From 6f71dc4695754b27bcfcb5b1e8da1fc1b4b04c3b Mon Sep 17 00:00:00 2001 From: ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ Date: Mon, 19 Sep 2022 20:31:20 +0800 Subject: Reduce buffer size for unsigned char arrays They're not strings, so no need for extra byte for the terminating NUL. --- crypt.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crypt.h b/crypt.h index 57d4689..9ae3038 100644 --- a/crypt.h +++ b/crypt.h @@ -13,7 +13,7 @@ static inline bool crypt_maccmp(const char *key, const char *query, gcry_mac_setkey(hd, key, strlen(key)); gcry_mac_write(hd, query, strlen(query)); static size_t hmacsha256_len = 32; - unsigned char hmacsha256[hmacsha256_len + 1]; + unsigned char hmacsha256[hmacsha256_len]; gcry_mac_read(hd, hmacsha256, &hmacsha256_len); gcry_mac_close(hd); char hmacsha256_str[hmacsha256_len * 2 + 1]; @@ -28,7 +28,7 @@ static inline void crypt_getnonce(char buf[], const size_t buf_len) { buf[0] = '\0'; const size_t nonce_len = buf_len / 2; - unsigned char nonce[nonce_len + 1]; + unsigned char nonce[nonce_len]; gcry_create_nonce(nonce, nonce_len); for (int i = 0; i < nonce_len; i++) sprintf(buf, "%s%02x", buf, nonce[i]); -- cgit v1.3