mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Replace sprintf with snprintf
svn:r2602
This commit is contained in:
+1
-1
@@ -142,7 +142,7 @@ static INLINE char *format_msg(char *buf, size_t buf_len,
|
||||
|
||||
/** Helper: sends a message to the appropriate logfiles, at loglevel
|
||||
* <b>severity</b>. If provided, <b>funcname</b> is prepended to the
|
||||
* message. The actual message is derived as from vsprintf(format,ap).
|
||||
* message. The actual message is derived as from vsnprintf(format,ap).
|
||||
*/
|
||||
static void
|
||||
logv(int severity, const char *funcname, const char *format, va_list ap)
|
||||
|
||||
+2
-2
@@ -294,12 +294,12 @@ tor_tls_context_new(crypto_pk_env_t *identity,
|
||||
EVP_PKEY *pkey = NULL;
|
||||
tor_tls_context *result = NULL;
|
||||
X509 *cert = NULL, *idcert = NULL;
|
||||
char nn2[1024];
|
||||
char nn2[128];
|
||||
int client_only;
|
||||
SSL_CTX **ctx;
|
||||
if (!nickname)
|
||||
nickname = "null";
|
||||
sprintf(nn2, "%s <identity>", nickname);
|
||||
snprintf(nn2, sizeof(nn2), "%s <identity>", nickname);
|
||||
|
||||
tor_tls_init();
|
||||
|
||||
|
||||
+4
-2
@@ -1763,6 +1763,7 @@ char *expand_filename(const char *filename)
|
||||
tor_assert(filename);
|
||||
/* XXXX Should eventually check for ~username/ */
|
||||
if (!strncmp(filename,"~/",2)) {
|
||||
size_t len;
|
||||
const char *home = getenv("HOME");
|
||||
char *result;
|
||||
if (!home) {
|
||||
@@ -1770,8 +1771,9 @@ char *expand_filename(const char *filename)
|
||||
return NULL;
|
||||
}
|
||||
/* minus two characters for ~/, plus one for /, plus one for NUL. */
|
||||
result = tor_malloc(strlen(home)+strlen(filename)+16);
|
||||
sprintf(result,"%s/%s",home,filename+2);
|
||||
len = strlen(home)+strlen(filename)+16;
|
||||
result = tor_malloc(len);
|
||||
snprintf(result,len,"%s/%s",home,filename+2);
|
||||
return result;
|
||||
} else {
|
||||
return tor_strdup(filename);
|
||||
|
||||
Reference in New Issue
Block a user