Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [day] [month] [year] [list]
Date: Sun, 24 Apr 2011 22:41:20 +0200
From: "" <>
Subject: patch for sscanf issues

the current sscanf implementation has 2 issues:
- it doesnt return EOF with fscanf, which causes the /gcc/genhooks.c to 
enter an endless loop when compiling gcc 4.6.0
- it doesnt return the correct value in %n pointer, when something like 
"%*d%n" is used

both bugs are fixed in the following patch. this means a) gcc 4.6.0 
compilation succeeds now, and b) musl now passes the rigorous sscanf 
testsuite of gnu gmp, which is executed when "make check" is called.

here are some testcases
bug 1: EOF (testcase.txt is available here: )
this one causes GCC compilation to fail

         FILE* f = fopen("testcase.txt", "r");

         while (fscanf (f, "%*[^@]"), buf[0] = '\0',
                  fscanf (f, "@%5[^ \n]", buf) != EOF) {
                 if(*buf) {
                         printf("%d: %s\n",i,buf);

bug 2: %n after %*d
this one causes GMP testsuite to fail

     int i;
         assert(sscanf ("123", "%*d%d", &i) == -1);
         assert(sscanf ("123", "%*d%n", &i) == 0);
         printf("value passed in pointer: %d\n", i); // it seems glibc 
returns 3 in i, while musl returns 2
         ret = sscanf("123" + i, "%d%n", &i);
         printf("%d\n", ret);
         assert(ret == -1);

regards, günter schäffler.

View attachment "musl-patch" of type "text/plain" (849 bytes)

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.