forked from Telodendria/Telodendria
Use snprintf() instead of sprintf().
All linker warnings should now be eliminated.
This commit is contained in:
parent
d83db35df0
commit
e1367d5bff
4 changed files with 7 additions and 6 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue