diff --git a/src/Config.c b/src/Config.c index 221cc6a..cfe6b2b 100644 --- a/src/Config.c +++ b/src/Config.c @@ -357,14 +357,15 @@ ConfigParse(HashMap * config) } else { - tConfig->baseUrl = Malloc(strlen(tConfig->serverName) + 10); + size_t len = strlen(tConfig->serverName) + 10; + tConfig->baseUrl = Malloc(len); if (!tConfig->baseUrl) { tConfig->err = "Error allocating memory for default config value 'baseUrl'."; goto error; } - sprintf(tConfig->baseUrl, "https://%s", tConfig->serverName); + snprintf(tConfig->baseUrl, len, "https://%s", tConfig->serverName); } CONFIG_OPTIONAL_STRING(tConfig->identityServer, "identityServer", NULL); diff --git a/src/HttpClient.c b/src/HttpClient.c index 8629b6e..7874966 100644 --- a/src/HttpClient.c +++ b/src/HttpClient.c @@ -81,7 +81,7 @@ HttpRequest(HttpRequestMethod method, int flags, unsigned short port, char *host } else { - sprintf(serv, "%hu", port); + snprintf(serv, sizeof(serv), "%hu", port); } diff --git a/src/Memory.c b/src/Memory.c index 1cf4f9a..09963fd 100644 --- a/src/Memory.c +++ b/src/Memory.c @@ -451,7 +451,7 @@ void printFunc(pI - MEMORY_HEXDUMP_WIDTH, hexBuf, asciiBuf, args); - sprintf(hexBuf, "%02x ", pc[pI]); + snprintf(hexBuf, 4, "%02x ", pc[pI]); hI = 3; asciiBuf[0] = isprint(pc[pI]) ? pc[pI] : '.'; @@ -463,7 +463,7 @@ void asciiBuf[aI] = isprint(pc[pI]) ? pc[pI] : '.'; aI++; - sprintf(hexBuf + hI, "%02x ", pc[pI]); + snprintf(hexBuf + hI, 4, "%02x ", pc[pI]); hI += 3; } } diff --git a/src/Sha2.c b/src/Sha2.c index 9cea8d3..613d420 100644 --- a/src/Sha2.c +++ b/src/Sha2.c @@ -231,7 +231,7 @@ Sha256(char *str) /* Convert to string */ for (i = 0; i < 32; i++) { - sprintf(outStr + (2 * i), "%02x", out[i]); + snprintf(outStr + (2 * i), 3, "%02x", out[i]); } return outStr;