summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorray <ray@openbsd.org>2007-02-20 01:44:16 +0000
committerray <ray@openbsd.org>2007-02-20 01:44:16 +0000
commit0420c874a690622bb92bd10a07d234035b0874ed (patch)
tree13705e7bcb87d504ab07d5abfe98d4025b5c3e8c
parentknf found while fixing another bug (diff)
downloadwireguard-openbsd-0420c874a690622bb92bd10a07d234035b0874ed.tar.xz
wireguard-openbsd-0420c874a690622bb92bd10a07d234035b0874ed.zip
Change hard coded numbers to sizeof(buf). Also change some
sizeof(buf) - 1 to sizeof(buf), since fgets takes the whole buffer size. Based on diff from Charles Longeau <chl at tuxfamily dot org> long ago. OK millert@.
-rw-r--r--lib/libc/crypt/bcrypt.c6
-rw-r--r--lib/libc/rpc/getrpcent.c4
-rw-r--r--sbin/disklabel/disklabel.c6
-rw-r--r--sbin/dump/optr.c6
-rw-r--r--sbin/routed/parms.c4
-rw-r--r--usr.bin/tip/value.c6
-rw-r--r--usr.bin/tset/tset.c4
-rw-r--r--usr.bin/units/units.c8
-rw-r--r--usr.sbin/httpd/src/modules/standard/mod_cern_meta.c2
-rw-r--r--usr.sbin/ypserv/revnetgroup/parse_netgroup.c6
10 files changed, 26 insertions, 26 deletions
diff --git a/lib/libc/crypt/bcrypt.c b/lib/libc/crypt/bcrypt.c
index 3a09112b40c..2f547585a38 100644
--- a/lib/libc/crypt/bcrypt.c
+++ b/lib/libc/crypt/bcrypt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bcrypt.c,v 1.21 2006/07/04 19:06:00 otto Exp $ */
+/* $OpenBSD: bcrypt.c,v 1.22 2007/02/20 01:44:16 ray Exp $ */
/*
* Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
@@ -320,11 +320,11 @@ main()
snprintf(salt + 3, 4, "%2.2u$", 5);
printf("24 bytes of salt: ");
- fgets(salt + 6, 94, stdin);
+ fgets(salt + 6, sizeof(salt) - 6, stdin);
salt[99] = 0;
printf("72 bytes of password: ");
fpurge(stdin);
- fgets(blubber, 73, stdin);
+ fgets(blubber, sizeof(blubber), stdin);
blubber[72] = 0;
p = crypt(blubber, salt);
diff --git a/lib/libc/rpc/getrpcent.c b/lib/libc/rpc/getrpcent.c
index 444d113a6c6..b37381aa31c 100644
--- a/lib/libc/rpc/getrpcent.c
+++ b/lib/libc/rpc/getrpcent.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getrpcent.c,v 1.13 2005/08/08 08:05:35 espie Exp $ */
+/* $OpenBSD: getrpcent.c,v 1.14 2007/02/20 01:47:03 ray Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
@@ -141,7 +141,7 @@ getrpcent(void)
if (d->rpcf == NULL && (d->rpcf = fopen(RPCDB, "r")) == NULL)
return (NULL);
/* -1 so there is room to append a \n below */
- if (fgets(d->line, BUFSIZ-1, d->rpcf) == NULL)
+ if (fgets(d->line, sizeof(d->line) - 1, d->rpcf) == NULL)
return (NULL);
return (interpret(d->line, strlen(d->line)));
}
diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c
index 538a848902e..2db486a8def 100644
--- a/sbin/disklabel/disklabel.c
+++ b/sbin/disklabel/disklabel.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disklabel.c,v 1.103 2006/10/14 19:16:39 krw Exp $ */
+/* $OpenBSD: disklabel.c,v 1.104 2007/02/20 01:50:01 ray Exp $ */
/*
* Copyright (c) 1987, 1993
@@ -39,7 +39,7 @@ static const char copyright[] =
#endif /* not lint */
#ifndef lint
-static const char rcsid[] = "$OpenBSD: disklabel.c,v 1.103 2006/10/14 19:16:39 krw Exp $";
+static const char rcsid[] = "$OpenBSD: disklabel.c,v 1.104 2007/02/20 01:50:01 ray Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -1274,7 +1274,7 @@ getasciilabel(FILE *f, struct disklabel *lp)
lp->d_bbsize = BBSIZE; /* XXX */
lp->d_sbsize = SBSIZE; /* XXX */
- while (fgets(line, sizeof(line) - 1, f)) {
+ while (fgets(line, sizeof(line), f)) {
lineno++;
if ((cp = strpbrk(line, "#\r\n")))
*cp = '\0';
diff --git a/sbin/dump/optr.c b/sbin/dump/optr.c
index 2a153084f8c..6d3dd331445 100644
--- a/sbin/dump/optr.c
+++ b/sbin/dump/optr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: optr.c,v 1.28 2004/11/04 20:10:07 deraadt Exp $ */
+/* $OpenBSD: optr.c,v 1.29 2007/02/20 01:44:16 ray Exp $ */
/* $NetBSD: optr.c,v 1.11 1997/05/27 08:34:36 mrg Exp $ */
/*-
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)optr.c 8.2 (Berkeley) 1/6/94";
#else
-static const char rcsid[] = "$OpenBSD: optr.c,v 1.28 2004/11/04 20:10:07 deraadt Exp $";
+static const char rcsid[] = "$OpenBSD: optr.c,v 1.29 2007/02/20 01:44:16 ray Exp $";
#endif
#endif /* not lint */
@@ -92,7 +92,7 @@ query(char *question)
back = -1;
errcount = 0;
do {
- if (fgets(replybuffer, 63, mytty) == NULL) {
+ if (fgets(replybuffer, sizeof(replybuffer), mytty) == NULL) {
clearerr(mytty);
if (++errcount > 30) /* XXX ugly */
quit("excessive operator query failures\n");
diff --git a/sbin/routed/parms.c b/sbin/routed/parms.c
index f5f70de2b27..f446f7536f2 100644
--- a/sbin/routed/parms.c
+++ b/sbin/routed/parms.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parms.c,v 1.14 2006/10/24 19:44:29 moritz Exp $ */
+/* $OpenBSD: parms.c,v 1.15 2007/02/20 01:44:16 ray Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -145,7 +145,7 @@ gwkludge(void)
return;
for (;;) {
- if (fgets(lbuf, sizeof(lbuf)-1, fp) == NULL)
+ if (fgets(lbuf, sizeof(lbuf), fp) == NULL)
break;
lptr = lbuf;
while (*lptr == ' ')
diff --git a/usr.bin/tip/value.c b/usr.bin/tip/value.c
index f381a1f1773..1c236f9cb25 100644
--- a/usr.bin/tip/value.c
+++ b/usr.bin/tip/value.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: value.c,v 1.14 2006/03/17 22:02:58 moritz Exp $ */
+/* $OpenBSD: value.c,v 1.15 2007/02/20 01:44:16 ray Exp $ */
/* $NetBSD: value.c,v 1.6 1997/02/11 09:24:09 mrg Exp $ */
/*
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)value.c 8.1 (Berkeley) 6/6/93";
#endif
-static const char rcsid[] = "$OpenBSD: value.c,v 1.14 2006/03/17 22:02:58 moritz Exp $";
+static const char rcsid[] = "$OpenBSD: value.c,v 1.15 2007/02/20 01:44:16 ray Exp $";
#endif /* not lint */
#include "tip.h"
@@ -79,7 +79,7 @@ vinit(void)
if ((fp = fopen(file, "r")) != NULL) {
char *tp;
- while (fgets(file, sizeof(file)-1, fp) != NULL) {
+ while (fgets(file, sizeof(file), fp) != NULL) {
if (vflag)
printf("set %s", file);
if ((tp = strrchr(file, '\n')))
diff --git a/usr.bin/tset/tset.c b/usr.bin/tset/tset.c
index 8d78d3c4594..f44bafa1882 100644
--- a/usr.bin/tset/tset.c
+++ b/usr.bin/tset/tset.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tset.c,v 1.28 2006/10/10 21:38:16 cloder Exp $ */
+/* $OpenBSD: tset.c,v 1.29 2007/02/20 01:52:01 ray Exp $ */
/****************************************************************************
* Copyright (c) 1998,1999,2000 Free Software Foundation, Inc. *
@@ -530,7 +530,7 @@ get_termcap_entry(char *userarg)
char buffer[BUFSIZ];
char *s, *t, *d;
- while (fgets(buffer, sizeof(buffer) - 1, fp) != NULL) {
+ while (fgets(buffer, sizeof(buffer), fp) != NULL) {
for (s = buffer, t = d = 0; *s; s++) {
if (isspace(CharOf(*s)))
*s = '\0';
diff --git a/usr.bin/units/units.c b/usr.bin/units/units.c
index 09399bf6094..8335c156db4 100644
--- a/usr.bin/units/units.c
+++ b/usr.bin/units/units.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: units.c,v 1.11 2004/12/02 22:54:55 pat Exp $ */
+/* $OpenBSD: units.c,v 1.12 2007/02/20 01:56:12 ray Exp $ */
/* $NetBSD: units.c,v 1.6 1996/04/06 06:01:03 thorpej Exp $ */
/*
@@ -153,7 +153,7 @@ readunits(char *userfile)
}
}
while (!feof(unitfile)) {
- if (!fgets(line, 79, unitfile))
+ if (!fgets(line, sizeof(line), unitfile))
break;
linenum++;
lineptr = line;
@@ -713,7 +713,7 @@ main(int argc, char **argv)
initializeunit(&have);
if (!quiet)
printf("You have: ");
- if (!fgets(havestr, 80, stdin)) {
+ if (!fgets(havestr, sizeof(havestr), stdin)) {
if (!quiet)
putchar('\n');
exit(0);
@@ -724,7 +724,7 @@ main(int argc, char **argv)
initializeunit(&want);
if (!quiet)
printf("You want: ");
- if (!fgets(wantstr, 80, stdin)) {
+ if (!fgets(wantstr, sizeof(wantstr), stdin)) {
if (!quiet)
putchar('\n');
exit(0);
diff --git a/usr.sbin/httpd/src/modules/standard/mod_cern_meta.c b/usr.sbin/httpd/src/modules/standard/mod_cern_meta.c
index 766f6a81515..44a252bf3b1 100644
--- a/usr.sbin/httpd/src/modules/standard/mod_cern_meta.c
+++ b/usr.sbin/httpd/src/modules/standard/mod_cern_meta.c
@@ -238,7 +238,7 @@ static int scan_meta_file(request_rec *r, FILE *f)
table *tmp_headers;
tmp_headers = ap_make_table(r->pool, 5);
- while (fgets(w, MAX_STRING_LEN - 1, f) != NULL) {
+ while (fgets(w, sizeof(w), f) != NULL) {
/* Delete terminal (CR?)LF */
diff --git a/usr.sbin/ypserv/revnetgroup/parse_netgroup.c b/usr.sbin/ypserv/revnetgroup/parse_netgroup.c
index 1e2d935c18c..831a084b9cc 100644
--- a/usr.sbin/ypserv/revnetgroup/parse_netgroup.c
+++ b/usr.sbin/ypserv/revnetgroup/parse_netgroup.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse_netgroup.c,v 1.10 2006/04/03 05:01:23 deraadt Exp $ */
+/* $OpenBSD: parse_netgroup.c,v 1.11 2007/02/20 01:44:16 ray Exp $ */
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -47,7 +47,7 @@
#include "hash.h"
#ifndef lint
-static const char rcsid[] = "$OpenBSD: parse_netgroup.c,v 1.10 2006/04/03 05:01:23 deraadt Exp $";
+static const char rcsid[] = "$OpenBSD: parse_netgroup.c,v 1.11 2007/02/20 01:44:16 ray Exp $";
#endif
/*
@@ -335,7 +335,7 @@ read_for_group(char *group)
}
#ifdef CANT_HAPPEN
if (cont) {
- if (fgets(line, LINSIZ, netf)) {
+ if (fgets(line, sizeof(line), netf)) {
pos = line;
len = strlen(pos);
} else