]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
libio: Limit buffer size to 8192 bytes [BZ #4099]
authorFlorian Weimer <fweimer@redhat.com>
Wed, 30 Nov 2016 13:59:27 +0000 (14:59 +0100)
committerFlorian Weimer <fweimer@redhat.com>
Wed, 30 Nov 2016 13:59:27 +0000 (14:59 +0100)
This avoids overly large buffers with network file systems which report
very large block sizes.

ChangeLog
NEWS
libio/filedoalloc.c

index 40f460f759181bcaf5970c4cfdad81f143729699..c2cb6080650955bff7e2e68d0a9550980a16c385 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2016-11-30  Florian Weimer  <fweimer@redhat.com>
+
+       [BZ #4099]
+       * libio/filedoalloc.c (_IO_file_doallocate): Limit buffer size to
+       _IO_BUFSIZ (8192).
+
 2016-11-30  Carlos O'Donell  <carlos@redhat.com>
 
        * PROJECTS: Remove file.
diff --git a/NEWS b/NEWS
index 9a45e730aff49adff43374146226bf1633ca6514..b2a0b0f1f8f11fc46ccbcd04e5e32c4a12ebd530 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -80,6 +80,12 @@ Version 2.25
   affect the ABI of other libraries that use this type in their interfaces,
   if they are compiled or used with those options.
 
+* The buffer size for byte-oriented stdio streams is now limited to 8192
+  bytes by default.  Previously, on Linux, the default buffer size on most
+  file systems was 4096 bytes (and thus remains unchanged), except on
+  network file systems, where the buffer size was unpredictable and could be
+  as large as several megabytes.
+
 * The <sys/quota.h> header now includes the <linux/quota.h> header.  Support
   for the Linux quota interface which predates kernel version 2.4.22 has
   been removed.
index 4f9d73896820b9d8245e7970814f493ad7a1b633..ded0725356e35a1e588e7570e56343a642fd012f 100644 (file)
@@ -94,7 +94,7 @@ _IO_file_doallocate (_IO_FILE *fp)
            fp->_flags |= _IO_LINE_BUF;
        }
 #if _IO_HAVE_ST_BLKSIZE
-      if (st.st_blksize > 0)
+      if (st.st_blksize > 0 && st.st_blksize < _IO_BUFSIZ)
        size = st.st_blksize;
 #endif
     }