From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29063 invoked by alias); 24 Oct 2005 13:32:53 -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 29041 invoked by uid 22791); 24 Oct 2005 13:32:48 -0000 Received: from lon-del-03.spheriq.net (HELO lon-del-03.spheriq.net) (195.46.50.99) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Mon, 24 Oct 2005 13:32:48 +0000 Received: from lon-out-02.spheriq.net ([195.46.50.130]) by lon-del-03.spheriq.net with ESMTP id j9ODWaTf027845 for ; Mon, 24 Oct 2005 13:32:37 GMT Received: from lon-cus-02.spheriq.net (lon-cus-02.spheriq.net [195.46.50.38]) by lon-out-02.spheriq.net with ESMTP id j9ODWDCl010721 for ; Mon, 24 Oct 2005 13:32:29 GMT Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by lon-cus-02.spheriq.net with ESMTP id j9ODWBho007690 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=OK); Mon, 24 Oct 2005 13:32:13 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 800CADA47; Mon, 24 Oct 2005 13:31:56 +0000 (GMT) Received: by zeta.dmz-eu.st.com (STMicroelectronics, from userid 60012) id AC82947C5B; Mon, 24 Oct 2005 13:34:44 +0000 (GMT) Received: from zeta.dmz-eu.st.com (localhost [127.0.0.1]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 6566175999; Mon, 24 Oct 2005 13:34:44 +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 84FDD47C6D; Mon, 24 Oct 2005 13:34:43 +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 CDV02551 (AUTH "andrew stubbs"); Mon, 24 Oct 2005 14:31:53 +0100 (BST) Message-ID: <435CE1E7.4040803@st.com> Date: Mon, 24 Oct 2005 13:32: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> In-Reply-To: Content-Type: multipart/mixed; boundary="------------070602090403000601000505" 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: 2.3.0 X-SW-Source: 2005-10/txt/msg00189.txt.bz2 This is a multi-part message in MIME format. --------------070602090403000601000505 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1088 Jim Blandy wrote: > Andrew STUBBS writes: > >>Index: src/gdb/tui/tui-command.c >>=================================================================== >>--- src.orig/gdb/tui/tui-command.c 2004-02-16 21:05:09.000000000 +0000 >>+++ src/gdb/tui/tui-command.c 2005-10-17 14:33:06.000000000 +0100 >>@@ -70,7 +70,7 @@ tui_dispatch_ctrl_char (unsigned int ch) >> 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 && (strcmp (term, "XTERM") == 0) && key_is_start_sequence (ch)) >> { >> unsigned int page_ch = 0; >> unsigned int tmp_char; > > > How about wrapping the upcasing loop and the 'if' after it all in one > big 'if (term), starting right after the 'getenv ("TERM")', and then > simplifying the conditional in the upcasing loop? > How about the attached? Diff has made it look rather confusing, but I assure you the only thing that has changed is the indenting and the extra if. Andrew Stubbs --------------070602090403000601000505 Content-Type: text/plain; name="tui-NULL-pointer.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="tui-NULL-pointer.patch" Content-length: 1859 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 14:11:02.000000000 +0100 @@ -67,34 +67,36 @@ tui_dispatch_ctrl_char (unsigned int ch) ** by keypad as a single char, so we must handle them here. ** 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 = (char *) getenv ("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) --------------070602090403000601000505--