This service will be undergoing maintenance at 20:00 UTC, 2017-04-03. It is expected to last about 30 minutes
Bug 202999 - bug in tapset/string.stp:substr prevents it from returning desired substring
bug in tapset/string.stp:substr prevents it from returning desired substring
Status: CLOSED UPSTREAM
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: systemtap (Show other bugs)
4.0
All Linux
medium Severity medium
: ---
: ---
Assigned To: Frank Ch. Eigler
Len DiMaggio
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-08-17 14:54 EDT by Jonathan Earl Brassow
Modified: 2007-11-30 17:07 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-09-20 11:20:31 EDT
Type: ---
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 Jonathan Earl Brassow 2006-08-17 14:54:44 EDT
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 08:02:59 EDT
Martin will fix this upstream.

http://sourceware.org/ml/systemtap/2006-q3/msg00362.html
Comment 2 Jonathan Earl Brassow 2006-09-08 12:19:42 EDT
3 argument changed upstream to be 'length' not 'stop' - works upstream now.
Comment 3 Frank Ch. Eigler 2006-09-20 11:20:31 EDT
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.