summary refs log tree commit diff
path: root/libio/fmemopen.c
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@redhat.com>2011-03-04 00:48:00 -0500
committerUlrich Drepper <drepper@gmail.com>2011-03-04 00:48:00 -0500
commit9d25c392ba73065ac20f518d1cef1cdc96860545 (patch)
tree118582e0a368a8980cd7063b4c8b06aa92f7b9bc /libio/fmemopen.c
parenta5543c6ad807f0b8ea793cb6d385f3dbeb0d98c5 (diff)
downloadglibc-9d25c392ba73065ac20f518d1cef1cdc96860545.tar.gz
glibc-9d25c392ba73065ac20f518d1cef1cdc96860545.tar.xz
glibc-9d25c392ba73065ac20f518d1cef1cdc96860545.zip
Don't read past end of buffer in fmemopen
Diffstat (limited to 'libio/fmemopen.c')
-rw-r--r--libio/fmemopen.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libio/fmemopen.c b/libio/fmemopen.c
index d3750fc7de..1a631d5122 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;