[PATCH] _store_inttype is broken for x86_64

Roman Kononov roman at xtremedatainc.com
Wed Jan 24 15:07:59 UTC 2007


Hello,

In libc/stdio/_store_inttype.c, _store_inttype(), for x86_64,
when desttype==PA_FLAG_LONG_LONG,

line 57:   *((unsigned int *) dest) = val;

is performed, while

line 40:   *((unsigned long long int *) dest) = val;

must be done.

To confirm that this is a bug try this on x86_64:

int main() {
     unsigned long long val=~0ull;
     sscanf("123456789","%Lx",&val);
     printf("val=%Lx\n");
     return 0;
}

It will show "val=ffffffff23456789"

The patch fixes this.

Regards, Roman
------------------------------------------------
Index: libc/stdio/_store_inttype.c
===================================================================
--- libc/stdio/_store_inttype.c (revision 17475)
+++ libc/stdio/_store_inttype.c (working copy)
@@ -35,7 +35,7 @@
                 *((unsigned char *) dest) = val;
                 return;
         }
-#if defined(LLONG_MAX) && (LONG_MAX != LLONG_MAX)
+#if defined(LLONG_MAX) && (LLONG_MAX != INT_MAX)
         if (desttype == PA_FLAG_LONG_LONG) {
                 *((unsigned long long int *) dest) = val;
                 return;






More information about the uClibc mailing list