fix unbounded write of sprintf

Buffer write operations that do not control the length of data written
may overflow. Fix by replacing sprintf() with snprintf().
This commit is contained in:
Mingjie Shen authored and Cameron Gutman committed 2024-03-25 00:11:49 -05:00
1 parent 014af67397
commit 274d3db34d
2 files changed
+5 -5

No files matched your search

+2 -2
View File
@@ -51,10 +51,10 @@ int http_init(const char* keyDirectory, int logLevel) {
return GS_FAILED;
char certificateFilePath[4096];
sprintf(certificateFilePath, "%s/%s", keyDirectory, CERTIFICATE_FILE_NAME);
snprintf(certificateFilePath, sizeof(certificateFilePath), "%s/%s", keyDirectory, CERTIFICATE_FILE_NAME);
char keyFilePath[4096];
sprintf(&keyFilePath[0], "%s/%s", keyDirectory, KEY_FILE_NAME);
snprintf(keyFilePath, sizeof(keyFilePath), "%s/%s", keyDirectory, KEY_FILE_NAME);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
curl_easy_setopt(curl, CURLOPT_SSLENGINE_DEFAULT, 1L);