From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#8254: race condition in dired.c's scmp function Date: Tue, 15 Mar 2011 03:06:12 -0400 Message-ID: References: <4D7F043A.5070702@cs.ucla.edu> Reply-To: Eli Zaretskii NNTP-Posting-Host: lo.gmane.org X-Trace: dough.gmane.org 1300174639 618 80.91.229.12 (15 Mar 2011 07:37:19 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 15 Mar 2011 07:37:19 +0000 (UTC) Cc: 8254@debbugs.gnu.org To: Paul Eggert Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Mar 15 08:37:14 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PzOob-00029O-Hw for geb-bug-gnu-emacs@m.gmane.org; Tue, 15 Mar 2011 08:37:13 +0100 Original-Received: from localhost ([127.0.0.1]:33523 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PzOoa-0007Pu-8y for geb-bug-gnu-emacs@m.gmane.org; Tue, 15 Mar 2011 03:37:12 -0400 Original-Received: from [140.186.70.92] (port=47188 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PzOoQ-0007Pg-7D for bug-gnu-emacs@gnu.org; Tue, 15 Mar 2011 03:37:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PzOoO-0000da-Fn for bug-gnu-emacs@gnu.org; Tue, 15 Mar 2011 03:37:01 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:55345) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PzOoO-0000dO-EJ for bug-gnu-emacs@gnu.org; Tue, 15 Mar 2011 03:37:00 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1PzOLO-0000JX-Cl; Tue, 15 Mar 2011 03:07:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 15 Mar 2011 07:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 8254 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 8254-submit@debbugs.gnu.org id=B8254.13001727811158 (code B ref 8254); Tue, 15 Mar 2011 07:07:02 +0000 Original-Received: (at 8254) by debbugs.gnu.org; 15 Mar 2011 07:06:21 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PzOKj-0000Id-8w for submit@debbugs.gnu.org; Tue, 15 Mar 2011 03:06:21 -0400 Original-Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PzOKg-0000IP-Lf for 8254@debbugs.gnu.org; Tue, 15 Mar 2011 03:06:19 -0400 Original-Received: from eliz by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1PzOKa-0000Dq-Jl; Tue, 15 Mar 2011 03:06:12 -0400 In-reply-to: <4D7F043A.5070702@cs.ucla.edu> (message from Paul Eggert on Mon, 14 Mar 2011 23:16:26 -0700) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Tue, 15 Mar 2011 03:07:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.43 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: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:45013 Archived-At: > Date: Mon, 14 Mar 2011 23:16:26 -0700 > From: Paul Eggert > Cc: > > The following code in the Emacs trunk src/dired.c's scmp function has > undefined behavior: > > while (l > && (DOWNCASE ((unsigned char) *s1++) > == DOWNCASE ((unsigned char) *s2++))) > l--; > > Because the DOWNCASE macro assigns to the global variables case_temp1 > and case_temp2, (DOWNCASE (x) == DOWNCASE (y)) is not valid, as the > assignments can collide and lead to a race condition. > [...] > I plan to work around the problem with something like the following > patch. Whew! How about a much simpler fix: while (l && (c1 = DOWNCASE ((unsigned char) *s1++), c2 = DOWNCASE ((unsigned char) *s2++), c1 == c2)) l--; (with suitable declarations of c1 and c2)? Will that fix the undefined behavior?