summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen/getusershell.c
diff options
context:
space:
mode:
authortobias <tobias@openbsd.org>2014-01-19 21:01:06 +0000
committertobias <tobias@openbsd.org>2014-01-19 21:01:06 +0000
commitf0b13b6daea08b8d3c68a5c5569f8dfa1fc77095 (patch)
treecfc6f5feaf3d2fe74fd9f078b749b108f11212bc /lib/libc/gen/getusershell.c
parentIf the system runs out ouf mbufs, the receive queue of the vio (diff)
downloadwireguard-openbsd-f0b13b6daea08b8d3c68a5c5569f8dfa1fc77095.tar.xz
wireguard-openbsd-f0b13b6daea08b8d3c68a5c5569f8dfa1fc77095.zip
Fix one more off-by-one (making it an off-by-two):
1. integer division can give an off-by-one (like 2/3 = 0 for calloc) 2. ending the shells array with NULL takes space, too ok millert@
Diffstat (limited to 'lib/libc/gen/getusershell.c')
-rw-r--r--lib/libc/gen/getusershell.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libc/gen/getusershell.c b/lib/libc/gen/getusershell.c
index 36af0ee2639..56ad2093b72 100644
--- a/lib/libc/gen/getusershell.c
+++ b/lib/libc/gen/getusershell.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getusershell.c,v 1.12 2014/01/17 20:51:54 tobias Exp $ */
+/* $OpenBSD: getusershell.c,v 1.13 2014/01/19 21:01:06 tobias Exp $ */
/*
* Copyright (c) 1985, 1993
* The Regents of the University of California. All rights reserved.
@@ -109,7 +109,7 @@ initshells(void)
(void)fclose(fp);
return (okshells);
}
- shells = calloc((size_t)(statb.st_size / 3 + 1), sizeof (char *));
+ shells = calloc((size_t)(statb.st_size / 3 + 2), sizeof (char *));
if (shells == NULL) {
(void)fclose(fp);
free(strings);