From: Michael Stapelberg Date: Sun, 28 Nov 2010 00:22:10 +0000 (+0100) Subject: fix third argument to strncat(), use smalloc(), use strlen(".old")+1 X-Git-Tag: tree-pr1~47 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2c157283ea7b38e6d67d65ca28472c5a6e3e25af;p=i3%2Fi3 fix third argument to strncat(), use smalloc(), use strlen(".old")+1 --- diff --git a/src/tree.c b/src/tree.c index 947a8daa..75f8c7cb 100644 --- a/src/tree.c +++ b/src/tree.c @@ -29,9 +29,9 @@ bool tree_restore() { tree_append_json(globbed); size_t path_len = strlen(config.restart_state_path); - char *old_restart = malloc(path_len + 5); - strncpy(old_restart, config.restart_state_path, path_len + 5); - strncat(old_restart, ".old", path_len + 5); + char *old_restart = smalloc(path_len + strlen(".old") + 1); + strncpy(old_restart, config.restart_state_path, path_len + strlen(".old") + 1); + strncat(old_restart, ".old", strlen(".old") + 1); unlink(old_restart); rename(globbed, old_restart); free(globbed);