Bug 130735 - strsep() function usage ends with "Segmentation fault"
Summary: strsep() function usage ends with "Segmentation fault"
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: glibc (Show other bugs)
(Show other bugs)
Version: 2
Hardware: i386 Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
URL: https://www.223-223.ru/svn/repos/phon...
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2004-08-24 01:45 UTC by Evgeny Sizikov
Modified: 2007-11-30 22:10 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-08-30 15:07:03 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

Description Evgeny Sizikov 2004-08-24 01:45:12 UTC
Description of problem:
with usage of strsep() function an entire program ends with
"Segmentation fault"

Version-Release number of selected component (if applicable):
glibc-2.3.3-27

How reproducible:
Compile and run the program given by the URL

Steps to Reproduce:
1. get the source from the URL
2. compile
3. run
  
Actual results:
testing strtok_r()...
AL=a
o=I
testing strsep()...
AL=a
o=I
Segmentation fault

Expected results:
all from above but without "Segmentation fault"

Additional info:
kernel-2.6.7-1.494.2.2 and gcc-3.3.3-7 was used to compile the test
program, hardware:
CPU AMD AthlonXP 2200+, MB Epox with nForce2-Ultra chipset, 2 DIMMs at
2-channel mode

Comment 1 Evgeny Sizikov 2004-08-24 01:51:24 UTC
Ah, yes - if strsep() finds no any of the separators provided in the
working buffer, it doesn't produces "Segmentation fault"

Comment 2 Jakub Jelinek 2004-08-30 15:07:03 UTC
Your testcase is wrong.
The segfault is not in strsep, but when trying to free(buf).
As you used buf as strtok_r's *ptrptr pointer (and data as strsep's *stringp
pointer), the buf you pass to free is what malloc gave you plus
8 (length of the test string) and data will be NULL at the end.
You probably want to change dataptr from char ** to char * and pass
&dataptr to strtok_r and strsep.


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