From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9579 invoked by alias); 11 Oct 2005 14:14:23 -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 9557 invoked by uid 22791); 11 Oct 2005 14:14:20 -0000 Received: from omx3-ext.sgi.com (HELO omx3.sgi.com) (192.48.171.20) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Tue, 11 Oct 2005 14:14:20 +0000 Received: from cthulhu.engr.sgi.com (cthulhu.engr.sgi.com [192.26.80.2]) by omx3.sgi.com (8.12.11/8.12.9/linux-outbound_gateway-1.1) with ESMTP id j9BEqC6n013987 for ; Tue, 11 Oct 2005 08:04:31 -0700 Received: from quasar.engr.sgi.com (quasar.engr.sgi.com [163.154.6.61]) by cthulhu.engr.sgi.com (SGI-8.12.5/8.12.5) with ESMTP id j9AFULps19469855 for ; Mon, 10 Oct 2005 08:33:04 -0700 (PDT) Received: from quasar.engr.sgi.com (localhost [127.0.0.1]) by quasar.engr.sgi.com (SGI-8.12.5/8.12.5) with ESMTP id j9AFTV89040658 for ; Mon, 10 Oct 2005 08:30:11 -0700 (PDT) Received: (from davea@localhost) by quasar.engr.sgi.com (SGI-8.12.5/8.12.5/Submit) id j9AFSoOV040655 for gdb-patches@sources.redhat.com; Mon, 10 Oct 2005 08:28:50 -0700 (PDT) Date: Tue, 11 Oct 2005 14:14:00 -0000 From: David Anderson Message-Id: <200510101528.j9AFSoOV040655@quasar.engr.sgi.com> To: gdb-patches@sources.redhat.com Subject: [RFA] register name too long leads to botch X-SW-Source: 2005-10/txt/msg00101.txt.bz2 I noticed that some code is unsafe with register names longer than 15 characters. infcmd.c: print_spaces_filtered (15 - strlen (REGISTER_NAME (i)), file); ms1-tdep.c: print_spaces_filtered (15 - strlen (REGISTER_NAME (regnum)), file); ms1-tdep.c: print_spaces_filtered (15 - strlen (REGISTER_NAME (regnum)), file); ms1-tdep.c: print_spaces_filtered (15 - strlen (REGISTER_NAME (regnum)), file); sh-tdep.c: print_spaces_filtered (15 - strlen (REGISTER_NAME (regnum)), file); sh-tdep.c: print_spaces_filtered (15 - strlen (REGISTER_NAME (regnum)), file); sh64-tdep.c: print_spaces_filtered (15 - strlen (REGISTER_NAME (regnum)), file); sh64-tdep.c: print_spaces_filtered (15 - strlen (REGISTER_NAME (regnum)), file) We have some user-named 'registers' so names did get longer, and that did crash gdb and/or print garbage. Approved? 2005-10-10 David Anderson * utils.c (n_spaces): Turn negative argument to zero. Index: utils.c =================================================================== RCS file: /cvs/src/src/gdb/utils.c,v retrieving revision 1.162 diff -p -u -p -r1.162 utils.c --- utils.c 31 Jul 2005 20:56:26 -0000 1.162 +++ utils.c 10 Oct 2005 15:17:06 -0000 @@ -2291,6 +2291,8 @@ n_spaces (int n) static char *spaces = 0; static int max_spaces = -1; + if(n < 0) + n = 0; if (n > max_spaces) { if (spaces) David Anderson.