Skip to content

Commit

Permalink
Shell-quote filenames when invoking LESSCLOSE.
Browse files Browse the repository at this point in the history
  • Loading branch information
gwsw committed Jun 25, 2022
1 parent 29c2596 commit c6ac6de
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions filename.c
Expand Up @@ -972,6 +972,8 @@ close_altfile(altfilename, filename)
{
#if HAVE_POPEN
char *lessclose;
char *qfilename;
char *qaltfilename;
FILE *fd;
char *cmd;
int len;
Expand All @@ -986,9 +988,13 @@ close_altfile(altfilename, filename)
error("LESSCLOSE ignored; must contain no more than 2 %%s", NULL_PARG);
return;
}
len = (int) (strlen(lessclose) + strlen(filename) + strlen(altfilename) + 2);
qfilename = shell_quote(filename);
qaltfilename = shell_quote(altfilename);
len = (int) (strlen(lessclose) + strlen(qfilename) + strlen(qaltfilename) + 2);
cmd = (char *) ecalloc(len, sizeof(char));
SNPRINTF2(cmd, len, lessclose, filename, altfilename);
SNPRINTF2(cmd, len, lessclose, qfilename, qaltfilename);
free(qaltfilename);
free(qfilename);
fd = shellcmd(cmd);
free(cmd);
if (fd != NULL)
Expand Down

0 comments on commit c6ac6de

Please sign in to comment.