This is the mail archive of the glibc-bugs@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]

[Bug stdio/17829] Incorrect handling of precision specifier in printf family


https://sourceware.org/bugzilla/show_bug.cgi?id=17829

--- Comment #7 from Alexander Cherepanov <cherepan at mccme dot ru> ---
1. The same problem with the width. Consider the program:

#include <stdio.h>
#include <errno.h>

int main()
{
   int res =  printf("%2147483647d", 1);
   fprintf(stderr, "res = %d, errno = %d\n", res, errno);
}

printf should succeed but it fails: "res = -1, errno = 75". There are 
two problematic checks similar to the one for precision:

https://sourceware.org/git/?p=glibc.git;a=blob;f=stdio-common/vfprintf.c;h=6829d4dc8e7fe7c066a06f1857ee926e0f48c379;hb=HEAD#l1459
https://sourceware.org/git/?p=glibc.git;a=blob;f=stdio-common/vfprintf.c;h=6829d4dc8e7fe7c066a06f1857ee926e0f48c379;hb=HEAD#l1491

2. When the width is taken from an argument via asterisk, INT_MIN is not 
handled properly -- signed integer overflow:

1451         /* Negative width means left justified.  */
1452         if (width < 0)
1453           {
1454             width = -width;
1455             pad = L_(' ');
1456             left = 1;
1457           }

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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