From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8401 invoked by alias); 24 Oct 2005 18:00:47 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 7982 invoked by uid 22791); 24 Oct 2005 18:00:45 -0000 Received: from fra-del-01.spheriq.net (HELO fra-del-01.spheriq.net) (195.46.51.97) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Mon, 24 Oct 2005 18:00:45 +0000 Received: from fra-out-03.spheriq.net (fra-out-03.spheriq.net [195.46.51.131]) by fra-del-01.spheriq.net with ESMTP id j9OI0gAP020116 for ; Mon, 24 Oct 2005 18:00:42 GMT Received: from fra-cus-01.spheriq.net (fra-cus-01.spheriq.net [195.46.51.37]) by fra-out-03.spheriq.net with ESMTP id j9OI0c6R028904 for ; Mon, 24 Oct 2005 18:00:39 GMT Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by fra-cus-01.spheriq.net with ESMTP id j9OI0bhE028623 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=OK); Mon, 24 Oct 2005 18:00:38 GMT Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 0BA59DA41; Mon, 24 Oct 2005 18:00:37 +0000 (GMT) Received: by zeta.dmz-eu.st.com (STMicroelectronics, from userid 60012) id 5D06A47D22; Mon, 24 Oct 2005 18:03:25 +0000 (GMT) Received: from zeta.dmz-eu.st.com (localhost [127.0.0.1]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 1EB0375999; Mon, 24 Oct 2005 18:03:25 +0000 (UTC) Received: from mail1.bri.st.com (mail1.bri.st.com [164.129.8.218]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id A1AE247D21; Mon, 24 Oct 2005 18:03:24 +0000 (GMT) Received: from [164.129.15.13] (terrorhawk.bri.st.com [164.129.15.13]) by mail1.bri.st.com (MOS 3.5.8-GR) with ESMTP id CDW01757 (AUTH "andrew stubbs"); Mon, 24 Oct 2005 19:00:35 +0100 (BST) Message-ID: <435D20E0.6040504@st.com> Date: Mon, 24 Oct 2005 20:22:00 -0000 From: Andrew STUBBS User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) MIME-Version: 1.0 To: Jim Blandy Cc: gdb-patches@sources.redhat.com Subject: Re: PATCH: Fix TUI null pointer dereference References: <4353B4A5.3010209@st.com> <435CE1E7.4040803@st.com> In-Reply-To: Content-Type: multipart/mixed; boundary="------------040905070700090901020500" X-O-Spoofed: Not Scanned X-O-General-Status: No X-O-Spam1-Status: Not Scanned X-O-Spam2-Status: Not Scanned X-O-URL-Status: Not Scanned X-O-Virus1-Status: No X-O-Virus2-Status: Not Scanned X-O-Virus3-Status: No X-O-Virus4-Status: No X-O-Virus5-Status: Not Scanned X-O-Image-Status: Not Scanned X-O-Attach-Status: Not Scanned X-SpheriQ-Ver: 4.1.07 X-SW-Source: 2005-10/txt/msg00192.txt.bz2 This is a multi-part message in MIME format. --------------040905070700090901020500 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 392 Jim Blandy wrote: > We generally avoid using assignments directly as conditions. Just > hoist the assignment out and just say 'if (term)'. With that change, > feel free to commit. OK. Here is an updated patch. I do not have write permission/ability. If I could get that set up that would be great, but till then somebody else wil have to submit it for me please. Thanks Andrew Stubbs --------------040905070700090901020500 Content-Type: text/plain; name="tui-NULL-pointer.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="tui-NULL-pointer.patch" Content-length: 1762 2005-10-24 Andrew Stubbs * tui/tui-command.c (tui_dispatch_ctrl_char): Test output of getenv() before using it. Index: src/gdb/tui/tui-command.c =================================================================== --- src.orig/gdb/tui/tui-command.c 2005-10-24 13:58:38.000000000 +0100 +++ src/gdb/tui/tui-command.c 2005-10-24 18:56:04.000000000 +0100 @@ -68,33 +68,36 @@ tui_dispatch_ctrl_char (unsigned int ch) ** Seems like a bug in the curses library? */ term = (char *) getenv ("TERM"); - for (i = 0; (term && term[i]); i++) - term[i] = toupper (term[i]); - if ((strcmp (term, "XTERM") == 0) && key_is_start_sequence (ch)) + if (term) { - unsigned int page_ch = 0; - unsigned int tmp_char; - - tmp_char = 0; - while (!key_is_end_sequence (tmp_char)) + for (i = 0; term[i]; i++) + term[i] = toupper (term[i]); + if ((strcmp (term, "XTERM") == 0) && key_is_start_sequence (ch)) { - tmp_char = (int) wgetch (w); - if (tmp_char == ERR) - { - return ch; - } - if (!tmp_char) - break; - if (tmp_char == 53) - page_ch = KEY_PPAGE; - else if (tmp_char == 54) - page_ch = KEY_NPAGE; - else + unsigned int page_ch = 0; + unsigned int tmp_char; + + tmp_char = 0; + while (!key_is_end_sequence (tmp_char)) { - return 0; + tmp_char = (int) wgetch (w); + if (tmp_char == ERR) + { + return ch; + } + if (!tmp_char) + break; + if (tmp_char == 53) + page_ch = KEY_PPAGE; + else if (tmp_char == 54) + page_ch = KEY_NPAGE; + else + { + return 0; + } } + ch_copy = page_ch; } - ch_copy = page_ch; } switch (ch_copy) --------------040905070700090901020500--