From: Andreas Schwab Date: Fri, 4 Mar 2011 05:48:00 +0000 (-0500) Subject: Don't read past end of buffer in fmemopen X-Git-Tag: glibc-2.14~219 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9d25c392ba73065ac20f518d1cef1cdc96860545;p=thirdparty%2Fglibc.git Don't read past end of buffer in fmemopen --- diff --git a/ChangeLog b/ChangeLog index 2cfa1e40469..16da2c1fa66 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-03-03 Andreas Schwab + + * libio/fmemopen.c (fmemopen): Don't read past end of buffer. + 2011-03-03 Roland McGrath * setjmp/bits/setjmp2.h: Canonicalize comment formatting. diff --git a/libio/fmemopen.c b/libio/fmemopen.c index d3750fc7de9..1a631d51229 100644 --- a/libio/fmemopen.c +++ b/libio/fmemopen.c @@ -1,5 +1,5 @@ /* Fmemopen implementation. - Copyright (C) 2000, 2002, 2005, 2006, 2008, 2009 + Copyright (C) 2000, 2002, 2005, 2006, 2008, 2009, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Hanno Mueller, kontakt@hanno.de, 2000. @@ -243,7 +243,7 @@ fmemopen (void *buf, size_t len, const char *mode) if (mode[0] == 'w') c->buffer[0] = '\0'; - c->maxpos = strlen (c->buffer); + c->maxpos = strnlen (c->buffer, len); if (mode[0] == 'a') c->pos = c->maxpos;