[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: new module 'string-buffer'

From: Bruno Haible
Subject: Re: new module 'string-buffer'
Date: Sat, 27 Feb 2021 18:20:28 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-201-generic; KDE/5.18.0; x86_64; ; )

This patch fixes two issues with this new module.

1) The license 'LGPLv2+' is not possible, because the dependency module
'vsnprintf' is under 'LGPL' (= 'LGPLv3+').

2) The continuous integration reported a test failure. I can reproduce it
  - on a Debian 10.7 system,
  - on an Ubuntu 16.04 system, but only when specifying CFLAGS that don't
    include optimizations. With optimizations, some fortify settings lead
    and thus to
    and so to
    The Gnulib implementation of vsnprintf() fails when an invalid format
    directive is given.
    Whereas without optimization, the glibc implementation of vsnprintf
    is POSIX compliant, hence REPLACE_VSNPRINTF=0, and since glibc vsnprintf()
    does not fail when an invalid format directive is encountered, the
    unit test failed.

2021-02-27  Bruno Haible  <bruno@clisp.org>

        string-buffer: Fixes.
        * modules/string-buffer (License): Change to LGPL.
        * tests/test-string-buffer.c (main): Add another sb_appendf call, that
        is more likely to fail.

diff --git a/modules/string-buffer b/modules/string-buffer
index 4e7827c..54da1db 100644
--- a/modules/string-buffer
+++ b/modules/string-buffer
@@ -20,7 +20,7 @@ Include:
diff --git a/tests/test-string-buffer.c b/tests/test-string-buffer.c
index 7973559..ecf5160 100644
--- a/tests/test-string-buffer.c
+++ b/tests/test-string-buffer.c
@@ -90,12 +90,19 @@ main ()
     free (s);
-  /* Test printf-like formatting failure.  */
+  /* Test printf-like formatting failure.
+     On all systems except AIX, trying to convert the wide-character 0x76543210
+     to a multibyte string (in the "C" locale) fails.
+     On all systems where REPLACE_VSNPRINTF=1 (this includes AIX), i.e. where
+     the Gnulib implementation of vsnprintf() is used), invalid format
+     directives make the *printf call fail.  */
     struct string_buffer buffer;
     sb_init (&buffer);
     sb_append (&buffer, "<");
+    sb_appendf (&buffer, "%lc", 0x76543210);
+    sb_append (&buffer, "|");
     sb_appendf (&buffer, invalid_format_string_1, 1);
     sb_append (&buffer, "|");
     sb_appendf (&buffer, invalid_format_string_2, 2);

reply via email to

[Prev in Thread] Current Thread [Next in Thread]