Blame SOURCES/glibc-rh1195762.patch

147e83
commit bdf1ff052a8e23d637f2c838fa5642d78fcedc33
147e83
Author: Paul Pluzhnikov <ppluzhnikov@google.com>
147e83
Date:   Sun Feb 22 12:01:47 2015 -0800
147e83
147e83
    Fix BZ #17269 -- _IO_wstr_overflow integer overflow
147e83
147e83
diff --git a/libio/wstrops.c b/libio/wstrops.c
147e83
index 43d847d..3993579 100644
147e83
--- a/libio/wstrops.c
147e83
+++ b/libio/wstrops.c
147e83
@@ -95,8 +95,11 @@ _IO_wstr_overflow (fp, c)
147e83
 	  wchar_t *old_buf = fp->_wide_data->_IO_buf_base;
147e83
 	  size_t old_wblen = _IO_wblen (fp);
147e83
 	  _IO_size_t new_size = 2 * old_wblen + 100;
147e83
-	  if (new_size < old_wblen)
147e83
+
147e83
+	  if (__glibc_unlikely (new_size < old_wblen)
147e83
+	      || __glibc_unlikely (new_size > SIZE_MAX / sizeof (wchar_t)))
147e83
 	    return EOF;
147e83
+
147e83
 	  new_buf
147e83
 	    = (wchar_t *) (*((_IO_strfile *) fp)->_s._allocate_buffer) (new_size
147e83
 									* sizeof (wchar_t));
147e83
@@ -186,6 +189,9 @@ enlarge_userbuf (_IO_FILE *fp, _IO_off64_t offset, int reading)
147e83
     return 1;
147e83
 
147e83
   _IO_size_t newsize = offset + 100;
147e83
+  if (__glibc_unlikely (newsize > SIZE_MAX / sizeof (wchar_t)))
147e83
+    return 1;
147e83
+
147e83
   wchar_t *oldbuf = wd->_IO_buf_base;
147e83
   wchar_t *newbuf
147e83
     = (wchar_t *) (*((_IO_strfile *) fp)->_s._allocate_buffer) (newsize