Bug 1018326 - strdup(3) segfaults when passing NULL to it
strdup(3) segfaults when passing NULL to it
Status: CLOSED NOTABUG
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: glibc (Show other bugs)
6.5
All Linux
high Severity high
: rc
: ---
Assigned To: Carlos O'Donell
qe-baseos-tools
:
Depends On: 1018323 1018331
Blocks:
  Show dependency treegraph
 
Reported: 2013-10-11 13:27 EDT by Eryu Guan
Modified: 2016-11-24 11:00 EST (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1018323
Environment:
Last Closed: 2013-10-11 21:15:02 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Eryu Guan 2013-10-11 13:27:50 EDT
glibc-2.12-1.129.el6 has this issue too

+++ This bug was initially created as a clone of Bug #1018323 +++

Description of problem:
$ cat strduptest.c 
#include <string.h>

int main(void)
{
        strdup(NULL);
}

$ gcc -o strduptest strduptest.c
$ ./strduptest
Segmentation fault (core dumped)

And dmesg shows:
strduptest[2374]: segfault at 0 ip 0000003b97086711 sp 00007fff67a8cd98 error 4 in libc-2.17.so[3b97000000+1b6000]

Version-Release number of selected component (if applicable):
glibc-2.17-18.fc19

How reproducible:
always

Steps to Reproduce:
1. see description
2.
3.

Actual results:
segfault

Expected results:
strdup(3) should deal with NULL correctly

Additional info:
Comment 1 Siddhesh Poyarekar 2013-10-11 21:15:02 EDT
Don't pass NULL to strdup or any string functions since the spec does not allow them:

http://pubs.opengroup.org/onlinepubs/9699919799/functions/strdup.html

Note You need to log in before you can comment on or make changes to this bug.