]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Use al possible bytes from fopen mode string.
authorEric Blake <eblake@redhat.com>
Sat, 23 Apr 2011 03:40:57 +0000 (04:40 +0100)
committerPetr Baudis <pasky@ucw.cz>
Thu, 26 May 2011 22:38:46 +0000 (00:38 +0200)
(cherry picked from commit b722481ac27a296c5e4c4ef5ebb85f48a9efac95)

ChangeLog
libio/fileops.c

index 9d8ecac5726ff55a627694769954acaab05bfd99..ff00f2efd3743472f3e7f2d72486211cf1915dee 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-04-22  Ulrich Drepper  <drepper@gmail.com>
+
+       [BZ #12685]
+       * libio/fileops.c (_IO_new_file_fopen): Scan up to 7 bytes of the
+       mode string.
+       Patch by Eric Blake <eblake@redhat.com>.
+
 2011-04-17  Ulrich Drepper  <drepper@gmail.com>
 
        [BZ #12420]
index 4698953f7ae1d37b4e0911bf2e28cc72d7a1519e..1e7ef0754cd5d5cf0b046d825c5416ea91627910 100644 (file)
@@ -290,7 +290,7 @@ _IO_new_file_fopen (fp, filename, mode, is32not64)
 #ifdef _LIBC
   last_recognized = mode;
 #endif
-  for (i = 1; i < 6; ++i)
+  for (i = 1; i < 7; ++i)
     {
       switch (*++mode)
        {
@@ -997,18 +997,18 @@ _IO_new_file_seekoff (fp, offset, dir, mode)
       /* Adjust for read-ahead (bytes is buffer). */
       offset -= fp->_IO_read_end - fp->_IO_read_ptr;
       if (fp->_offset == _IO_pos_BAD)
-        {
-          if (mode != 0)
-            goto dumb;
-          else
-            {
-              result = _IO_SYSSEEK (fp, 0, dir);
-              if (result == EOF)
-                return result;
-
-              fp->_offset = result;
-            }
-        }
+       {
+         if (mode != 0)
+           goto dumb;
+         else
+           {
+             result = _IO_SYSSEEK (fp, 0, dir);
+             if (result == EOF)
+               return result;
+
+             fp->_offset = result;
+           }
+       }
       /* Make offset absolute, assuming current pointer is file_ptr(). */
       offset += fp->_offset;
       if (offset < 0)
@@ -1270,7 +1270,7 @@ _IO_new_file_write (f, data, n)
        {
          f->_flags |= _IO_ERR_SEEN;
          break;
-        }
+       }
       to_do -= count;
       data = (void *) ((char *) data + count);
     }
@@ -1358,12 +1358,12 @@ _IO_new_file_xsputn (f, data, n)
       do_write = to_do - (block_size >= 128 ? to_do % block_size : 0);
 
       if (do_write)
-        {
+       {
          count = new_do_write (f, s, do_write);
          to_do -= count;
          if (count < do_write)
            return n - to_do;
-        }
+       }
 
       /* Now write out the remainder.  Normally, this will fit in the
         buffer, but it's somewhat messier for line-buffered files,