summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArun <engineerarun@gmail.com>2024-11-12 10:17:12 +0530
committerGitHub <noreply@github.com>2024-11-12 10:17:12 +0530
commit9db87a782c92cfb1e43ad93224371352eee43f71 (patch)
treee67bef61b71460c4117cbbc5bb7d3d9257705dbf
parentd17df60c4ae79c104bbacfc771646a762cacd45e (diff)
parent43c69abbacf2617163c50516871d570ecdeffd84 (diff)
Merge pull request #1953 from N-R-K/fix-fortify-abortion
fix crash under _FORTIFY_SOURCE
-rw-r--r--src/nnn.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/nnn.c b/src/nnn.c
index 5973c9d9..d66dde7f 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -2834,15 +2834,16 @@ static char *get_archive_cmd(const char *archive)
static void archive_selection(const char *cmd, const char *archive)
{
- char *buf = malloc((xstrlen(patterns[P_ARCHIVE_CMD]) + xstrlen(cmd) + xstrlen(archive)
- + xstrlen(selpath)) * sizeof(char));
+ size_t len = xstrlen(patterns[P_ARCHIVE_CMD]) + xstrlen(cmd) + xstrlen(archive)
+ + xstrlen(selpath) + 1;
+ char *buf = malloc(len);
if (!buf) {
DPRINTF_S(strerror(errno));
printwarn(NULL);
return;
}
- snprintf(buf, CMD_LEN_MAX, patterns[P_ARCHIVE_CMD], cmd, archive, selpath);
+ snprintf(buf, len, patterns[P_ARCHIVE_CMD], cmd, archive, selpath);
spawn(utils[UTIL_SH_EXEC], buf, NULL, NULL, F_CLI | F_CONFIRM);
free(buf);
}