On 8/28/21 5:45 AM, Bruno Haible wrote:

There are two problems with this patch:

1) $ ./gnulib-tool --create-testdir --dir=../testdir5 --single-configure base32 
base64
    prints messages
    gnulib-tool: warning: module base32 depends on a module with an 
incompatible license: ialloc
    gnulib-tool: warning: module base64 depends on a module with an 
incompatible license: ialloc

    The obvious fix would be to change the license of 'ialloc' from LGPL to 
LGPLv2+.

Sure, done in first attached patch.

2) The continuous integration reported a test failure (both with GCC and clang):

    test-base64.c:131: assertion 'len == 0' failed
    FAIL test-base64 (exit status: 134)

    But, strangely, I can't reproduce it locally. (Maybe it depends on the glibc
    version?)

There is a portability issue in that code, which I fixed by installing the second attached patch. I hope it fixes the problem you observed.
>From 34298f25c3d1d56f0502fdad42df3af6764e6a5d Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Sun, 29 Aug 2021 00:27:10 -0700
Subject: [PATCH 1/2] ialloc: relicense

* modules/ialloc (License): Change from LGPL to LGPLv2+.
---
 ChangeLog      | 5 +++++
 modules/ialloc | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 599ce55ed..e46b36efb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2021-08-29  Paul Eggert  <egg...@cs.ucla.edu>
+
+	ialloc: relicense
+	* modules/ialloc (License): Change from LGPL to LGPLv2+.
+
 2021-08-28  Bruno Haible  <br...@clisp.org>
 
 	fma: Fix compilation error on Linux/sh4.
diff --git a/modules/ialloc b/modules/ialloc
index 3bf377a62..bcf431399 100644
--- a/modules/ialloc
+++ b/modules/ialloc
@@ -23,7 +23,7 @@ Include:
 "ialloc.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 all
-- 
2.30.2

>From 93280a4bdca1c6e6fa1946fbf9d8621c42bdd692 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Sun, 29 Aug 2021 00:45:43 -0700
Subject: [PATCH 2/2] base32, base64: fix broken tests
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2021-08/msg00170.html
* lib/base32.c, lib/base64.c: Do not include verify.h,
and omit all uses of ‘assume’.
* modules/base32, modules/base64 (Depends-on): Remove verify.
* tests/test-base32.c, tests/test-base64.c:
Don’t pass out-of-range values to allocator,
as converting them to idx_t relies on implementation-defined
behavior that could trap.
---
 ChangeLog           | 11 +++++++++++
 lib/base32.c        |  2 --
 lib/base64.c        |  2 --
 modules/base32      |  1 -
 modules/base64      |  1 -
 tests/test-base32.c |  2 +-
 tests/test-base64.c |  2 +-
 7 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e46b36efb..d9f291fcd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2021-08-29  Paul Eggert  <egg...@cs.ucla.edu>
 
+	base32, base64: fix broken tests
+	Problem reported by Bruno Haible in:
+	https://lists.gnu.org/r/bug-gnulib/2021-08/msg00170.html
+	* lib/base32.c, lib/base64.c: Do not include verify.h,
+	and omit all uses of ‘assume’.
+	* modules/base32, modules/base64 (Depends-on): Remove verify.
+	* tests/test-base32.c, tests/test-base64.c:
+	Don’t pass out-of-range values to allocator,
+	as converting them to idx_t relies on implementation-defined
+	behavior that could trap.
+
 	ialloc: relicense
 	* modules/ialloc (License): Change from LGPL to LGPLv2+.
 
diff --git a/lib/base32.c b/lib/base32.c
index e8feaf166..e3f2f9b4c 100644
--- a/lib/base32.c
+++ b/lib/base32.c
@@ -46,7 +46,6 @@
 #include <ialloc.h>
 
 #include <intprops.h>
-#include <verify.h>
 
 /* Get UCHAR_MAX. */
 #include <limits.h>
@@ -143,7 +142,6 @@ idx_t
 base32_encode_alloc (const char *in, idx_t inlen, char **out)
 {
   /* Check for overflow in outlen computation.  */
-  assume (0 <= inlen);
   idx_t in_over_5 = inlen / 5 + (inlen % 5 != 0), outlen;
   if (! INT_MULTIPLY_OK (in_over_5, 8, &outlen))
     {
diff --git a/lib/base64.c b/lib/base64.c
index 2a01ed34e..4611fe548 100644
--- a/lib/base64.c
+++ b/lib/base64.c
@@ -48,7 +48,6 @@
 #include <ialloc.h>
 
 #include <intprops.h>
-#include <verify.h>
 
 /* Get UCHAR_MAX. */
 #include <limits.h>
@@ -148,7 +147,6 @@ idx_t
 base64_encode_alloc (const char *in, idx_t inlen, char **out)
 {
   /* Check for overflow in outlen computation.  */
-  assume (0 <= inlen);
   idx_t in_over_3 = inlen / 3 + (inlen % 3 != 0), outlen;
   if (! INT_MULTIPLY_OK (in_over_3, 4, &outlen))
     {
diff --git a/modules/base32 b/modules/base32
index 659081d7e..93c180b09 100644
--- a/modules/base32
+++ b/modules/base32
@@ -10,7 +10,6 @@ Depends-on:
 ialloc
 stdbool
 memchr
-verify
 
 configure.ac:
 gl_FUNC_BASE32
diff --git a/modules/base64 b/modules/base64
index 717c0697d..278e52fc8 100644
--- a/modules/base64
+++ b/modules/base64
@@ -10,7 +10,6 @@ Depends-on:
 ialloc
 stdbool
 memchr
-verify
 
 configure.ac:
 gl_FUNC_BASE64
diff --git a/tests/test-base32.c b/tests/test-base32.c
index 24c46567d..25df559fd 100644
--- a/tests/test-base32.c
+++ b/tests/test-base32.c
@@ -150,7 +150,7 @@ main (void)
   ASSERT (strcmp (p, "MFRGGZDFMZTWQ2LKNNWG23TPOA======") == 0);
   free (p);
 
-  len = base32_encode_alloc (in, SIZE_MAX - 5, &p);
+  len = base32_encode_alloc (in, IDX_MAX - 5, &p);
   ASSERT (len == 0);
 
   /* Decode context function */
diff --git a/tests/test-base64.c b/tests/test-base64.c
index bc75acd95..a7f4e5370 100644
--- a/tests/test-base64.c
+++ b/tests/test-base64.c
@@ -127,7 +127,7 @@ main (void)
   ASSERT (strcmp (p, "YWJjZGVmZ2hpamtsbW5vcA==") == 0);
   free (p);
 
-  len = base64_encode_alloc (in, SIZE_MAX - 5, &p);
+  len = base64_encode_alloc (in, IDX_MAX - 5, &p);
   ASSERT (len == 0);
 
   /* Decode context function */
-- 
2.30.2

Reply via email to