From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31173 invoked by alias); 13 Feb 2010 15:20:53 -0000 Received: (qmail 31164 invoked by uid 22791); 13 Feb 2010 15:20:52 -0000 X-SWARE-Spam-Status: No, hits=-6.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 13 Feb 2010 15:20:48 +0000 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o1DFKliD016755 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 13 Feb 2010 10:20:47 -0500 Received: from host0.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o1DFKjYO006305 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 13 Feb 2010 10:20:46 -0500 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.3/8.14.3) with ESMTP id o1DFKigt010477 for ; Sat, 13 Feb 2010 16:20:44 +0100 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.3/8.14.3/Submit) id o1DFKig2010476 for gdb-patches@sourceware.org; Sat, 13 Feb 2010 16:20:44 +0100 Date: Sat, 13 Feb 2010 15:20:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [patch] PID cmdline argument should be whole from digits Message-ID: <20100213152044.GA6115@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-08-17) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-02/txt/msg00336.txt.bz2 Hi, # gdb ./1 1.core Attaching to program: .../1, process 1 warning: process 1 is a cloned process Cannot access memory at address 0x3d001006 that is scary because on a test box I ran as root. Normally it just prints (and loads it as a core file then): Attaching to program: .../1, process 1 ptrace: Operation not permitted. No regressions on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu. strspn is already freely in use by libiberty/cplus-dem.c. I will check it in as [obv] in several days if there are no objections. Thanks, Jan 2010-02-13 Jan Kratochvil * main.c (captured_main) : Check the whole PID_OR_CORE_ARG consists of digit characters. --- a/gdb/main.c +++ b/gdb/main.c @@ -827,10 +827,11 @@ Can't attach to process and specify a core file at the same time.")); else if (pid_or_core_arg) { /* The user specified 'gdb program pid' or gdb program core'. - If pid_or_core_arg's first character is a digit, try attach - first and then corefile. Otherwise try just corefile. */ + If pid_or_core_arg's is a number, try attach first and then corefile. + Otherwise try just corefile. */ - if (isdigit (pid_or_core_arg[0])) + if (pid_or_core_arg[0] != 0 + && strspn (pid_or_core_arg, "0123456789") == strlen (pid_or_core_arg)) { if (catch_command_errors (attach_command, pid_or_core_arg, !batch, RETURN_MASK_ALL) == 0)