Subject: bug#59544: [PATCH] Fixed lib-src/etags.c command execute vulnerability

From: "lux" <[email-masked]>
Date: Fri, 25 Nov 2022 16:38:02 +0800

------------------&nbsp;Original&nbsp;------------------
From:                                                                                                                        "Stefan Kangas"                                                                                    <[email-masked]&gt;;
Date:&nbsp;Fri, Nov 25, 2022 03:53 PM
To:&nbsp;"lux"<[email-masked]&gt;;
Cc:&nbsp;"Eli Zaretskii"<[email-masked]&gt;;"59544"<[email-masked]&gt;;
Subject:&nbsp;Re: bug#59544: [PATCH] Fixed lib-src/etags.c command execute vulnerability

"lux" <[email-masked]&gt; writes:

&gt; I rewrote this code, not use system(1).

Thanks.

&gt; From d6bc71f8640efe7caa2657a75c5aa4d8b4f0532c Mon Sep 17 00:00:00 2001
&gt; From: lu4nx <[email-masked]&gt;
&gt; Date: Fri, 25 Nov 2022 14:38:29 +0800
&gt; Subject: [PATCH] * Fixed lib-src/etags.c command execute vulnerability
&gt;
&gt; ---
&gt;&nbsp; lib-src/etags.c | 44 +++++++++++++++++++++++++++++++-------------
&gt;&nbsp; 1 file changed, 31 insertions(+), 13 deletions(-)
&gt;
&gt; diff --git a/lib-src/etags.c b/lib-src/etags.c
&gt; index f665f35fa6..1bb352f565 100644
&gt; --- a/lib-src/etags.c
&gt; +++ b/lib-src/etags.c
&gt; @@ -1387,9 +1387,11 @@ main (int argc, char **argv)
&gt;&nbsp;&nbsp;&nbsp; /* From here on, we are in (CTAGS &amp;&amp; !cxref_style) */
&gt;&nbsp;&nbsp;&nbsp; if (update)
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {
&gt; -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char *cmd =
&gt; -	xmalloc (strlen (tagfile) + whatlen_max +
&gt; -		 sizeof "mv..OTAGS;grep -Fv '\t\t' OTAGS &gt;;rm OTAGS");
&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FILE *otags_f, *tag_f;
&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int buf_len;
&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char *buf;
&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char line[512];

&gt; Hmm, I'm not sure about the hard-coded 512 character line limit here.
&gt; ISTR that some people use much longer lines than that.

Hi, do you have any suggestions? At present, I think hardcoding 512 is enough, thanks :-)