]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
iconv: fixed coverity issue CID1609382
authorXavi Hernandez <xhernandez@gmail.com>
Tue, 29 Jul 2025 08:31:45 +0000 (10:31 +0200)
committerDouglas Bagnall <dbagnall@samba.org>
Wed, 30 Jul 2025 00:44:28 +0000 (00:44 +0000)
The issue is not a real bug as it is implemented, but it's better to not
mix signed and unsigned types to avoid potential future issues.

Signed-off-by: Xavi Hernandez <xhernandez@gmail.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org>
Autobuild-Date(master): Wed Jul 30 00:44:28 UTC 2025 on atb-devel-224

lib/util/charset/tests/iconv.c

index 2139795d0a871108d0827a27a74354d6f43d23e0..3851aaf4f76b71782217fe7e4eb16c5119f85362 100644 (file)
@@ -349,14 +349,18 @@ static bool test_buffer(struct torture_context *test,
 static bool test_codepoint(struct torture_context *tctx, unsigned int codepoint)
 {
        uint8_t buf[10];
-       size_t size, size2;
+       ssize_t size;
+       size_t size2;
        codepoint_t c;
 
        size = push_codepoint_handle(lpcfg_iconv_handle(tctx->lp_ctx), (char *)buf, codepoint);
-       torture_assert(tctx, size != -1 || (codepoint >= 0xd800 && codepoint <= 0x10000), 
+       torture_assert(tctx,
+                      size >= 0 ||
+                              (codepoint >= 0xd800 && codepoint <= 0x10000),
                       "Invalid Codepoint range");
 
-       if (size == -1) return true;
+       if (size < 0)
+               return true;
 
        buf[size] = random();
        buf[size+1] = random();