From 30bfcd167a3cf46687368f9b0b8de90b0d451772 Mon Sep 17 00:00:00 2001 From: John Zaitseff Date: Mon, 1 Aug 2022 22:27:56 +1000 Subject: [PATCH] Keep Coverity Scan happy Coverity Scan (https://scan.coverity.com/projects/trader) complains that a high-impact defect is present in the scramble() function: "String not null terminated" -- even though b64encode() does give a NUL-termininated buffer. --- src/utils.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils.c b/src/utils.c index cb5b72c..9bb9c54 100644 --- a/src/utils.c +++ b/src/utils.c @@ -929,6 +929,7 @@ char *scramble (char *restrict dest, const char *restrict src, // Place checksum in front of Base64 string snprintf(chksumbuf, SCRAMBLE_CHKSUM_LEN + 1, "%03x", chksum); memcpy(dest, chksumbuf, SCRAMBLE_CHKSUM_LEN); + dest[size - 1] = '\0'; // Keep Coverity Scan happy... free(xorbuf); }