Bug 202999 - bug in tapset/string.stp:substr prevents it from returning desired substring
Summary: bug in tapset/string.stp:substr prevents it from returning desired substring
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: systemtap
Version: 4.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
: ---
Assignee: Frank Ch. Eigler
QA Contact: Len DiMaggio
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2006-08-17 18:54 UTC by Jonathan Earl Brassow
Modified: 2007-11-30 22:07 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2006-09-20 15:20:31 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Jonathan Earl Brassow 2006-08-17 18:54:44 UTC
Firstly, I pulled the sources from upstream and compiled them against a kernel I
have.  So, sorry if this is fixed in the rpm.

Description of problem:
The substr function, as described in the man page and comments, indicates the
last argument is the "stop", however, the strncpy function acts as though it
expects it to be a "length" argument.

If I want "there" from "hello there world", it currently does the following:
str = "hello there world"
substr(str, 6, 11) # 11 is the stop, not the len
-> strncpy(ret, s+6, 11)
-> ret[11] = '\0'
result:  "there world"

should be:
str = "hello there world"
substr(str, 6, 11) # 11 is the stop, not the len
-> strncpy(ret, s+6, 11-6)
-> ret[11-6] = '\0'
result:  "there"

Version-Release number of selected component (if applicable):
?

How reproducible:
always

Steps to Reproduce:
See above

I am using the following (please review for correctness):
strncpy(THIS->__retvalue,s+THIS->start, THIS->stop - THIS->start);
THIS->__retvalue[THIS->stop - THIS->start]='\0';

Comment 1 Frank Ch. Eigler 2006-08-23 12:02:59 UTC
Martin will fix this upstream.

http://sourceware.org/ml/systemtap/2006-q3/msg00362.html

Comment 2 Jonathan Earl Brassow 2006-09-08 16:19:42 UTC
3 argument changed upstream to be 'length' not 'stop' - works upstream now.


Comment 3 Frank Ch. Eigler 2006-09-20 15:20:31 UTC
The fix will be included in any subsequent package refresh.


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