From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jim Meyering Newsgroups: gmane.emacs.devel Subject: [PATCH] x-load-color-file: avoid array bounds errors (r+w) Date: Mon, 08 Jun 2009 10:45:28 +0200 Message-ID: <87eitvdsgn.fsf@meyering.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1244450751 17823 80.91.229.12 (8 Jun 2009 08:45:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 8 Jun 2009 08:45:51 +0000 (UTC) To: Emacs development discussions Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jun 08 10:45:47 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MDaUF-0005Jb-3N for ged-emacs-devel@m.gmane.org; Mon, 08 Jun 2009 10:45:47 +0200 Original-Received: from localhost ([127.0.0.1]:55464 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MDaUE-0006ea-9f for ged-emacs-devel@m.gmane.org; Mon, 08 Jun 2009 04:45:46 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MDaU9-0006eV-KB for emacs-devel@gnu.org; Mon, 08 Jun 2009 04:45:41 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MDaU4-0006bQ-Lc for emacs-devel@gnu.org; Mon, 08 Jun 2009 04:45:41 -0400 Original-Received: from [199.232.76.173] (port=52065 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MDaU4-0006bL-HX for emacs-devel@gnu.org; Mon, 08 Jun 2009 04:45:36 -0400 Original-Received: from smtp4-g21.free.fr ([212.27.42.4]:41816) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MDaU3-0007TT-5D for emacs-devel@gnu.org; Mon, 08 Jun 2009 04:45:36 -0400 Original-Received: from smtp4-g21.free.fr (localhost [127.0.0.1]) by smtp4-g21.free.fr (Postfix) with ESMTP id 8B6E74C81A2 for ; Mon, 8 Jun 2009 10:45:30 +0200 (CEST) Original-Received: from mx.meyering.net (mx.meyering.net [82.230.74.64]) by smtp4-g21.free.fr (Postfix) with ESMTP id B0D4C4C80D3 for ; Mon, 8 Jun 2009 10:45:28 +0200 (CEST) Original-Received: by rho.meyering.net (Acme Bit-Twister, from userid 1000) id 954A35514C; Mon, 8 Jun 2009 10:45:28 +0200 (CEST) Original-Lines: 45 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:111373 Archived-At: I spotted an array bounds error in the code below. The patch below fixes it, assuming the intent is to accept arbitrary (including empty) names. Note that this is in a !HAVE_X_WINDOWS block. If no one objects, I'll commit it tomorrow. 2009-06-08 Jim Meyering x-load-color-file: avoid array bounds error x-load-color-file expects each line of input to be of the form "R G B name". But if "name" is missing, it would read name[-1], and if that value is '\n', zero it. * xfaces.c (Fx_load_color_file): Handle missing color name. >From cbb822330a91336d261e808eee84c503e4b2d659 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 8 Jun 2009 08:38:07 +0200 Subject: [PATCH] x-load-color-file: avoid array bounds error x-load-color-file expects each line of input to be of the form "R G B name". But if "name" is missing, it would read name[-1], and if that value is '\n', zero it. * xfaces.c (Fx_load_color_file): Handle missing color name. --- src/xfaces.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/xfaces.c b/src/xfaces.c index 4443768..704d7a9 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -6630,7 +6630,7 @@ where R,G,B are numbers between 0 and 255 and name is an arbitrary string. */) { char *name = buf + num; num = strlen (name) - 1; - if (name[num] == '\n') + if (num >= 0 && name[num] == '\n') name[num] = 0; cmap = Fcons (Fcons (build_string (name), #ifdef WINDOWSNT -- 1.6.3.2.322.g117de