From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#59544: [PATCH] Fixed lib-src/etags.c command execute vulnerability Date: Fri, 25 Nov 2022 14:18:19 +0200 Message-ID: <83fse7ut10.fsf@gnu.org> References: <837czkw7sl.fsf@gnu.org> <8335a8w643.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40701"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 59544@debbugs.gnu.org, stefankangas@gmail.com To: "lux" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Nov 25 13:19:21 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oyXfr-000AGe-TO for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 25 Nov 2022 13:19:20 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oyXfb-0000Q4-Nz; Fri, 25 Nov 2022 07:19:03 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oyXfa-0000PG-Dr for bug-gnu-emacs@gnu.org; Fri, 25 Nov 2022 07:19:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oyXfa-0003Rv-56 for bug-gnu-emacs@gnu.org; Fri, 25 Nov 2022 07:19:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oyXfa-0001Ry-0v for bug-gnu-emacs@gnu.org; Fri, 25 Nov 2022 07:19:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 25 Nov 2022 12:19:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59544 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: security patch Original-Received: via spool by 59544-submit@debbugs.gnu.org id=B59544.16693786865471 (code B ref 59544); Fri, 25 Nov 2022 12:19:01 +0000 Original-Received: (at 59544) by debbugs.gnu.org; 25 Nov 2022 12:18:06 +0000 Original-Received: from localhost ([127.0.0.1]:33783 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oyXeg-0001QA-B2 for submit@debbugs.gnu.org; Fri, 25 Nov 2022 07:18:06 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:60426) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oyXee-0001Ph-Op for 59544@debbugs.gnu.org; Fri, 25 Nov 2022 07:18:05 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oyXeY-0003MK-0p; Fri, 25 Nov 2022 07:17:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=ZYVz2yxyvQT0q6w6Gn/uj5/xzGRFel1k8BSqdD62hGA=; b=S+4rPDSpQoP3 BYHoyqKRSUnI0c4E4MYdXGE5Lc5P7fvLTZFUXfTdqwWBmRlAPaktm9YM7OFFB2RQcLC0wOgK6tpkh vRKOTX/tjuq9j/U147zTRSF6ygeYRfatz8dbYJ3Jm8OikKFp04fvR60PZb8iKfLOaWlv+/SkBmnQr q3VomY98BiD65SMKq9LojA1S/+rDtMWkDmeWRcfAkHjqeYZAS6D/qu3riRJduNZ3kUaHGAA4mebp5 2Nhvl9rp2gQl6MQUf8ggAxIAKhUm3lDIsK/zFyWbroP/VSo3Nn3Ms/yzsCxUBnesKwdGCXcBhcDCQ k5loVd7IaD/M1yckRbPSnA==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oyXeX-0006z6-H6; Fri, 25 Nov 2022 07:17:57 -0500 In-Reply-To: (lx@shellcodes.org) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:248993 Archived-At: > From: "lux" > Cc: "59544" <59544@debbugs.gnu.org> > Date: Fri, 25 Nov 2022 14:41:56 +0800 > > > That's a possibility, yes. Although I doubt that people are still using > > ctags that comes with Emacs (this code fragment runs only in ctags, not in > > etags). > > I rewrote this code, not use system(1). Thanks. I have a few comments: > + > + otags_f = fopen ("OTAGS", "w"); > + tag_f = fopen (tagfile, "r"); Please use "rb" and "wb" in these fopen calls, so as not to change the EOL format of the original file. > + rename ("OTAGS", tagfile); > + unlink ("OTAGS"); We should not delete the original file if 'rename' fails; instead, we should emit a warning and leave OTAGS alone, so that user could manually rename it. Can you add a test of this feature to test/manual/etags/Makefile?