mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-23 01:43:01 +01:00
Fix potential string truncations with snprintf
This commit is contained in:
parent
52dd60dc86
commit
f2c116feb3
@ -287,7 +287,7 @@ int dir_match(ToxWindow *self, Tox *m, const wchar_t *line, const wchar_t *cmd)
|
|||||||
if (dp == NULL)
|
if (dp == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
char dirnames[MAX_DIRS][NAME_MAX];
|
char dirnames[MAX_DIRS][NAME_MAX + 1];
|
||||||
struct dirent *entry;
|
struct dirent *entry;
|
||||||
int dircount = 0;
|
int dircount = 0;
|
||||||
|
|
||||||
|
@ -561,7 +561,7 @@ static void chat_onFileRecv(ToxWindow *self, Tox *m, uint32_t friendnum, uint32_
|
|||||||
bytes_convert_str(sizestr, sizeof(sizestr), file_size);
|
bytes_convert_str(sizestr, sizeof(sizestr), file_size);
|
||||||
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "File transfer request for '%s' (%s)", filename, sizestr);
|
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "File transfer request for '%s' (%s)", filename, sizestr);
|
||||||
|
|
||||||
char file_path[MAX_STR_SIZE];
|
char file_path[PATH_MAX + name_length + 1];
|
||||||
size_t path_len = name_length;
|
size_t path_len = name_length;
|
||||||
|
|
||||||
/* use specified download path in config if possible */
|
/* use specified download path in config if possible */
|
||||||
|
@ -578,7 +578,7 @@ static void init_tox_options(struct Tox_Options *tox_opts)
|
|||||||
tox_opts->proxy_host = arg_opts.proxy_address;
|
tox_opts->proxy_host = arg_opts.proxy_address;
|
||||||
const char *ps = tox_opts->proxy_type == TOX_PROXY_TYPE_SOCKS5 ? "SOCKS5" : "HTTP";
|
const char *ps = tox_opts->proxy_type == TOX_PROXY_TYPE_SOCKS5 ? "SOCKS5" : "HTTP";
|
||||||
|
|
||||||
char tmp[48];
|
char tmp[sizeof(arg_opts.proxy_address) + MAX_STR_SIZE];
|
||||||
snprintf(tmp, sizeof(tmp), "Using %s proxy %s : %d", ps, arg_opts.proxy_address, arg_opts.proxy_port);
|
snprintf(tmp, sizeof(tmp), "Using %s proxy %s : %d", ps, arg_opts.proxy_address, arg_opts.proxy_port);
|
||||||
queue_init_message("%s", tmp);
|
queue_init_message("%s", tmp);
|
||||||
}
|
}
|
||||||
@ -1256,7 +1256,7 @@ int main(int argc, char **argv)
|
|||||||
cleanup_init_messages();
|
cleanup_init_messages();
|
||||||
|
|
||||||
/* set user avatar from config file. if no path is supplied tox_unset_avatar is called */
|
/* set user avatar from config file. if no path is supplied tox_unset_avatar is called */
|
||||||
char avatarstr[MAX_STR_SIZE];
|
char avatarstr[PATH_MAX + 11];
|
||||||
snprintf(avatarstr, sizeof(avatarstr), "/avatar \"%s\"", user_settings->avatar_path);
|
snprintf(avatarstr, sizeof(avatarstr), "/avatar \"%s\"", user_settings->avatar_path);
|
||||||
execute(prompt->chatwin->history, prompt, m, avatarstr, GLOBAL_COMMAND_MODE);
|
execute(prompt->chatwin->history, prompt, m, avatarstr, GLOBAL_COMMAND_MODE);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user