I noticed Gnulib changed most of the *_WRAPV to the ckd_* variants at
some point. Is there a reason that INT_MULTIPLY_OK is still used in
base32 and base64 or can I apply the following patch?
It looks like the module description were missing 'intprops' in the
depends on these modules too. I guess everyone that used it had it in
their module list or as a transitive dependency.
Collin
From 9710c203220c73d9f3e1b604604157f76b1a821e Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Tue, 7 May 2024 21:47:17 -0700
Subject: [PATCH] base32, base64: Prefer stdckdint to intprops.
* lib/base32.c (base32_encode_alloc): Include stdckdint.h. Prefer
ckd_mul to INT_MULTIPLY_OK.
* lib/base64.c (base64_encode_alloc): Likewise.
* modules/base32 (Depends-on): Add stdckdint.
* modules/base64 (Depends-on): Likewise.
---
ChangeLog | 9 +++++++++
lib/base32.c | 4 ++--
lib/base64.c | 4 ++--
modules/base32 | 1 +
modules/base64 | 1 +
5 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b752fde065..41a8ef7eb6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-05-07 Collin Funk <collin.fu...@gmail.com>
+
+ base32, base64: Prefer stdckdint to intprops.
+ * lib/base32.c (base32_encode_alloc): Include stdckdint.h. Prefer
+ ckd_mul to INT_MULTIPLY_OK.
+ * lib/base64.c (base64_encode_alloc): Likewise.
+ * modules/base32 (Depends-on): Add stdckdint.
+ * modules/base64 (Depends-on): Likewise.
+
2024-05-07 Collin Funk <collin.fu...@gmail.com>
gnulib-tool.py: Handle module dependencies that cannot be found.
diff --git a/lib/base32.c b/lib/base32.c
index 270c505e20..266b32e14c 100644
--- a/lib/base32.c
+++ b/lib/base32.c
@@ -46,7 +46,7 @@
/* Get imalloc. */
#include <ialloc.h>
-#include <intprops.h>
+#include <stdckdint.h>
#include <string.h>
@@ -143,7 +143,7 @@ base32_encode_alloc (const char *in, idx_t inlen, char **out)
Treat negative INLEN as overflow, for better compatibility with
pre-2021-08-27 API, which used size_t. */
idx_t in_over_5 = inlen / 5 + (inlen % 5 != 0), outlen;
- if (! INT_MULTIPLY_OK (in_over_5, 8, &outlen) || inlen < 0)
+ if (ckd_mul (&outlen, in_over_5, 8) || inlen < 0)
{
*out = NULL;
return 0;
diff --git a/lib/base64.c b/lib/base64.c
index c8b3b76b0b..26c08e583b 100644
--- a/lib/base64.c
+++ b/lib/base64.c
@@ -48,7 +48,7 @@
/* Get imalloc. */
#include <ialloc.h>
-#include <intprops.h>
+#include <stdckdint.h>
#include <string.h>
@@ -148,7 +148,7 @@ base64_encode_alloc (const char *in, idx_t inlen, char **out)
Treat negative INLEN as overflow, for better compatibility with
pre-2021-08-27 API, which used size_t. */
idx_t in_over_3 = inlen / 3 + (inlen % 3 != 0), outlen;
- if (! INT_MULTIPLY_OK (in_over_3, 4, &outlen) || inlen < 0)
+ if (ckd_mul (&outlen, in_over_3, 4) || inlen < 0)
{
*out = NULL;
return 0;
diff --git a/modules/base32 b/modules/base32
index 85cbeeb8a8..534e2ac5ef 100644
--- a/modules/base32
+++ b/modules/base32
@@ -11,6 +11,7 @@ extern-inline
ialloc
stdbool
memchr
+stdckdint
configure.ac:
gl_FUNC_BASE32
diff --git a/modules/base64 b/modules/base64
index 8956c44af8..99f3eb8700 100644
--- a/modules/base64
+++ b/modules/base64
@@ -11,6 +11,7 @@ extern-inline
ialloc
stdbool
memchr
+stdckdint
configure.ac:
gl_FUNC_BASE64
--
2.45.0