This is the mail archive of the gdb-prs@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gdb/1434: Bad calls to execl()


>Number:         1434
>Category:       gdb
>Synopsis:       Bad calls to execl()
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Oct 30 14:08:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Harti Brandt
>Release:        6.0 and prior
>Organization:
>Environment:
Any
>Description:
The gdb source contains several calls to execl of the following forms:

   execl(...., 0)
or
   execl(...., NULL)

Both of these calls invoke undefined behaviour according to
ISO-C. The problem is, that for a variadic function the compile will do only default promotions so in both cases an
integer 0 will be passed to the function (unless on the concrete OS NULL is defined as (void *)0 which is not required by the standard). execl() expectes a null pointer to terminate the argument list. In order to pass a null pointer one has to explicitely cast the 0 or null pointer constant (NULL) to a pointer type:

  execl(...., (char *)NULL)

While the bad call usually makes no difference on systems
where sizeof(int) != sizeof(char *) it breaks badly on
systems where this is not true.
>How-To-Repeat:

>Fix:
Apply the attached patch
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="gdb.diff"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="gdb.diff"

ZGlmZiAtcnUgZ2RiLTYuMC9nZGIvY2xpL2NsaS1jbWRzLmMgZ2RiLTYuMC5uZXcvZ2RiL2NsaS9j
bGktY21kcy5jCi0tLSBnZGItNi4wL2dkYi9jbGkvY2xpLWNtZHMuYwlTdW4gSnVuIDIyIDA2OjIz
OjUyIDIwMDMKKysrIGdkYi02LjAubmV3L2dkYi9jbGkvY2xpLWNtZHMuYwlUaHUgT2N0IDMwIDE0
OjU0OjE1IDIwMDMKQEAgLTUxNCw5ICs1MTQsOSBAQAogCXArKzsJCQkvKiBHZXQgcGFzdCAnLycg
Ki8KIAogICAgICAgaWYgKCFhcmcpCi0JZXhlY2wgKHVzZXJfc2hlbGwsIHAsIDApOworCWV4ZWNs
ICh1c2VyX3NoZWxsLCBwLCAoY2hhciAqKTApOwogICAgICAgZWxzZQotCWV4ZWNsICh1c2VyX3No
ZWxsLCBwLCAiLWMiLCBhcmcsIDApOworCWV4ZWNsICh1c2VyX3NoZWxsLCBwLCAiLWMiLCBhcmcs
IChjaGFyICopMCk7CiAKICAgICAgIGZwcmludGZfdW5maWx0ZXJlZCAoZ2RiX3N0ZGVyciwgIkNh
bm5vdCBleGVjdXRlICVzOiAlc1xuIiwgdXNlcl9zaGVsbCwKIAkJCSAgc2FmZV9zdHJlcnJvciAo
ZXJybm8pKTsKZGlmZiAtcnUgZ2RiLTYuMC9nZGIvc2VyLXBpcGUuYyBnZGItNi4wLm5ldy9nZGIv
c2VyLXBpcGUuYwotLS0gZ2RiLTYuMC9nZGIvc2VyLXBpcGUuYwlUdWUgTWF5IDEzIDIxOjQwOjEx
IDIwMDMKKysrIGdkYi02LjAubmV3L2dkYi9zZXItcGlwZS5jCVRodSBPY3QgMzAgMTQ6NTQ6NDYg
MjAwMwpAQCAtOTgsNyArOTgsNyBAQAogICAgICAgZm9yIChvbGQgPSBwaWRsaXN0OyBvbGQ7IG9s
ZCA9IG9sZC0+bmV4dCkKIAljbG9zZSAoZmlsZW5vIChvbGQtPmZwKSk7CS8qIGRvbid0IGFsbG93
IGEgZmx1c2ggKi8KICNlbmRpZgotICAgICAgZXhlY2wgKCIvYmluL3NoIiwgInNoIiwgIi1jIiwg
bmFtZSwgTlVMTCk7CisgICAgICBleGVjbCAoIi9iaW4vc2giLCAic2giLCAiLWMiLCBuYW1lLCAo
Y2hhciAqKU5VTEwpOwogICAgICAgX2V4aXQgKDEyNyk7CiAgICAgfQogCg==


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]