unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: lux <lx@shellcodes.org>
Cc: stefankangas@gmail.com, 59817@debbugs.gnu.org
Subject: bug#59817: [PATCH] Fix etags local command injection vulnerability
Date: Tue, 06 Dec 2022 14:55:09 +0200	[thread overview]
Message-ID: <83lenk7kuq.fsf@gnu.org> (raw)
In-Reply-To: <tencent_D2CBCB866F054B72DECE28D5D0D434DCAD0A@qq.com> (message from lux on Tue, 6 Dec 2022 15:48:10 +0800)

> Date: Tue, 6 Dec 2022 15:48:10 +0800
> From: lux <lx@shellcodes.org>
> Cc: Stefan Kangas <stefankangas@gmail.com>, 59817@debbugs.gnu.org
> 
> @@ -1716,8 +1717,12 @@ process_file_name (char *file, language *lang)
>  	  char *cmd1 = concat (compr->command, " \"", real_name);
>  	  char *cmd = concat (cmd1, "\" > ", tmp_name);
>  #else
> -	  char *cmd1 = concat (compr->command, " '", real_name);
> -	  char *cmd = concat (cmd1, "' > ", tmp_name);
> +          char *new_real_name = escape_shell_arg_string (real_name);
> +          char *new_tmp_name = escape_shell_arg_string (tmp_name);
> +          char *cmd1 = concat (compr->command, " ", new_real_name);
> +          char *cmd = concat (cmd1, " > ", new_tmp_name);
> +          free (new_real_name);
> +          free (new_tmp_name);
>  #endif

The "MSDOS || DOS_NT" case also needs a small change:

>  	  char *cmd = concat (cmd1, "\" > ", tmp_name);

This doesn't quote tmp_name; it should.

> +static char*
             ^^
There should be a space before "*".

> +      if (*p == '\'')
> +        {
> +          new_str[i+1] = '\\';
> +          new_str[i+2] = '\'';
> +          new_str[i+3] = '\'';
> +          i += 3;

I don't understand why you are adding ''\'' and not just \'.  Wouldn't the
latter work for some reason?

Thanks.





  reply	other threads:[~2022-12-06 12:55 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-04 13:51 bug#59817: [PATCH] Fix etags local command injection vulnerability lux
2022-12-04 14:39 ` Eli Zaretskii
2022-12-04 16:27   ` Stefan Kangas
2022-12-04 17:04     ` Eli Zaretskii
     [not found]   ` <tencent_2F6B5EEED2E485C363837738F5661E6AB009@qq.com>
2022-12-05 12:34     ` Eli Zaretskii
2022-12-06  7:48       ` lux
2022-12-06 12:55         ` Eli Zaretskii [this message]
2022-12-06 13:11           ` lux
2022-12-06 14:52             ` Eli Zaretskii
2022-12-06 15:05               ` Francesco Potortì
2022-12-06 15:19               ` Francesco Potortì
2022-12-06 15:49               ` lux
2022-12-06 16:14                 ` Eli Zaretskii
2022-12-06 13:05         ` Andreas Schwab
2022-12-06 14:33           ` Eli Zaretskii
2022-12-05  0:58 ` lux

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83lenk7kuq.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=59817@debbugs.gnu.org \
    --cc=lx@shellcodes.org \
    --cc=stefankangas@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).