bug-gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

null pointer in fork-child.c


From: Dan Grayson
Subject: null pointer in fork-child.c
Date: Sun, 25 May 2003 18:31:04 -0500 (CDT)

The following code

      /* Scan for next arg separator */
      cp = strchr (cp, ' ');
      if (cp == NULL)
        cp = strchr (cp, '\t');
      if (cp == NULL)
        cp = strchr (cp, '\n');

in fork-child.c in gdb 5.3 will always produce a segmentation fault, for when
the last argument is scanned, and the first call to strchr above returns
NULL, the original value of cp has been lost and the second call to strchr
will have a NULL first argument.

The offending code is called only if someone modifies the source code to set

    #define STARTUP_WITH_SHELL 0

in inferior.h, so it's not urgent.

Being able to call the program without having a shell called first is a good
thing, because a shell such as bash will often add environment variables and
rearrange the order of the environment variables, making it hard to find some
bugs.

Here is an example where bash does both:

    iridium% env -i N=x NN=n /bin/bash -c printenv
    NN=n
    N=x
    PWD=/tmp
    SHLVL=1
    _=/bin/printenv

    iridium% bash --version
    GNU bash, version 2.05b.0(1)-release (i686-pc-linux-gnu)
    Copyright (C) 2002 Free Software Foundation, Inc.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]