Patchwork [BUG:2935] NFS rpc auth: handle multiple host/ip args

login
register
Submitter shishir gowda
Date 2011-05-24 11:03:51
Message ID <20110524110350.GA28127@gluster.com>
Download mbox | patch
Permalink /patch/7233/
State Not Applicable, archived
Headers show

Comments

shishir gowda - 2011-05-24 11:03:51
Dup the str from str, so that the comma separated string is not truncated.

Signed-off-by: shishir gowda <shishirng@gluster.com>
---
 xlators/nfs/lib/src/rpcsvc.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

Patch

diff --git a/xlators/nfs/lib/src/rpcsvc.c b/xlators/nfs/lib/src/rpcsvc.c
index 0831cf4..79e6eba 100644
--- a/xlators/nfs/lib/src/rpcsvc.c
+++ b/xlators/nfs/lib/src/rpcsvc.c
@@ -230,6 +230,7 @@  nfs_rpcsvc_conn_peer_check_search (dict_t *options, char *pattern, char *clstr)
         char                    *addrtok = NULL;
         char                    *addrstr = NULL;
         char                    *svptr = NULL;
+        char                    *dupstr = NULL;
 
         if ((!options) || (!clstr))
                 return -1;
@@ -247,8 +248,14 @@  nfs_rpcsvc_conn_peer_check_search (dict_t *options, char *pattern, char *clstr)
                 ret = -1;
                 goto err;
         }
+        dupstr = gf_strdup (addrstr);
 
-        addrtok = strtok_r (addrstr, ",", &svptr);
+        if (!dupstr) {
+                ret = -1;
+                goto err;
+        }
+
+        addrtok = strtok_r (dupstr, ",", &svptr);
         while (addrtok) {
 
                 /* CASEFOLD not present on Solaris */
@@ -265,7 +272,8 @@  nfs_rpcsvc_conn_peer_check_search (dict_t *options, char *pattern, char *clstr)
 
         ret = -1;
 err:
-
+        if (dupstr)
+                GF_FREE (dupstr);
         return ret;
 }