mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-14 05:13:02 +01:00
Fix a bunch of Wformat-truncation warnings due to snprintf() misuse
This commit is contained in:
parent
26b5fe8f9d
commit
4c302da503
@ -279,7 +279,7 @@ static void complete_home_dir(ToxWindow *self, char *path, int pathsize, const c
|
||||
char homedir[MAX_STR_SIZE] = {0};
|
||||
get_home_dir(homedir, sizeof(homedir));
|
||||
|
||||
char newline[MAX_STR_SIZE];
|
||||
char newline[MAX_STR_SIZE + 1];
|
||||
snprintf(newline, sizeof(newline), "%s %s%s", cmd, homedir, path + 1);
|
||||
snprintf(path, pathsize, "%s", &newline[cmdlen - 1]);
|
||||
|
||||
@ -309,12 +309,12 @@ static void complete_home_dir(ToxWindow *self, char *path, int pathsize, const c
|
||||
#define MAX_DIRS 512
|
||||
int dir_match(ToxWindow *self, Tox *m, const wchar_t *line, const wchar_t *cmd)
|
||||
{
|
||||
char b_path[MAX_STR_SIZE];
|
||||
char b_name[MAX_STR_SIZE];
|
||||
char b_path[MAX_STR_SIZE + 1];
|
||||
char b_name[MAX_STR_SIZE + 1];
|
||||
char b_cmd[MAX_STR_SIZE];
|
||||
const wchar_t *tmpline = &line[wcslen(cmd) + 1]; /* start after "/command " */
|
||||
|
||||
if (wcs_to_mbs_buf(b_path, tmpline, sizeof(b_path)) == -1) {
|
||||
if (wcs_to_mbs_buf(b_path, tmpline, sizeof(b_path) - 1) == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -323,7 +323,7 @@ int dir_match(ToxWindow *self, Tox *m, const wchar_t *line, const wchar_t *cmd)
|
||||
}
|
||||
|
||||
if (b_path[0] == '~') {
|
||||
complete_home_dir(self, b_path, sizeof(b_path), b_cmd, strlen(b_cmd) + 2);
|
||||
complete_home_dir(self, b_path, sizeof(b_path) - 1, b_cmd, strlen(b_cmd) + 2);
|
||||
}
|
||||
|
||||
int si = char_rfind(b_path, '/', strlen(b_path));
|
||||
@ -332,9 +332,8 @@ int dir_match(ToxWindow *self, Tox *m, const wchar_t *line, const wchar_t *cmd)
|
||||
b_path[0] = '.';
|
||||
b_path[1] = '\0';
|
||||
} else if (!si && b_path[0] != '/') { /* look for matches in pwd */
|
||||
char tmp[MAX_STR_SIZE];
|
||||
snprintf(tmp, sizeof(tmp), ".%s", b_path);
|
||||
snprintf(b_path, sizeof(b_path), "%s", tmp);
|
||||
memmove(b_path + 1, b_path, sizeof(b_path) - 1);
|
||||
b_path[0] = '.';
|
||||
}
|
||||
|
||||
snprintf(b_name, sizeof(b_name), "%s", &b_path[si + 1]);
|
||||
|
@ -1306,7 +1306,8 @@ static void chat_onInit(ToxWindow *self, Tox *m)
|
||||
|
||||
char nick[TOX_MAX_NAME_LENGTH + 1];
|
||||
size_t n_len = get_nick_truncate(m, nick, self->num);
|
||||
snprintf(statusbar->nick, sizeof(statusbar->nick), "%s", nick);
|
||||
memcpy(statusbar->nick, nick, n_len);
|
||||
statusbar->nick[n_len] = 0;
|
||||
statusbar->nick_len = n_len;
|
||||
|
||||
/* Init subwindows */
|
||||
|
@ -491,10 +491,11 @@ void friendlist_onFriendAdded(ToxWindow *self, Tox *m, uint32_t num, bool sort)
|
||||
|
||||
update_friend_last_online(i, t);
|
||||
|
||||
char tempname[TOX_MAX_NAME_LENGTH] = {0};
|
||||
get_nick_truncate(m, tempname, num);
|
||||
snprintf(Friends.list[i].name, sizeof(Friends.list[i].name), "%s", tempname);
|
||||
Friends.list[i].namelength = strlen(Friends.list[i].name);
|
||||
char tempname[TOX_MAX_NAME_LENGTH + 1];
|
||||
int name_len = get_nick_truncate(m, tempname, num);
|
||||
memcpy(Friends.list[i].name, tempname, name_len);
|
||||
Friends.list[i].name[name_len] = 0;
|
||||
Friends.list[i].namelength = name_len;
|
||||
|
||||
if (i == Friends.max_idx) {
|
||||
++Friends.max_idx;
|
||||
|
@ -75,7 +75,7 @@ void cmd_set_title(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*arg
|
||||
|
||||
line_info_add(self, timefrmt, selfnick, NULL, NAME_CHANGE, 0, 0, " set the group title to: %s", title);
|
||||
|
||||
char tmp_event[MAX_STR_SIZE];
|
||||
char tmp_event[MAX_STR_SIZE + 20];
|
||||
snprintf(tmp_event, sizeof(tmp_event), "set title to %s", title);
|
||||
write_to_log(tmp_event, selfnick, self->chatwin->log, true);
|
||||
}
|
||||
|
@ -269,7 +269,7 @@ void *lookup_thread_func(void *data)
|
||||
|
||||
memset(&recv_data, 0, sizeof(struct Recv_Curl_Data));
|
||||
|
||||
char post_data[MAX_STR_SIZE];
|
||||
char post_data[MAX_STR_SIZE + 30];
|
||||
|
||||
snprintf(post_data, sizeof(post_data), "{\"action\": 3, \"name\": \"%s\"}", name);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user