summaryrefslogtreecommitdiffstats
path: root/lib/libc
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 /lib/libc
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@.
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/crypt/bcrypt.c6
-rw-r--r--lib/libc/rpc/getrpcent.c4
2 files changed, 5 insertions, 5 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)));
}