Skip to content

Commit

Permalink
Fix for using sprintf.
Browse files Browse the repository at this point in the history
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]);
                 ^
```
  • Loading branch information
dgarske committed Jul 26, 2024
1 parent 42930b2 commit 010905d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions wolfssl/test.h
Original file line number Diff line number Diff line change
Expand Up @@ -1099,10 +1099,11 @@ static WC_INLINE void ShowX509Ex(WOLFSSL_X509* x509, const char* hdr,
char serialMsg[80];

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

Expand Down

0 comments on commit 010905d

Please sign in to comment.