Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <f1c6f16a-a6fd-8447-5f9b-d3d25a044af4@gmail.com>
Date: Sun, 18 Dec 2022 10:32:10 +0100
From: Domingo Alvarez Duarte <mingodad@...il.com>
To: musl@...ts.openwall.com
Subject: Bug in atoll strtoll, the output of then differ

Hello !

Doing some work with emscripten with this project 
https://github.com/mingodad/CG-SQL-Lua-playground I was getting some 
errors with the usage of "atoll" and with this small program to compare 
the output of "musl" and "glibc" I found what seems to be a bug in 
"atoll" because with "musl" it gives a different output than "strtoll".

=====

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
     const char *s = "9223372036854775808";
     long  long ll = atoll(s);
     long long ll2 = strtoll (s, (char **) NULL, 10);
     int imax = 0x7fffffff;
     printf("%s : %lld : %lld : %d : %d\n",  s, ll, ll2, imax, ll <= imax);
     return 0;
}

=====

Output from "glibc":

=====

9223372036854775808 : 9223372036854775807 : 9223372036854775807 : 
2147483647 : 0

=====

Output from "musl":

=====

9223372036854775808 : -9223372036854775808 : 9223372036854775807 : 
2147483647 : 1

=====

Cheers !

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.