Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch] PID cmdline argument should be whole from digits
@ 2010-02-13 15:20 Jan Kratochvil
  2010-02-13 17:47 ` Eli Zaretskii
  0 siblings, 1 reply; 10+ messages in thread
From: Jan Kratochvil @ 2010-02-13 15:20 UTC (permalink / raw)
  To: gdb-patches

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  <jan.kratochvil@redhat.com>

	* main.c (captured_main) <pid_or_core_arg>: 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)


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-02-15 17:38 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-13 15:20 [patch] PID cmdline argument should be whole from digits Jan Kratochvil
2010-02-13 17:47 ` Eli Zaretskii
2010-02-13 21:03   ` Jan Kratochvil
2010-02-14 14:37     ` [patch] PID cmdline argument should be whole from digits [+testcase] Jan Kratochvil
2010-02-14 14:54       ` Pedro Alves
2010-02-14 18:56         ` Jan Kratochvil
2010-02-15 14:57           ` Pedro Alves
2010-02-15 15:52             ` Jan Kratochvil
2010-02-15 16:03               ` Mark Kettenis
2010-02-15 17:38               ` Jan Kratochvil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox