From 1a24dc8fef64a0be8b4cac28e99876a91153ed1c Mon Sep 17 00:00:00 2001 From: "Blachut, Bartosz" Date: Tue, 30 Aug 2022 18:54:44 +0200 Subject: [PATCH] hexlify util: v2c helper function return type is signed char `v2c` helper function returns -1 on error, hovewer its return type was char - which may cause an overflow situation on architectures where char is interpreted as unsigned char, which was reported by the CI. The return type has been changed to signed char. Signed-off-by: Blachut, Bartosz Change-Id: I84f5784b2de7d681f78c69b5f3646e851e8dee88 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14273 Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot Reviewed-by: Shuhei Matsumoto Reviewed-by: Aleksey Marchuk Reviewed-by: Jacek Kalwas --- module/bdev/crypto/vbdev_crypto.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/module/bdev/crypto/vbdev_crypto.h b/module/bdev/crypto/vbdev_crypto.h index d8338a1e9..b1418853b 100644 --- a/module/bdev/crypto/vbdev_crypto.h +++ b/module/bdev/crypto/vbdev_crypto.h @@ -93,7 +93,7 @@ __c2v(char c) return -1; } -static inline char +static inline signed char __v2c(int c) { const char hexchar[] = "0123456789abcdef"; @@ -121,8 +121,8 @@ hexlify(const char *bin, size_t len) } phex = hex; for (size_t i = 0; i < len; i++) { - char c0 = __v2c((bin[i] >> 4) & 0x0f); - char c1 = __v2c((bin[i]) & 0x0f); + signed char c0 = __v2c((bin[i] >> 4) & 0x0f); + signed char c1 = __v2c((bin[i]) & 0x0f); if (c0 < 0 || c1 < 0) { assert(false); free(hex);