This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch master updated. glibc-2.24-301-g726d48e


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  726d48ec96f8b8a27e17cffaacb83588589e2f78 (commit)
      from  e863cce57bff6cb795e6aad745ddf6235bca21ce (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=726d48ec96f8b8a27e17cffaacb83588589e2f78

commit 726d48ec96f8b8a27e17cffaacb83588589e2f78
Author: Gabriel F. T. Gomes <gftg@linux.vnet.ibm.com>
Date:   Tue Sep 20 14:19:27 2016 -0300

    Use read_int in vfscanf
    
    The function read_int, from printf-parse.h, parses an integer from a string
    while avoiding overflows.  It is used by other functions, such as vfprintf,
    to avoid undefined behavior.
    
    The function vfscanf (_IO_vfwscanf) parses an integer from the format
    string, and can use read_int.

diff --git a/ChangeLog b/ChangeLog
index de9056e..4b91b6a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2016-10-26  Gabriel F. T. Gomes  <gftg@linux.vnet.ibm.com>
+
+	* stdio-common/vfscanf.c (_IO_vfwscanf): Use read_int to parse
+	integer from the format string.
+
 2016-10-26  Florian Weimer  <fweimer@redhat.com>
 
 	[BZ #19473]
diff --git a/stdio-common/vfscanf.c b/stdio-common/vfscanf.c
index fe3677b..7caa96f 100644
--- a/stdio-common/vfscanf.c
+++ b/stdio-common/vfscanf.c
@@ -133,6 +133,8 @@
 # define WINT_T		int
 #endif
 
+#include "printf-parse.h" /* Use read_int.  */
+
 #define encode_error() do {						      \
 			  errval = 4;					      \
 			  __set_errno (EILSEQ);				      \
@@ -488,9 +490,7 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
       /* Check for a positional parameter specification.  */
       if (ISDIGIT ((UCHAR_T) *f))
 	{
-	  argpos = (UCHAR_T) *f++ - L_('0');
-	  while (ISDIGIT ((UCHAR_T) *f))
-	    argpos = argpos * 10 + ((UCHAR_T) *f++ - L_('0'));
+	  argpos = read_int ((const UCHAR_T **) &f);
 	  if (*f == L_('$'))
 	    ++f;
 	  else
@@ -525,11 +525,8 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
 
       /* Find the maximum field width.  */
       width = 0;
-      while (ISDIGIT ((UCHAR_T) *f))
-	{
-	  width *= 10;
-	  width += (UCHAR_T) *f++ - L_('0');
-	}
+      if (ISDIGIT ((UCHAR_T) *f))
+	width = read_int ((const UCHAR_T **) &f);
     got_width:
       if (width == 0)
 	width = -1;

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog              |    5 +++++
 stdio-common/vfscanf.c |   13 +++++--------
 2 files changed, 10 insertions(+), 8 deletions(-)


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]