Module Name: src Committed By: roy Date: Tue Jul 14 18:29:41 UTC 2009
Modified Files: src/lib/libc/stdio: getdelim.c Log Message: Allow a buffer of SSIZE_MAX + 1 as the returned bytes do not include the NULL. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/lib/libc/stdio/getdelim.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libc/stdio/getdelim.c diff -u src/lib/libc/stdio/getdelim.c:1.2 src/lib/libc/stdio/getdelim.c:1.3 --- src/lib/libc/stdio/getdelim.c:1.2 Tue Jul 14 17:04:32 2009 +++ src/lib/libc/stdio/getdelim.c Tue Jul 14 18:29:41 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: getdelim.c,v 1.2 2009/07/14 17:04:32 christos Exp $ */ +/* $NetBSD: getdelim.c,v 1.3 2009/07/14 18:29:41 roy Exp $ */ /* * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -28,7 +28,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: getdelim.c,v 1.2 2009/07/14 17:04:32 christos Exp $"); +__RCSID("$NetBSD: getdelim.c,v 1.3 2009/07/14 18:29:41 roy Exp $"); #include <sys/param.h> @@ -85,12 +85,13 @@ else len = (p - fp->_p) + 1; - newlen = off + len + 1; + newlen = off + len; /* Ensure that the resultant buffer length fits in ssize_t */ - if (newlen >= (size_t)SSIZE_MAX) { + if (newlen > (size_t)SSIZE_MAX) { errno = EOVERFLOW; goto error; } + newlen++; /* reserve space for the NULL terminator */ if (newlen > *buflen) { if (newlen < MINBUF) newlen = MINBUF;