Bug 1049946 - Possible problems with some strtok_r() calls.
Summary: Possible problems with some strtok_r() calls.
Keywords:
Status: CLOSED EOL
Alias: None
Product: GlusterFS
Classification: Community
Component: unclassified
Version: 3.4.2
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: ---
Assignee: bugs@gluster.org
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-01-08 14:27 UTC by Jeff Byers
Modified: 2015-10-07 13:50 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2015-10-07 13:50:53 UTC
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Embargoed:


Attachments (Terms of Use)

Description Jeff Byers 2014-01-08 14:27:08 UTC
While checking the GlusterFS version 3.4.2 source code 
to make sure that a strtok_r() bug what we had repeatably 
with 3.2.x:

 Patchwork [BUG:2935] NFS rpc auth: handle multiple host/ip args 
 http://patches.gluster.com/patch/7233/ 
 Submitter shishir gowda 
 Date 2011-05-24 11:03:51 
 Dup the str from str, so that the comma separated string is not truncated.

was, and stayed fixed, I noticed that there might be a few cases 
where a similar problem exists:

./xlators/features/quota/src/quota.c

quota_parse_limits (quota_priv_t *priv, xlator_t *this, dict_t *xl_options, 
 struct list_head *old_list) 
{ 
 char *str = NULL; 
... 
 ret = dict_get_str (xl_options, "limit-set", &str);

 if (str) { 
 path = strtok_r (str, ",", &saveptr);

Shouldn't the string be duped before calling strtok_r() since 
it changes the string buffer is passes? Something like 
is done almost everywhere else:

 dup_str = gf_strdup (str); 
 if (dup_str) { 
 path = strtok_r (str, ",", &saveptr); 
... 
 if(dup_str) { 
 GF_FREE (dup_str); 
 }

We don't use quota's so wouldn't be affected by this 
ourselves.

==========

Possibly another case where gf_strdup() is needed?

./xlators/cluster/stripe/src/stripe-helpers.c

set_stripe_block_size (xlator_t *this, stripe_private_t *priv, char *data) 
{ 
... 
 /* Get the pattern for striping. 
 "option block-size *avi:10MB" etc */ 
 stripe_str = strtok_r (data, ",", &tmp_str);

==========

Also noticed a call to strtok(), not strtok_r() here, but 
since the caller of this routine is using strtok_r(), 
probably best that this function does as well.

./libglusterfs/src/common-utils.c

gf_ports_reserved (char *blocked_port, gf_boolean_t *ports) 
{ 
... 
 if (strstr (blocked_port, "-") == NULL) { 
... 
 } else { 
 range_port = strtok (blocked_port, "-"); 
... 
 range_port = strtok (NULL, "-");

==========

Thanks.

~ Jeff Byers ~
 
Re: Possible problems with some strdup_r() calls.

message from vpshastry to me

Hey Jeff,

That's a good catch.

1. Quota and stripe

Even though its good to have the fixes, these bugs doesn't
affect any functionality of the quota or stripe since the
strings supplied to strtok_r are no more used after its use
in the function.

2. gf_ports_reserved

Agreed.

Can you please raise a bug against this to track and not
miss anything? That would be really helpful in going ahead
with the solution.

Thanks 
Varun Shastry

Comment 1 Niels de Vos 2015-05-17 21:57:57 UTC
GlusterFS 3.7.0 has been released (http://www.gluster.org/pipermail/gluster-users/2015-May/021901.html), and the Gluster project maintains N-2 supported releases. The last two releases before 3.7 are still maintained, at the moment these are 3.6 and 3.5.

This bug has been filed against the 3,4 release, and will not get fixed in a 3.4 version any more. Please verify if newer versions are affected with the reported problem. If that is the case, update the bug with a note, and update the version if you can. In case updating the version is not possible, leave a comment in this bug report with the version you tested, and set the "Need additional information the selected bugs from" below the comment box to "bugs".

If there is no response by the end of the month, this bug will get automatically closed.

Comment 2 Kaleb KEITHLEY 2015-10-07 13:50:53 UTC
GlusterFS 3.4.x has reached end-of-life.\                                                   \                                                                               If this bug still exists in a later release please reopen this and change the version or open a new bug.


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