1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-12-07 03:26:35 +01:00

enforce const correctess, fix undefined behaviour with string literals

This commit is contained in:
Jfreegman
2014-07-29 14:54:34 -04:00
parent cbe47b3660
commit 973f6206ee
9 changed files with 68 additions and 59 deletions

View File

@@ -166,15 +166,15 @@ void cmd_sendfile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv
return;
}
char *path = argv[1];
if (path[0] != '\"') {
if (argv[1][0] != '\"') {
errmsg = "File path must be enclosed in quotes.";
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, errmsg);
return;
}
++path;
/* remove opening and closing quotes */
char path[MAX_STR_SIZE];
snprintf(path, sizeof(path), "%s", &argv[1][1]);
int path_len = strlen(path) - 1;
path[path_len] = '\0';