]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Don't read past end of buffer in fmemopen
authorAndreas Schwab <schwab@redhat.com>
Fri, 4 Mar 2011 05:48:00 +0000 (00:48 -0500)
committerPetr Baudis <pasky@suse.cz>
Thu, 26 May 2011 22:10:58 +0000 (00:10 +0200)
(cherry picked from commit 9d25c392ba73065ac20f518d1cef1cdc96860545)

ChangeLog
libio/fmemopen.c

index 0aaabe754c001e01904a810dafb631178c5f05c3..a6fa7a9f962b2e3d42c04a452090e9850db55d20 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-03-03  Andreas Schwab  <schwab@redhat.com>
+
+       * libio/fmemopen.c (fmemopen): Don't read past end of buffer.
+
 2011-02-23  Andreas Schwab  <schwab@redhat.com>
            Ulrich Drepper  <drepper@gmail.com>
 
index d3750fc7de9ca358d8d8f75eb13e75ee5b55727f..1a631d5122969ff949484d5066abe48a3c0aae18 100644 (file)
@@ -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;