diff options
author | 2007-11-28 18:20:39 +0000 | |
---|---|---|
committer | 2007-11-28 18:20:39 +0000 | |
commit | 7f09bb9dce6e7b0a8cc018a4e4a28f30a84dc780 (patch) | |
tree | 75a0220676ad3d1128d8f73d50a8ffc1c742feb2 | |
parent | when we probe a port send an ata inquiry to the device and cache (diff) | |
download | wireguard-openbsd-7f09bb9dce6e7b0a8cc018a4e4a28f30a84dc780.tar.xz wireguard-openbsd-7f09bb9dce6e7b0a8cc018a4e4a28f30a84dc780.zip |
use sizeof (buf) instead of hardcoded value
use strcspn to properly overwrite '\n' in fgets returned buffer
ok ray@
-rw-r--r-- | gnu/usr.sbin/mkhybrid/src/libfile/apprentice.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/gnu/usr.sbin/mkhybrid/src/libfile/apprentice.c b/gnu/usr.sbin/mkhybrid/src/libfile/apprentice.c index fecc3086291..fd98f50e65d 100644 --- a/gnu/usr.sbin/mkhybrid/src/libfile/apprentice.c +++ b/gnu/usr.sbin/mkhybrid/src/libfile/apprentice.c @@ -42,7 +42,7 @@ #ifndef lint static char *moduleid = - "@(#)$Id: apprentice.c,v 1.1 2000/10/10 20:40:36 beck Exp $"; + "@(#)$Id: apprentice.c,v 1.2 2007/11/28 18:20:39 chl Exp $"; #endif /* lint */ #define EATAB {while (isascii((unsigned char) *l) && \ @@ -97,12 +97,13 @@ int check; /* non-zero? checking-only run. */ if (check) /* print silly verbose header for USG compat. */ (void) printf("%s\n", hdr); - for (lineno = 1;fgets(line, BUFSIZ, f) != NULL; lineno++) { + for (lineno = 1;fgets(line, sizeof(line), f) != NULL; lineno++) { if (line[0]=='#') /* comment, do not parse */ continue; - if (strlen(line) <= (unsigned)1) /* null line, garbage, etc */ + /* delete newline */ + line[strcspn(line, "\n")] = '\0'; + if (line[0] == '\0') continue; - line[strlen(line)-1] = '\0'; /* delete newline */ if (parse(line, &nmagic, check) != 0) errs = 1; } |