Skip to content

Commit

Permalink
Merge pull request #1953 from N-R-K/fix-fortify-abortion
Browse files Browse the repository at this point in the history
fix crash under _FORTIFY_SOURCE
  • Loading branch information
jarun authored Nov 12, 2024
2 parents d17df60 + 43c69ab commit 9db87a7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/nnn.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 9db87a7

Please sign in to comment.