Note that there are some explanatory texts on larger screens.

plurals
  1. POglibc function strtoull() failure
    primarykey
    data
    text
    <p>I am facing issue with c library function strtoull which is returning me wrong output.</p> <pre><code> int main(int argc, char *argv[]) { unsigned long long int intValue; if(atoi(argv[2]) == 1) { intValue = strtoull((const char *)argv[1], 0, 10 ); } else { // ... } printf("intValue of %s is %llu \n", argv[1], intValue); return 0; } </code></pre> <p>I built them and generated 32 and 64 bit executables as str32_new and str64_new. But the output received from 32 bit exe is errorneous as wrong number is returned:</p> <p>strtoull should had returned me number 5368709120 for the passed string "5368709120" but it returned me 1073741824.</p> <pre><code># ./str32_new "5368709120" 1 intValue of 5368709120 is 1073741824 </code></pre> <p>I note that when I decrease one character from string then it shows proper output.</p> <pre><code># ./str32_new "536870912" 1 intValue of 536870912 is 536870912 </code></pre> <p>glibc attached to 32 bit exe is</p> <pre><code> # readelf -Wa /home/str32_new | grep strt [39] .shstrtab STRTAB 00000000 002545 000190 00 0 0 1 [41] .strtab STRTAB 00000000 0032f8 0002a4 00 0 0 1 0804a014 00000607 R_386_JUMP_SLOT 00000000 strtoull 6: 00000000 0 FUNC GLOBAL DEFAULT UND strtoull@GLIBC_2.0 (2) 55: 00000000 0 FILE LOCAL DEFAULT ABS strtoull.c 75: 00000000 0 FUNC GLOBAL DEFAULT UND strtoull@@GLIBC_2.0 77: 08048534 915 FUNC GLOBAL DEFAULT 15 my_strtoull </code></pre> <p>glibc attached to 64 bit exe is</p> <pre><code> # readelf -Wa /home/str64_new | grep strt [39] .shstrtab STRTAB 0000000000000000 001893 000192 00 0 0 1 [41] .strtab STRTAB 0000000000000000 002cd0 00029b 00 0 0 1 0000000000601028 0000000700000007 R_X86_64_JUMP_SLOT 0000000000000000 strtoull + 0 7: 0000000000000000 0 FUNC GLOBAL DEFAULT UND strtoull@GLIBC_2.2.5 (2) 57: 0000000000000000 0 FILE LOCAL DEFAULT ABS strtoull.c 73: 00000000004006cc 804 FUNC GLOBAL DEFAULT 15 my_strtoull 82: 0000000000000000 0 FUNC GLOBAL DEFAULT UND strtoull@@GLIBC_2.2.5 </code></pre> <p>64 bit exe shows proper output but on some system it too behaves abnormally. Why is the strtoull in 32 bit exe behaving so and how to resolve this issue?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload