Skip to content

Commit 6d39a78

Browse files
committed
Fix for using sprintf.
Resolves warning: ``` ./configure CC="gcc -fsanitize=address" && make In file included from ./wolfclu/clu_header_main.h:71: /usr/local/include/wolfssl/test.h:1103:18: error: 'sprintf' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Werror,-Wdeprecated-declarations] strLen = sprintf(serialMsg, " %s", words[3]); ^ ```
1 parent 3fc7be8 commit 6d39a78

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

wolfssl/test.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,10 +1099,11 @@ static WC_INLINE void ShowX509Ex(WOLFSSL_X509* x509, const char* hdr,
10991099
char serialMsg[80];
11001100

11011101
/* testsuite has multiple threads writing to stdout, get output
1102-
message ready to write once */
1103-
strLen = sprintf(serialMsg, " %s", words[3]);
1102+
* message ready to write once */
1103+
strLen = XSNPRINTF(serialMsg, sizeof(serialMsg), " %s", words[3]);
11041104
for (i = 0; i < sz; i++)
1105-
sprintf(serialMsg + strLen + (i*3), ":%02x ", serial[i]);
1105+
strLen = XSNPRINTF(serialMsg + strLen, sizeof(serialMsg) - strLen,
1106+
":%02x ", serial[i]);
11061107
printf("%s\n", serialMsg);
11071108
}
11081109

0 commit comments

Comments
 (0)