diff options
author | 2007-09-25 11:35:00 +0000 | |
---|---|---|
committer | 2007-09-25 11:35:00 +0000 | |
commit | fe0a6c2a69ee802bae4e48b1adc2830eabb6fea1 (patch) | |
tree | 9b61f7b7e3b50db1b2a38009ba01bf524bd6bb95 | |
parent | Last missing piece in the equal cost multipath support for ospfd. (diff) | |
download | wireguard-openbsd-fe0a6c2a69ee802bae4e48b1adc2830eabb6fea1.tar.xz wireguard-openbsd-fe0a6c2a69ee802bae4e48b1adc2830eabb6fea1.zip |
handle empty strings returned by fgets
use strcspn to properly overwrite '\n' in fgets returned buffer
ok ray@
-rw-r--r-- | usr.bin/tn3270/tools/mkhits/dohits.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/usr.bin/tn3270/tools/mkhits/dohits.c b/usr.bin/tn3270/tools/mkhits/dohits.c index 5e6ba71805e..11059beabbf 100644 --- a/usr.bin/tn3270/tools/mkhits/dohits.c +++ b/usr.bin/tn3270/tools/mkhits/dohits.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dohits.c,v 1.8 2003/06/03 02:56:20 millert Exp $ */ +/* $OpenBSD: dohits.c,v 1.9 2007/09/25 11:35:00 chl Exp $ */ /*- * Copyright (c) 1988 The Regents of the University of California. @@ -31,7 +31,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)dohits.c 4.2 (Berkeley) 4/26/91";*/ -static char rcsid[] = "$OpenBSD: dohits.c,v 1.8 2003/06/03 02:56:20 millert Exp $"; +static char rcsid[] = "$OpenBSD: dohits.c,v 1.9 2007/09/25 11:35:00 chl Exp $"; #endif /* not lint */ /* @@ -133,7 +133,7 @@ char *file, /* Name of file to scan for whitespace prefix */ } break; } - } while (line[strlen(line)-1] != '\n'); + } while (strchr(line, '\n') == NULL); } } @@ -173,7 +173,7 @@ char *file, /* Name of file to scan for #define prefix */ } break; } - } while (line[strlen(line)-1] != '\n'); + } while (strchr(line, '\n') == NULL); } } @@ -257,8 +257,7 @@ char *aidfile, *fcnfile; scanwhite(fcnfile, "FCN_"); while (fgets(line, sizeof(line), stdin) != NULL) { - if (line[strlen(line)-1] == '\n') - line[strlen(line)-1] = '\0'; + line[strcspn(line, "\n")] = '\0'; if (!isdigit(line[0])) { continue; } |