=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/units/units.c,v retrieving revision 1.6 retrieving revision 1.7 diff -c -r1.6 -r1.7 *** src/usr.bin/units/units.c 1999/06/13 16:34:21 1.6 --- src/usr.bin/units/units.c 2001/01/17 19:29:49 1.7 *************** *** 1,4 **** ! /* $OpenBSD: units.c,v 1.6 1999/06/13 16:34:21 pjanzen Exp $ */ /* $NetBSD: units.c,v 1.6 1996/04/06 06:01:03 thorpej Exp $ */ /* --- 1,4 ---- ! /* $OpenBSD: units.c,v 1.7 2001/01/17 19:29:49 deraadt Exp $ */ /* $NetBSD: units.c,v 1.6 1996/04/06 06:01:03 thorpej Exp $ */ /* *************** *** 43,49 **** struct { char *uname; char *uval; ! } unittable[MAXUNITS]; struct unittype { char *numerator[MAXSUBUNITS]; --- 43,49 ---- struct { char *uname; char *uval; ! } unittable[MAXUNITS]; struct unittype { char *numerator[MAXSUBUNITS]; *************** *** 54,60 **** struct { char *prefixname; char *prefixval; ! } prefixtable[MAXPREFIXES]; char *NULLUNIT = ""; --- 54,60 ---- struct { char *prefixname; char *prefixval; ! } prefixtable[MAXPREFIXES]; char *NULLUNIT = ""; *************** *** 74,85 **** { char *ret; ! ret = malloc(strlen(str) + 1); if (!ret) { fprintf(stderr, "Memory allocation error\n"); exit(3); } - strcpy(ret, str); return (ret); } --- 74,84 ---- { char *ret; ! ret = strdup(str); if (!ret) { fprintf(stderr, "Memory allocation error\n"); exit(3); } return (ret); } *************** *** 443,450 **** copy[strlen(copy) - 1] = '\0'; for (i = 0; i < unitcount; i++) { if (!strcmp(unittable[i].uname, copy)) { ! strncpy(buffer, copy, sizeof(buffer) - 1); ! buffer[sizeof(buffer) - 1] = '\0'; free(copy); return buffer; } --- 442,448 ---- copy[strlen(copy) - 1] = '\0'; for (i = 0; i < unitcount; i++) { if (!strcmp(unittable[i].uname, copy)) { ! strlcpy(buffer, copy, sizeof(buffer)); free(copy); return buffer; } *************** *** 456,463 **** copy[strlen(copy) - 1] = 0; for (i = 0; i < unitcount; i++) { if (!strcmp(unittable[i].uname, copy)) { ! strncpy(buffer, copy, sizeof(buffer) - 1); ! buffer[sizeof(buffer) - 1] = '\0'; free(copy); return buffer; } --- 454,460 ---- copy[strlen(copy) - 1] = 0; for (i = 0; i < unitcount; i++) { if (!strcmp(unittable[i].uname, copy)) { ! strlcpy(buffer, copy, sizeof(buffer)); free(copy); return buffer; } *************** *** 466,473 **** copy[strlen(copy) - 1] = 0; for (i = 0; i < unitcount; i++) { if (!strcmp(unittable[i].uname, copy)) { ! strncpy(buffer, copy, sizeof(buffer) - 1); ! buffer[sizeof(buffer) - 1] = '\0'; free(copy); return buffer; } --- 463,469 ---- copy[strlen(copy) - 1] = 0; for (i = 0; i < unitcount; i++) { if (!strcmp(unittable[i].uname, copy)) { ! strlcpy(buffer, copy, sizeof(buffer)); free(copy); return buffer; } *************** *** 669,678 **** readunits(userfile); if (optind == argc - 2) { ! strncpy(havestr, argv[optind], sizeof(havestr) - 1); ! havestr[sizeof(havestr) - 1] = '\0'; ! strncpy(wantstr, argv[optind + 1], sizeof(wantstr) - 1); ! wantstr[sizeof(wantstr) - 1] = '\0'; initializeunit(&have); addunit(&have, havestr, 0); completereduce(&have); --- 665,672 ---- readunits(userfile); if (optind == argc - 2) { ! strlcpy(havestr, argv[optind], sizeof(havestr)); ! strlcpy(wantstr, argv[optind + 1], sizeof(wantstr)); initializeunit(&have); addunit(&have, havestr, 0); completereduce(&have);