minor snprintf fixes

This commit is contained in:
Devaev Maxim
2021-01-13 01:26:11 +03:00
parent 4a156a692a
commit 5576cbb3b8
2 changed files with 4 additions and 4 deletions

View File

@@ -145,7 +145,7 @@ int server_listen(server_s *server) {
char *raw_token; char *raw_token;
char *encoded_token = NULL; char *encoded_token = NULL;
A_CALLOC(raw_token, strlen(server->user) + strlen(server->passwd) + 2); A_CALLOC(raw_token, strlen(server->user) + strlen(server->passwd) + 16);
sprintf(raw_token, "%s:%s", server->user, server->passwd); sprintf(raw_token, "%s:%s", server->user, server->passwd);
base64_encode((uint8_t *)raw_token, strlen(raw_token), &encoded_token, NULL); base64_encode((uint8_t *)raw_token, strlen(raw_token), &encoded_token, NULL);
free(raw_token); free(raw_token);
@@ -404,12 +404,12 @@ static void _http_callback_snapshot(struct evhttp_request *request, void *v_serv
char header_buf[256]; char header_buf[256];
# define ADD_TIME_HEADER(_key, _value) { \ # define ADD_TIME_HEADER(_key, _value) { \
sprintf(header_buf, "%.06Lf", _value); \ snprintf(header_buf, 255, "%.06Lf", _value); \
ADD_HEADER(_key, header_buf); \ ADD_HEADER(_key, header_buf); \
} }
# define ADD_UNSIGNED_HEADER(_key, _value) { \ # define ADD_UNSIGNED_HEADER(_key, _value) { \
sprintf(header_buf, "%u", _value); \ snprintf(header_buf, 255, "%u", _value); \
ADD_HEADER(_key, header_buf); \ ADD_HEADER(_key, header_buf); \
} }

View File

@@ -32,7 +32,7 @@ char *find_static_file_path(const char *root_path, const char *request_path) {
goto error; goto error;
} }
A_CALLOC(path, strlen(root_path) + strlen(simplified_path) + 32); A_CALLOC(path, strlen(root_path) + strlen(simplified_path) + 16);
sprintf(path, "%s/%s", root_path, simplified_path); sprintf(path, "%s/%s", root_path, simplified_path);
struct stat st; struct stat st;