Andreas Tille pushed to branch master at Debian Med / libsonlib
Commits: 09b88fa1 by Andreas Tille at 2026-11-09T13:22:50+01:00 Fix infinite loop in file line-reading on unsigned-char architectures - - - - - b4291e4d by Andreas Tille at 2026-11-09T13:24:09+01:00 Fix undefined behaviour in stString_print test - - - - - bf76d241 by Andreas Tille at 2026-11-09T13:26:40+01:00 Upload to unstable - - - - - 4 changed files: - debian/changelog - + debian/patches/fix_char_getc_eof.patch - + debian/patches/fix_stString_print_varargs.patch - debian/patches/series Changes: ===================================== debian/changelog ===================================== @@ -1,3 +1,10 @@ +libsonlib (1.1+git20220915.5cbc158+dfsg1-3) unstable; urgency=medium + + * Fix infinite loop in file line-reading on unsigned-char architectures + * Fix undefined behaviour in stString_print test + + -- Andreas Tille <[email protected]> Mon, 09 Nov 2026 13:24:36 +0100 + libsonlib (1.1+git20220915.5cbc158+dfsg1-2) unstable; urgency=medium * Link the shared library against libquicktree so that the TreeREP ===================================== debian/patches/fix_char_getc_eof.patch ===================================== @@ -0,0 +1,48 @@ +Description: Fix infinite loop in file line-reading on unsigned-char architectures + getc(3) returns an int (0..255 or EOF, which is -1). The line-reading + helpers in sonLibFile.c and bioioC.c cast the result to char before + checking it against EOF. That cast is implementation-defined: on + architectures where plain char is unsigned (arm64, armhf, ppc64, + ppc64el, powerpc, s390x, ...) EOF (-1) becomes 255, so the + `ch == EOF` termination check never fires and the reader loops forever + on the last (newline-less or empty) line of a file. +. +This makes the sonLibTests suite hang indefinitely on those +architectures at test_stFile_getLineFromFile / benLine, causing the +build to be killed by the buildd timeout. Reading into an int64_t +directly without the char truncation fixes EOF detection everywhere and +is behaviour-identical on signed-char architectures. +Author: Andreas Tille <[email protected]> +Last-Update: 2026-11-09 +Assisted-By: scaleway/deepseek-v4-flash-0731 +--- + C/impl/sonLibFile.c | 2 +- + C/impl/bioioC.c | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/C/impl/sonLibFile.c b/C/impl/sonLibFile.c +index 3a62e03..e12c1ac 100644 +--- a/C/impl/sonLibFile.c ++++ b/C/impl/sonLibFile.c +@@ -22,7 +22,7 @@ static int64_t stFile_getLineFromFileP(char **s, int64_t *n, FILE *f) { + + char *s2 = *s; + while (1) { +- register int64_t ch = (char) getc(f); ++ register int64_t ch = getc(f); + + if (ch == '\r') { + ch = getc(f); +diff --git a/C/impl/bioioC.c b/C/impl/bioioC.c +index 55bb06a..bd9d802 100644 +--- a/C/impl/bioioC.c ++++ b/C/impl/bioioC.c +@@ -553,7 +553,7 @@ int64_t benLine(char **s, int64_t *n, FILE *f) { + + char *s2 = *s; + while(TRUE) { +- register int64_t ch = (char)getc(f); ++ register int64_t ch = getc(f); + + if(ch == '\r') { + ch= getc(f); ===================================== debian/patches/fix_stString_print_varargs.patch ===================================== @@ -0,0 +1,30 @@ +Description: Fix undefined behaviour in stString_print test + test_stString_print passes the integer literal 5 for an argument that + the format string consumes with the PRIi64 (int64_t) conversion. On + ABIs where varargs are passed on the stack (i386) or in a mixed + register/stack layout (hppa) this reads the wrong words and the test + fails with a garbage value (e.g. "foo 10903929910156347803952691740557 + 6524209428700210687939411819354183979772946877523748264649767777482424 + 97536.0" instead of "foo 5 7.0"). On amd64/arm64 the register-based + varargs happen to mask the bug. Cast the argument to int64_t so the + call is well-defined on every ABI. +Author: Andreas Tille <[email protected]> +Last-Update: 2026-11-09 +Assisted-By: scaleway/deepseek-v4-flash-0731 +--- + C/tests/sonLibStringTest.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/C/tests/sonLibStringTest.c b/C/tests/sonLibStringTest.c +index 64e0178..4f2a39b 100644 +--- a/C/tests/sonLibStringTest.c ++++ b/C/tests/sonLibStringTest.c +@@ -25,7 +25,7 @@ static void test_stString_copy(CuTest* testCase) { + } + + static void test_stString_print(CuTest* testCase) { +- char *cA = stString_print("Hello %s, foo %" PRIi64 " %.1f", "world", 5, 7.0); ++ char *cA = stString_print("Hello %s, foo %" PRIi64 " %.1f", "world", (int64_t) 5, 7.0); + CuAssertStrEquals(testCase, "Hello world, foo 5 7.0", cA); + free(cA); + cA = stString_print(""); ===================================== debian/patches/series ===================================== @@ -8,3 +8,5 @@ python313_compat.patch fix_quicktree_clone_child_ids.patch add_shared_library.patch use_debian_packaged_cutest.patch +fix_char_getc_eof.patch +fix_stString_print_varargs.patch View it on GitLab: https://salsa.debian.org/med-team/libsonlib/-/compare/53eaed658e4d2b33b99f4512666f7f6cb722b9a0...bf76d241905508af331fbd14066a4f59be48407e -- View it on GitLab: https://salsa.debian.org/med-team/libsonlib/-/compare/53eaed658e4d2b33b99f4512666f7f6cb722b9a0...bf76d241905508af331fbd14066a4f59be48407e You're receiving this email because of your account on salsa.debian.org. Manage all notifications: https://salsa.debian.org/-/profile/notifications | Help: https://salsa.debian.org/help
_______________________________________________ debian-med-commit mailing list [email protected] https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/debian-med-commit
