Bug#488013: libglib2.0-0: function g_ascii_strtoll is broken
Flavio Poletti
flavio at polettix.it
Wed Jun 25 18:15:35 UTC 2008
Subject: libglib2.0-0: function g_ascii_strtoll is broken
Package: libglib2.0-0
Version: 2.12.4-2
Severity: normal
*** Please type your report below this line ***
g_ascii_strtoll is broken in 2.12.4, which comes streamline with Etch.
Patch for this is included.
The implementation has been changed (I don't know exactly when) to cope
with errors while converting negative values. The proposed patch to
glib/gstrfuncs.c "upgrades" the function to the correct implementation
that can be found, for example, in 2.16.3.
Tests for it were added as well. In particular, there are more tests
than in 2.16.3 (including those present in 2.16.3, anyway), because
two tests for near-the-limit values were added. If you execute the
patched test file in a non-patched system, you'll get an error.
Cheers,
Flavio Poletti.
-- BEGIN OF PATCH --
diff broken/glib/gstrfuncs.c patched/glib/gstrfuncs.c
--- broken/glib/gstrfuncs.c
+++ patched/glib/gstrfuncs.c
@@ -813,6 +813,8 @@
errno = ERANGE;
return G_MAXINT64;
}
+ else if (negative)
+ return - (gint64) result;
else
return (gint64) result;
}
diff broken/tests/strtoll-test.c patched/tests/strtoll-test.c
--- broken/tests/strtoll-test.c
+++ patched/tests/strtoll-test.c
@@ -58,8 +58,14 @@
test_uint64 ("-1", "", 10, G_MAXUINT64, 0);
test_int64 ("0", "", 10, 0, 0);
+ test_int64 ("42", "", 10, 42, 0);
+ test_int64 ("-42", "", 10, -42, 0);
+ test_int64 ("32768", "", 10, 32768, 0);
+ test_int64 ("-32768", "", 10, -32768, 0);
+ test_int64 ("9223372036854775806", "", 10, G_MAXINT64 - 1, 0);
test_int64 ("9223372036854775807", "", 10, G_MAXINT64, 0);
test_int64 ("9223372036854775808", "", 10, G_MAXINT64, ERANGE);
+ test_int64 ("-9223372036854775807", "", 10, G_MININT64 + 1, 0);
test_int64 ("-9223372036854775808", "", 10, G_MININT64, 0);
test_int64 ("-9223372036854775809", "", 10, G_MININT64, ERANGE);
-- END OF PATCH --
-- System Information:
Debian Release: 4.0
APT prefers stable
APT policy: (500, 'stable')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-6-686
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Versions of packages libglib2.0-0 depends on:
ii libc6 2.3.6.ds1-13etch5 GNU C Library: Shared libraries
Versions of packages libglib2.0-0 recommends:
ii libglib2.0-data 2.12.4-2 Common files for GLib library
-- no debconf information
More information about the pkg-gnome-maintainers
mailing list