cifs: fix composing of mount options for DFS referrals
Subsystems (2)
PATCH 1/1 cifs: fix composing of mount options for DFS referrals
With the change to ignore the unc= and prefixpath= mount options, there is no longer any need to add them to the options string when mounting. By the same token, we now need to build a device name that includes the prefixpath when mounting.
To make things neater, the delimiters on the devicename are changed to '/' since that's preferred when mounting anyway.
While we're at it, fix a potential buffer overrun when building the mount options string, if the new ip= option is much longer than the original one.
--- fs/cifs/cifs_dfs_ref.c | 151 +++++++++++++++++++++++++++---------------------- fs/cifs/dns_resolve.c | 4 +- 2 files changed, 84 insertions(+), 71 deletions(-)
fs/cifs/cifs_dfs_ref.c +82 -69
@@ -18,6 +18,7 @@#include <linux/slab.h> #include <linux/vfs.h> #include <linux/fs.h> +#include <linux/inet.h> #include "cifsglob.h" #include "cifsproto.h" #include "cifsfs.h"
@@ -48,58 +49,75 @@ void cifs_dfs_release_automount_timer(void) }/** -* cifs_get_share_name - extracts share name from UNC -* @node_name: pointer to UNC string +* cifs_build_devname - build a devicename from a UNC and optional prepath +* @nodename: pointer to UNC string +* @prepath: pointer to prefixpath (or NULL if there isn't one) * -* Extracts sharename form full UNC. -* i.e. strips from UNC trailing path that is not part of share -* name and fixup missing '\' in the beginning of DFS node refferal -* if necessary. -* Returns pointer to share name on success or ERR_PTR on error. -* Caller is responsible for freeing returned string. +* Build a new cifs devicename after chasing a DFS referral. Allocate a buffer +* big enough to hold the final thing. Copy the UNC from the nodename, trimming +* off anything after the sharename. Concatenate the prepath onto the end of it +* if there is one. +* +* Returns pointer to the built string, or a ERR_PTR. Caller is responsible +* for freeing the returned string. */ -static char *cifs_get_share_name (const char *node_name) +static char * +cifs_build_devname (char *nodename,const char *prepath) { -int len; -char *UNC ; -char *pSep; - - len =strlen (node_name); -UNC =kmalloc (len+2 /*for term null and additional \ if it's missed */ , -GFP_KERNEL ); -if (!UNC ) -return ERR_PTR (-ENOMEM ); +size_t pplen; +size_t unclen; +char *dev; +char *pos; + +/* skip over any preceding delimiters */ + nodename +=strspn (nodename,"\\" ); +if (!*nodename) +return ERR_PTR (-EINVAL ); -/* get share name and server name */ -if (node_name[1 ] !='\\' ) { -UNC [0 ] ='\\' ; -strncpy (UNC +1 , node_name, len); - len++; -UNC [len] =0 ; - }else { -strncpy (UNC , node_name, len); -UNC [len] =0 ; - } +/* get length of UNC and set pos to last char */ + unclen =strlen (nodename); + pos = nodename + unclen -1 ; -/* find server name end */ - pSep =memchr (UNC +2 ,'\\' , len-2 ); -if (!pSep) { -cifs_dbg (VFS ,"%s: no server name end in node name: %s\n" , - __func__, node_name); -kfree (UNC ); -return ERR_PTR (-EINVAL ); +/* trim off any trailing delimiters */ +while (*pos =='\\' ) { + --pos; + --unclen; } -/* find sharename end */ - pSep++; - pSep =memchr (UNC +(pSep-UNC ),'\\' , len-(pSep-UNC )); -if (pSep) { -/* trim path up to sharename end -* now we have share name in UNC */ - *pSep =0 ; +/* allocate a buffer: +* +2 for preceding "//" +* +1 for delimiter between UNC and prepath +* +1 for trailing NULL +*/ + pplen = prepath ?strlen (prepath) :0 ; + dev =kmalloc (2 + unclen +1 + pplen +1 ,GFP_KERNEL ); +if (!dev) +return ERR_PTR (-ENOMEM ); + + pos = dev; +/* add the initial "//" */ + *pos ='/' ; + ++pos; + *pos ='/' ; + ++pos; + +/* copy in the UNC portion from referral */ +memcpy (pos, nodename, unclen); + pos += unclen; + +/* copy the prefixpath remainder (if there is one) */ +if (pplen) { + *pos ='/' ; + ++pos; +memcpy (pos, prepath, pplen); + pos += pplen; } -return UNC ; +/* NULL terminator */ + *pos ='\0' ; + +convert_delimiter (dev,'/' ); +return dev; }
@@ -123,6 +141,7 @@ char *cifs_compose_mount_options(const char *sb_mountdata, {int rc;char *mountdata =NULL ; +const char *prepath =NULL ;int md_len;char *tkn_e;char *srvIP =NULL ;
@@ -132,7 +151,19 @@ char *cifs_compose_mount_options(const char *sb_mountdata,if (sb_mountdata ==NULL )return ERR_PTR (-EINVAL ); - *devname =cifs_get_share_name (ref->node_name); +/* find & copy prefixpath */ + tkn_e =strchr (ref->node_name +2 ,'\\' ); +if (tkn_e ==NULL ) { +/* invalid unc, missing share name*/ + rc = -EINVAL ; + goto compose_mount_options_err; + } + + tkn_e =strchr (tkn_e +1 ,'\\' ); +if (tkn_e || (strlen (fullpath) - ref->path_consumed)) + prepath = fullpath + ref->path_consumed; + + *devname =cifs_build_devname (ref->node_name, prepath);if (IS_ERR (*devname)) { rc =PTR_ERR (*devname); *devname =NULL ;
@@ -146,12 +177,14 @@ char *cifs_compose_mount_options(const char *sb_mountdata, goto compose_mount_options_err; } -/* md_len = strlen(...) + 12 for 'sep+prefixpath=' -* assuming that we have 'unc=' and 'ip=' in -* the original sb_mountdata +/* +* In most cases, we'll be building a shorter string than the original, +* but we do have to assume that the address in the ip= option may be +* much longer than the original. Add the max length of an address +* string to the length of the original string to allow for worse case. */ - md_len =strlen (sb_mountdata) + rc +strlen (ref->node_name) +12 ; - mountdata =kzalloc (md_len+1 ,GFP_KERNEL ); + md_len =strlen (sb_mountdata) +INET6_ADDRSTRLEN ; + mountdata =kzalloc (md_len +1 ,GFP_KERNEL );if (mountdata ==NULL ) { rc = -ENOMEM ; goto compose_mount_options_err;
@@ -195,26 +228,6 @@ char *cifs_compose_mount_options(const char *sb_mountdata,strncat (mountdata, &sep,1 );strcat (mountdata,"ip=" );strcat (mountdata, srvIP); -strncat (mountdata, &sep,1 ); -strcat (mountdata,"unc=" ); -strcat (mountdata, *devname); - -/* find & copy prefixpath */ - tkn_e =strchr (ref->node_name +2 ,'\\' ); -if (tkn_e ==NULL ) { -/* invalid unc, missing share name*/ - rc = -EINVAL ; - goto compose_mount_options_err; - } - - tkn_e =strchr (tkn_e +1 ,'\\' ); -if (tkn_e || (strlen (fullpath) - ref->path_consumed)) { -strncat (mountdata, &sep,1 ); -strcat (mountdata,"prefixpath=" ); -if (tkn_e) -strcat (mountdata, tkn_e +1 ); -strcat (mountdata, fullpath + ref->path_consumed); - }/*cifs_dbg(FYI, "%s: parent mountdata: %s\n", __func__, sb_mountdata);*/ /*cifs_dbg(FYI, "%s: submount mountdata: %s\n", __func__, mountdata );*/
fs/cifs/dns_resolve.c +2 -2
@@ -34,7 +34,7 @@/** * dns_resolve_server_name_to_ip - Resolve UNC server name to ip address. -* @unc: UNC path specifying the server +* @unc: UNC path specifying the server (with '/' as delimiter) * @ip_addr: Where to return the IP address. * * The IP address will be returned in string form, and the caller is
@@ -64,7 +64,7 @@ dns_resolve_server_name_to_ip(const char *unc, char **ip_addr) hostname = unc +2 ;/* Search for server name delimiter */ - sep =memchr (hostname,'\\' , len); + sep =memchr (hostname,'/' , len);if (sep) len = sep - hostname;else
Signature · 1 line
1.8.1.4
A message that is not in the archive (sent off-list or not yet received): 1369270472-16408-1-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Quoted 39 lines · On Wed, 22 May 2013 20:54:32 -0400 Jeff Layton…
With the change to ignore the unc= and prefixpath= mount options, there is no longer any need to add them to the options string when mounting. By the same token, we now need to build a device name that includes the prefixpath when mounting.
To make things neater, the delimiters on the devicename are changed to '/' since that's preferred when mounting anyway.
While we're at it, fix a potential buffer overrun when building the mount options string, if the new ip= option is much longer than the original one.
Signed-off-by Jeff Layton <[email protected]>--- fs/cifs/cifs_dfs_ref.c | 151 +++++++++++++++++++++++++++---------------------- fs/cifs/dns_resolve.c | 4 +- 2 files changed, 84 insertions(+), 71 deletions(-)fs/cifs/cifs_dfs_ref.c +4
-2@@ -18,6 +18,7 @@#include <linux/slab.h> #include <linux/vfs.h> #include <linux/fs.h> +#include <linux/inet.h> #include "cifsglob.h" #include "cifsproto.h" #include "cifsfs.h" @@ -48,58 +49,75 @@ void cifs_dfs_release_automount_timer(void) }/** -* cifs_get_share_name - extracts share name from UNC -* @node_name: pointer to UNC string +* cifs_build_devname - build a devicename from a UNC and optional prepath +* @nodename: pointer to UNC string +* @prepath: pointer to prefixpath (or NULL if there isn't one)
fs/cifs/cifs_dfs_ref.c void cifs_dfs_release_automount_timer(void) · line 58
Quoted 10 lines
fs/cifs/cifs_dfs_ref.c +3
-6* -* Extracts sharename form full UNC. -* i.e. strips from UNC trailing path that is not part of share -* name and fixup missing '\' in the beginning of DFS node refferal -* if necessary. -* Returns pointer to share name on success or ERR_PTR on error. -* Caller is responsible for freeing returned string. +* Build a new cifs devicename after chasing a DFS referral. Allocate a buffer +* big enough to hold the final thing. Copy the UNC from the nodename, trimming +* off anything after the sharename. Concatenate the prepath onto the end of it
Sorry, the above comment is wrong and from an earlier version of this patch. The final version doesn't trim off anything after the sharename. It just concantenates the unconsumed portion of the fullpath onto the end of the referral node.
Let me know if you want me to respin this or if I should just do a fix for the comments on top of this one.
Quoted 198 lines
fs/cifs/cifs_dfs_ref.c +75
-61+* if there is one. +* +* Returns pointer to the built string, or a ERR_PTR. Caller is responsible +* for freeing the returned string. */ -static char *cifs_get_share_name (const char *node_name) +static char * +cifs_build_devname (char *nodename,const char *prepath) { -int len; -char *UNC ; -char *pSep; - - len =strlen (node_name); -UNC =kmalloc (len+2 /*for term null and additional \ if it's missed */ , -GFP_KERNEL ); -if (!UNC ) -return ERR_PTR (-ENOMEM ); +size_t pplen; +size_t unclen; +char *dev; +char *pos; + +/* skip over any preceding delimiters */ + nodename +=strspn (nodename,"\\" ); +if (!*nodename) +return ERR_PTR (-EINVAL ); -/* get share name and server name */ -if (node_name[1 ] !='\\' ) { -UNC [0 ] ='\\' ; -strncpy (UNC +1 , node_name, len); - len++; -UNC [len] =0 ; - }else { -strncpy (UNC , node_name, len); -UNC [len] =0 ; - } +/* get length of UNC and set pos to last char */ + unclen =strlen (nodename); + pos = nodename + unclen -1 ; -/* find server name end */ - pSep =memchr (UNC +2 ,'\\' , len-2 ); -if (!pSep) { -cifs_dbg (VFS ,"%s: no server name end in node name: %s\n" , - __func__, node_name); -kfree (UNC ); -return ERR_PTR (-EINVAL ); +/* trim off any trailing delimiters */ +while (*pos =='\\' ) { + --pos; + --unclen; } -/* find sharename end */ - pSep++; - pSep =memchr (UNC +(pSep-UNC ),'\\' , len-(pSep-UNC )); -if (pSep) { -/* trim path up to sharename end -* now we have share name in UNC */ - *pSep =0 ; +/* allocate a buffer: +* +2 for preceding "//" +* +1 for delimiter between UNC and prepath +* +1 for trailing NULL +*/ + pplen = prepath ?strlen (prepath) :0 ; + dev =kmalloc (2 + unclen +1 + pplen +1 ,GFP_KERNEL ); +if (!dev) +return ERR_PTR (-ENOMEM ); + + pos = dev; +/* add the initial "//" */ + *pos ='/' ; + ++pos; + *pos ='/' ; + ++pos; + +/* copy in the UNC portion from referral */ +memcpy (pos, nodename, unclen); + pos += unclen; + +/* copy the prefixpath remainder (if there is one) */ +if (pplen) { + *pos ='/' ; + ++pos; +memcpy (pos, prepath, pplen); + pos += pplen; } -return UNC ; +/* NULL terminator */ + *pos ='\0' ; + +convert_delimiter (dev,'/' ); +return dev; }@@ -123,6 +141,7 @@ char *cifs_compose_mount_options(const char *sb_mountdata, {int rc;char *mountdata =NULL ; +const char *prepath =NULL ;int md_len;char *tkn_e;char *srvIP =NULL ;@@ -132,7 +151,19 @@ char *cifs_compose_mount_options(const char *sb_mountdata,if (sb_mountdata ==NULL )return ERR_PTR (-EINVAL ); - *devname =cifs_get_share_name (ref->node_name); +/* find & copy prefixpath */ + tkn_e =strchr (ref->node_name +2 ,'\\' ); +if (tkn_e ==NULL ) { +/* invalid unc, missing share name*/ + rc = -EINVAL ; + goto compose_mount_options_err; + } + + tkn_e =strchr (tkn_e +1 ,'\\' ); +if (tkn_e || (strlen (fullpath) - ref->path_consumed)) + prepath = fullpath + ref->path_consumed; + + *devname =cifs_build_devname (ref->node_name, prepath);if (IS_ERR (*devname)) { rc =PTR_ERR (*devname); *devname =NULL ;@@ -146,12 +177,14 @@ char *cifs_compose_mount_options(const char *sb_mountdata, goto compose_mount_options_err; } -/* md_len = strlen(...) + 12 for 'sep+prefixpath=' -* assuming that we have 'unc=' and 'ip=' in -* the original sb_mountdata +/* +* In most cases, we'll be building a shorter string than the original, +* but we do have to assume that the address in the ip= option may be +* much longer than the original. Add the max length of an address +* string to the length of the original string to allow for worse case. */ - md_len =strlen (sb_mountdata) + rc +strlen (ref->node_name) +12 ; - mountdata =kzalloc (md_len+1 ,GFP_KERNEL ); + md_len =strlen (sb_mountdata) +INET6_ADDRSTRLEN ; + mountdata =kzalloc (md_len +1 ,GFP_KERNEL );if (mountdata ==NULL ) { rc = -ENOMEM ; goto compose_mount_options_err;@@ -195,26 +228,6 @@ char *cifs_compose_mount_options(const char *sb_mountdata,strncat (mountdata, &sep,1 );strcat (mountdata,"ip=" );strcat (mountdata, srvIP); -strncat (mountdata, &sep,1 ); -strcat (mountdata,"unc=" ); -strcat (mountdata, *devname); - -/* find & copy prefixpath */ - tkn_e =strchr (ref->node_name +2 ,'\\' ); -if (tkn_e ==NULL ) { -/* invalid unc, missing share name*/ - rc = -EINVAL ; - goto compose_mount_options_err; - } - - tkn_e =strchr (tkn_e +1 ,'\\' ); -if (tkn_e || (strlen (fullpath) - ref->path_consumed)) { -strncat (mountdata, &sep,1 ); -strcat (mountdata,"prefixpath=" ); -if (tkn_e) -strcat (mountdata, tkn_e +1 ); -strcat (mountdata, fullpath + ref->path_consumed); - }/*cifs_dbg(FYI, "%s: parent mountdata: %s\n", __func__, sb_mountdata);*/ /*cifs_dbg(FYI, "%s: submount mountdata: %s\n", __func__, mountdata );*/ fs/cifs/dns_resolve.c +2
-2@@ -34,7 +34,7 @@/** * dns_resolve_server_name_to_ip - Resolve UNC server name to ip address. -* @unc: UNC path specifying the server +* @unc: UNC path specifying the server (with '/' as delimiter) * @ip_addr: Where to return the IP address. * * The IP address will be returned in string form, and the caller is @@ -64,7 +64,7 @@ dns_resolve_server_name_to_ip(const char *unc, char **ip_addr) hostname = unc +2 ;/* Search for server name delimiter */ - sep =memchr (hostname,'\\' , len); + sep =memchr (hostname,'/' , len);if (sep) len = sep - hostname;else
Signature · 1 line
Jeff Layton <[email protected]>
A message that is not in the archive (sent off-list or not yet received): 20130523063715.557fbcc6-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org
I will try to fix the comment up - and we can always update it later. I will try to create the for 3.10 and for 3.11 branches later today (for-linus and for-next) so it is clearer what is going where
Quoted 272 lines · Jeff Layton
Quoted 46 lines · On Wed, 22 May 2013 20:54:32 -0400 Jeff Layton…
With the change to ignore the unc= and prefixpath= mount options, there is no longer any need to add them to the options string when mounting. By the same token, we now need to build a device name that includes the prefixpath when mounting.
To make things neater, the delimiters on the devicename are changed to '/' since that's preferred when mounting anyway.
While we're at it, fix a potential buffer overrun when building the mount options string, if the new ip= option is much longer than the original one.
Signed-off-by Jeff Layton <[email protected]>--- fs/cifs/cifs_dfs_ref.c | 151 +++++++++++++++++++++++++++---------------------- fs/cifs/dns_resolve.c | 4 +- 2 files changed, 84 insertions(+), 71 deletions(-)fs/cifs/cifs_dfs_ref.c +2
-2@@ -18,6 +18,7 @@#include <linux/slab.h> #include <linux/vfs.h> #include <linux/fs.h> +#include <linux/inet.h> #include "cifsglob.h" #include "cifsproto.h" #include "cifsfs.h" @@ -48,58 +49,75 @@ void cifs_dfs_release_automount_timer(void) }/** -* cifs_get_share_name - extracts share name from UNC -* @node_name: pointer to UNC string +* cifs_build_devname - build a devicename from a UNC and optional prepath
+ * @nodename: pointer to UNC string
+ * @prepath: pointer to prefixpath (or NULL if there isn't one) *
- * Extracts sharename form full UNC.
- * i.e. strips from UNC trailing path that is not part of share
- * name and fixup missing '\' in the beginning of DFS node refferal
- * if necessary.Quoted 8 lines
- * Returns pointer to share name on success or
ERR_PTRon error.
- * Caller is responsible for freeing returned string.
+ * Build a new cifs devicename after chasing a DFS referral. Allocate a buffer
+ * big enough to hold the final thing. Copy the UNC from the nodename, trimming
+ * off anything after the sharename. Concatenate the prepath onto the end of itSorry, the above comment is wrong and from an earlier version of this patch. The final version doesn't trim off anything after the sharename. It just concantenates the unconsumed portion of the fullpath onto the end of the referral node.
Let me know if you want me to respin this or if I should just do a fix for the comments on top of this one.
Quoted 205 lines
+ * if there is one.
+ *
+ * Returns pointer to the built string, or aERR_PTR. Caller is responsible
+ * for freeing the returned string.
*/fs/cifs/cifs_dfs_ref.c +2
-7-static char *cifs_get_share_name (const char *node_name) +static char * +cifs_build_devname (char *nodename,const char *prepath) { -int len; -char *UNC ; -char *pSep; - - len =strlen (node_name); -UNC =kmalloc (len+2 /*for term null and additional \ if it's missed */,
fs/cifs/cifs_dfs_ref.c +49
-28- GFP_KERNEL); -if (!UNC ) -return ERR_PTR (-ENOMEM ); +size_t pplen; +size_t unclen; +char *dev; +char *pos; + +/* skip over any preceding delimiters */ + nodename +=strspn (nodename,"\\" ); +if (!*nodename) +return ERR_PTR (-EINVAL ); -/* get share name and server name */ -if (node_name[1 ] !='\\' ) { -UNC [0 ] ='\\' ; -strncpy (UNC +1 , node_name, len); - len++; -UNC [len] =0 ; - }else { -strncpy (UNC , node_name, len); -UNC [len] =0 ; - } +/* get length of UNC and set pos to last char */ + unclen =strlen (nodename); + pos = nodename + unclen -1 ; -/* find server name end */ - pSep =memchr (UNC +2 ,'\\' , len-2 ); -if (!pSep) { -cifs_dbg (VFS ,"%s: no server name end in node name: %s\n" , - __func__, node_name); -kfree (UNC ); -return ERR_PTR (-EINVAL ); +/* trim off any trailing delimiters */ +while (*pos =='\\' ) { + --pos; + --unclen; } -/* find sharename end */ - pSep++; - pSep =memchr (UNC +(pSep-UNC ),'\\' , len-(pSep-UNC )); -if (pSep) { -/* trim path up to sharename end -* now we have share name in UNC */ - *pSep =0 ; +/* allocate a buffer: +* +2 for preceding "//" +* +1 for delimiter between UNC and prepath +* +1 for trailing NULL +*/ + pplen = prepath ?strlen (prepath) :0 ; + dev =kmalloc (2 + unclen +1 + pplen +1 ,GFP_KERNEL ); +if (!dev) +return ERR_PTR (-ENOMEM ); + + pos = dev; +/* add the initial "//" */ + *pos ='/' ; + ++pos; + *pos ='/' ; + ++pos; + +/* copy in the UNC portion from referral */ +memcpy (pos, nodename, unclen); + pos += unclen; + +/* copy the prefixpath remainder (if there is one) */ +if (pplen) { + *pos ='/' ; + ++pos; +memcpy (pos, prepath, pplen); + pos += pplen; } -return UNC ; +/* NULL terminator */ + *pos ='\0' ; + +convert_delimiter (dev,'/' ); +return dev; }@@ -123,6 +141,7 @@ char *cifs_compose_mount_options(const char *sb_mountdata, {int rc;char *mountdata =NULL ; +const char *prepath =NULL ;int md_len;char *tkn_e;char *srvIP = NULL;fs/cifs/cifs_dfs_ref.c +13
-1@@ -132,7 +151,19 @@ char *cifs_compose_mount_options(const char *sb_mountdata, if (sb_mountdata == NULL)return ERR_PTR (-EINVAL ); - *devname =cifs_get_share_name (ref->node_name); +/* find & copy prefixpath */ + tkn_e =strchr (ref->node_name +2 ,'\\' ); +if (tkn_e ==NULL ) { +/* invalid unc, missing share name*/ + rc = -EINVAL ; + goto compose_mount_options_err; + } + + tkn_e =strchr (tkn_e +1 ,'\\' ); +if (tkn_e || (strlen (fullpath) - ref->path_consumed)) + prepath = fullpath + ref->path_consumed; + + *devname =cifs_build_devname (ref->node_name, prepath);if (IS_ERR (*devname)) { rc =PTR_ERR (*devname);*devname = NULL;fs/cifs/cifs_dfs_ref.c +3
-3@@ -146,12 +177,14 @@ char *cifs_compose_mount_options(const char *sb_mountdata, goto compose_mount_options_err; } -/* md_len = strlen(...) + 12 for 'sep+prefixpath=' -* assuming that we have 'unc=' and 'ip=' in -* the original sb_mountdata +/* +* In most cases, we'll be building a shorter string than the original, +* but we do have to assume that the address in the ip= option may be
fs/cifs/cifs_dfs_ref.c +2
-0+* much longer than the original. Add the max length of an address +* string to the length of the original string to allow for worse case.
*/fs/cifs/cifs_dfs_ref.c +2
-22- md_len =strlen (sb_mountdata) + rc +strlen (ref->node_name) +12 ; - mountdata =kzalloc (md_len+1 ,GFP_KERNEL ); + md_len =strlen (sb_mountdata) +INET6_ADDRSTRLEN ; + mountdata =kzalloc (md_len +1 ,GFP_KERNEL );if (mountdata ==NULL ) { rc = -ENOMEM ; goto compose_mount_options_err;@@ -195,26 +228,6 @@ char *cifs_compose_mount_options(const char *sb_mountdata,strncat (mountdata, &sep,1 );strcat (mountdata,"ip=" );strcat (mountdata, srvIP); -strncat (mountdata, &sep,1 ); -strcat (mountdata,"unc=" ); -strcat (mountdata, *devname); - -/* find & copy prefixpath */ - tkn_e =strchr (ref->node_name +2 ,'\\' ); -if (tkn_e ==NULL ) { -/* invalid unc, missing share name*/ - rc = -EINVAL ; - goto compose_mount_options_err; - } - - tkn_e =strchr (tkn_e +1 ,'\\' ); -if (tkn_e || (strlen (fullpath) - ref->path_consumed)) { -strncat (mountdata, &sep,1 ); -strcat (mountdata,"prefixpath=" ); -if (tkn_e) -strcat (mountdata, tkn_e +1 ); -strcat (mountdata, fullpath + ref->path_consumed); - }/*cifs_dbg(FYI, "%s: parent mountdata: %s\n", __func__, sb_mountdata);*/
/*cifs_dbg(FYI, "%s: submount mountdata: %s\n", __func__,mountdata );*/
fs/cifs/dns_resolve.c +0
-0@@ -34,7 +34,7 @@/** * dns_resolve_server_name_to_ip - Resolve UNC server name to ip address.
- * @unc: UNC path specifying the server
+ * @unc: UNC path specifying the server (with '/' as delimiter)
* @ip_addr: Where to return the IP address.
*
* The IP address will be returned in string form, and the caller isfs/cifs/dns_resolve.c +0
-0@@ -64,7 +64,7 @@ dns_resolve_server_name_to_ip(const char *unc, char **ip_addr) hostname = unc +2 ;
Quoted 10 lines
Quoted 6 lines
fs/cifs/dns_resolve.c +1
-1/* Search for server name delimiter */ - sep =memchr (hostname,'\\' , len); + sep =memchr (hostname,'/' , len);if (sep) len = sep - hostname;else
--
Jeff Layton <[email protected]>
--
Thanks,
Steve
A message that is not in the archive (sent off-list or not yet received): CAH2r5mtxN6faWt1-XWgFNHEWCaHAWrxBjYBZdD29FsF0QwRPkg@mail.gmail.com
A message that is not in the archive (sent off-list or not yet received): CAH2r5mtxN6faWt1-XWgFNHEWCaHAWrxBjYBZdD29FsF0QwRPkg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 4 lines · On Thu, 23 May 2013 07:48:21 -0500 Steve French…
I will try to fix the comment up - and we can always update it later. I will try to create the for 3.10 and for 3.11 branches later today (for-linus and for-next) so it is clearer what is going where
Ok, thanks. I think all of the patches I sent yesterday are candidates for 3.10. It's good to have a consistency when it comes to mount options, and we want DFS to continue working.
Signature · 1 line
Jeff Layton <[email protected]>
PATCH v2 1/1 cifs: fix composing of mount options for DFS referrals
In reply to a message not in the archiveWith the change to ignore the unc= and prefixpath= mount options, there is no longer any need to add them to the options string when mounting. By the same token, we now need to build a device name that includes the prefixpath when mounting.
To make things neater, the delimiters on the devicename are changed to '/' since that's preferred when mounting anyway.
While we're at it, fix a potential buffer overrun when building the mount options string, if the new ip= option is much longer than the original one.
v2: fix some comments and don't bother looking at whether there is
a prepath in the ref->node_name when deciding whether to pass a prepath to cifs_build_devname.
--- fs/cifs/cifs_dfs_ref.c | 141 +++++++++++++++++++++++++------------------------ fs/cifs/dns_resolve.c | 4 +- 2 files changed, 74 insertions(+), 71 deletions(-)
fs/cifs/cifs_dfs_ref.c +72 -69
@@ -18,6 +18,7 @@#include <linux/slab.h> #include <linux/vfs.h> #include <linux/fs.h> +#include <linux/inet.h> #include "cifsglob.h" #include "cifsproto.h" #include "cifsfs.h"
@@ -48,58 +49,74 @@ void cifs_dfs_release_automount_timer(void) }/** -* cifs_get_share_name - extracts share name from UNC -* @node_name: pointer to UNC string +* cifs_build_devname - build a devicename from a UNC and optional prepath +* @nodename: pointer to UNC string +* @prepath: pointer to prefixpath (or NULL if there isn't one) * -* Extracts sharename form full UNC. -* i.e. strips from UNC trailing path that is not part of share -* name and fixup missing '\' in the beginning of DFS node refferal -* if necessary. -* Returns pointer to share name on success or ERR_PTR on error. -* Caller is responsible for freeing returned string. +* Build a new cifs devicename after chasing a DFS referral. Allocate a buffer +* big enough to hold the final thing. Copy the UNC from the nodename, and +* concatenate the prepath onto the end of it if there is one. +* +* Returns pointer to the built string, or a ERR_PTR. Caller is responsible +* for freeing the returned string. */ -static char *cifs_get_share_name (const char *node_name) +static char * +cifs_build_devname (char *nodename,const char *prepath) { -int len; -char *UNC ; -char *pSep; - - len =strlen (node_name); -UNC =kmalloc (len+2 /*for term null and additional \ if it's missed */ , -GFP_KERNEL ); -if (!UNC ) -return ERR_PTR (-ENOMEM ); +size_t pplen; +size_t unclen; +char *dev; +char *pos; + +/* skip over any preceding delimiters */ + nodename +=strspn (nodename,"\\" ); +if (!*nodename) +return ERR_PTR (-EINVAL ); -/* get share name and server name */ -if (node_name[1 ] !='\\' ) { -UNC [0 ] ='\\' ; -strncpy (UNC +1 , node_name, len); - len++; -UNC [len] =0 ; - }else { -strncpy (UNC , node_name, len); -UNC [len] =0 ; - } +/* get length of UNC and set pos to last char */ + unclen =strlen (nodename); + pos = nodename + unclen -1 ; -/* find server name end */ - pSep =memchr (UNC +2 ,'\\' , len-2 ); -if (!pSep) { -cifs_dbg (VFS ,"%s: no server name end in node name: %s\n" , - __func__, node_name); -kfree (UNC ); -return ERR_PTR (-EINVAL ); +/* trim off any trailing delimiters */ +while (*pos =='\\' ) { + --pos; + --unclen; } -/* find sharename end */ - pSep++; - pSep =memchr (UNC +(pSep-UNC ),'\\' , len-(pSep-UNC )); -if (pSep) { -/* trim path up to sharename end -* now we have share name in UNC */ - *pSep =0 ; +/* allocate a buffer: +* +2 for preceding "//" +* +1 for delimiter between UNC and prepath +* +1 for trailing NULL +*/ + pplen = prepath ?strlen (prepath) :0 ; + dev =kmalloc (2 + unclen +1 + pplen +1 ,GFP_KERNEL ); +if (!dev) +return ERR_PTR (-ENOMEM ); + + pos = dev; +/* add the initial "//" */ + *pos ='/' ; + ++pos; + *pos ='/' ; + ++pos; + +/* copy in the UNC portion from referral */ +memcpy (pos, nodename, unclen); + pos += unclen; + +/* copy the prefixpath remainder (if there is one) */ +if (pplen) { + *pos ='/' ; + ++pos; +memcpy (pos, prepath, pplen); + pos += pplen; } -return UNC ; +/* NULL terminator */ + *pos ='\0' ; + +convert_delimiter (dev,'/' ); +return dev; }
@@ -123,6 +140,7 @@ char *cifs_compose_mount_options(const char *sb_mountdata, {int rc;char *mountdata =NULL ; +const char *prepath =NULL ;int md_len;char *tkn_e;char *srvIP =NULL ;
@@ -132,7 +150,10 @@ char *cifs_compose_mount_options(const char *sb_mountdata,if (sb_mountdata ==NULL )return ERR_PTR (-EINVAL ); - *devname =cifs_get_share_name (ref->node_name); +if (strlen (fullpath) - ref->path_consumed) + prepath = fullpath + ref->path_consumed; + + *devname =cifs_build_devname (ref->node_name, prepath);if (IS_ERR (*devname)) { rc =PTR_ERR (*devname); *devname =NULL ;
@@ -146,12 +167,14 @@ char *cifs_compose_mount_options(const char *sb_mountdata, goto compose_mount_options_err; } -/* md_len = strlen(...) + 12 for 'sep+prefixpath=' -* assuming that we have 'unc=' and 'ip=' in -* the original sb_mountdata +/* +* In most cases, we'll be building a shorter string than the original, +* but we do have to assume that the address in the ip= option may be +* much longer than the original. Add the max length of an address +* string to the length of the original string to allow for worst case. */ - md_len =strlen (sb_mountdata) + rc +strlen (ref->node_name) +12 ; - mountdata =kzalloc (md_len+1 ,GFP_KERNEL ); + md_len =strlen (sb_mountdata) +INET6_ADDRSTRLEN ; + mountdata =kzalloc (md_len +1 ,GFP_KERNEL );if (mountdata ==NULL ) { rc = -ENOMEM ; goto compose_mount_options_err;
@@ -195,26 +218,6 @@ char *cifs_compose_mount_options(const char *sb_mountdata,strncat (mountdata, &sep,1 );strcat (mountdata,"ip=" );strcat (mountdata, srvIP); -strncat (mountdata, &sep,1 ); -strcat (mountdata,"unc=" ); -strcat (mountdata, *devname); - -/* find & copy prefixpath */ - tkn_e =strchr (ref->node_name +2 ,'\\' ); -if (tkn_e ==NULL ) { -/* invalid unc, missing share name*/ - rc = -EINVAL ; - goto compose_mount_options_err; - } - - tkn_e =strchr (tkn_e +1 ,'\\' ); -if (tkn_e || (strlen (fullpath) - ref->path_consumed)) { -strncat (mountdata, &sep,1 ); -strcat (mountdata,"prefixpath=" ); -if (tkn_e) -strcat (mountdata, tkn_e +1 ); -strcat (mountdata, fullpath + ref->path_consumed); - }/*cifs_dbg(FYI, "%s: parent mountdata: %s\n", __func__, sb_mountdata);*/ /*cifs_dbg(FYI, "%s: submount mountdata: %s\n", __func__, mountdata );*/
fs/cifs/dns_resolve.c +2 -2
@@ -34,7 +34,7 @@/** * dns_resolve_server_name_to_ip - Resolve UNC server name to ip address. -* @unc: UNC path specifying the server +* @unc: UNC path specifying the server (with '/' as delimiter) * @ip_addr: Where to return the IP address. * * The IP address will be returned in string form, and the caller is
@@ -64,7 +64,7 @@ dns_resolve_server_name_to_ip(const char *unc, char **ip_addr) hostname = unc +2 ;/* Search for server name delimiter */ - sep =memchr (hostname,'\\' , len); + sep =memchr (hostname,'/' , len);if (sep) len = sep - hostname;else
Signature · 1 line
1.8.1.4
A message that is not in the archive (sent off-list or not yet received): 1369334864-21105-1-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Quoted 179 lines · On Thu, 23 May 2013 14:47:44 -0400 Jeff Layton…
With the change to ignore the unc= and prefixpath= mount options, there is no longer any need to add them to the options string when mounting. By the same token, we now need to build a device name that includes the prefixpath when mounting.
To make things neater, the delimiters on the devicename are changed to '/' since that's preferred when mounting anyway.
While we're at it, fix a potential buffer overrun when building the mount options string, if the new ip= option is much longer than the original one.
v2: fix some comments and don't bother looking at whether there is
a prepath in theref->node_namewhen deciding whether to pass a prepath tocifs_build_devname.Signed-off-by Jeff Layton <[email protected]>--- fs/cifs/cifs_dfs_ref.c | 141 +++++++++++++++++++++++++------------------------ fs/cifs/dns_resolve.c | 4 +- 2 files changed, 74 insertions(+), 71 deletions(-)fs/cifs/cifs_dfs_ref.c +65
-47@@ -18,6 +18,7 @@#include <linux/slab.h> #include <linux/vfs.h> #include <linux/fs.h> +#include <linux/inet.h> #include "cifsglob.h" #include "cifsproto.h" #include "cifsfs.h" @@ -48,58 +49,74 @@ void cifs_dfs_release_automount_timer(void) }/** -* cifs_get_share_name - extracts share name from UNC -* @node_name: pointer to UNC string +* cifs_build_devname - build a devicename from a UNC and optional prepath +* @nodename: pointer to UNC string +* @prepath: pointer to prefixpath (or NULL if there isn't one) * -* Extracts sharename form full UNC. -* i.e. strips from UNC trailing path that is not part of share -* name and fixup missing '\' in the beginning of DFS node refferal -* if necessary. -* Returns pointer to share name on success or ERR_PTR on error. -* Caller is responsible for freeing returned string. +* Build a new cifs devicename after chasing a DFS referral. Allocate a buffer +* big enough to hold the final thing. Copy the UNC from the nodename, and +* concatenate the prepath onto the end of it if there is one. +* +* Returns pointer to the built string, or a ERR_PTR. Caller is responsible +* for freeing the returned string. */ -static char *cifs_get_share_name (const char *node_name) +static char * +cifs_build_devname (char *nodename,const char *prepath) { -int len; -char *UNC ; -char *pSep; - - len =strlen (node_name); -UNC =kmalloc (len+2 /*for term null and additional \ if it's missed */ , -GFP_KERNEL ); -if (!UNC ) -return ERR_PTR (-ENOMEM ); +size_t pplen; +size_t unclen; +char *dev; +char *pos; + +/* skip over any preceding delimiters */ + nodename +=strspn (nodename,"\\" ); +if (!*nodename) +return ERR_PTR (-EINVAL ); -/* get share name and server name */ -if (node_name[1 ] !='\\' ) { -UNC [0 ] ='\\' ; -strncpy (UNC +1 , node_name, len); - len++; -UNC [len] =0 ; - }else { -strncpy (UNC , node_name, len); -UNC [len] =0 ; - } +/* get length of UNC and set pos to last char */ + unclen =strlen (nodename); + pos = nodename + unclen -1 ; -/* find server name end */ - pSep =memchr (UNC +2 ,'\\' , len-2 ); -if (!pSep) { -cifs_dbg (VFS ,"%s: no server name end in node name: %s\n" , - __func__, node_name); -kfree (UNC ); -return ERR_PTR (-EINVAL ); +/* trim off any trailing delimiters */ +while (*pos =='\\' ) { + --pos; + --unclen; } -/* find sharename end */ - pSep++; - pSep =memchr (UNC +(pSep-UNC ),'\\' , len-(pSep-UNC )); -if (pSep) { -/* trim path up to sharename end -* now we have share name in UNC */ - *pSep =0 ; +/* allocate a buffer: +* +2 for preceding "//" +* +1 for delimiter between UNC and prepath +* +1 for trailing NULL +*/ + pplen = prepath ?strlen (prepath) :0 ; + dev =kmalloc (2 + unclen +1 + pplen +1 ,GFP_KERNEL ); +if (!dev) +return ERR_PTR (-ENOMEM ); + + pos = dev; +/* add the initial "//" */ + *pos ='/' ; + ++pos; + *pos ='/' ; + ++pos; + +/* copy in the UNC portion from referral */ +memcpy (pos, nodename, unclen); + pos += unclen; + +/* copy the prefixpath remainder (if there is one) */ +if (pplen) { + *pos ='/' ; + ++pos; +memcpy (pos, prepath, pplen); + pos += pplen; } -return UNC ; +/* NULL terminator */ + *pos ='\0' ; + +convert_delimiter (dev,'/' ); +return dev; }@@ -123,6 +140,7 @@ char *cifs_compose_mount_options(const char *sb_mountdata, {int rc;char *mountdata =NULL ; +const char *prepath =NULL ;int md_len;char *tkn_e;char *srvIP =NULL ;@@ -132,7 +150,10 @@ char *cifs_compose_mount_options(const char *sb_mountdata,if (sb_mountdata ==NULL )return ERR_PTR (-EINVAL ); - *devname =cifs_get_share_name (ref->node_name); +if (strlen (fullpath) - ref->path_consumed) + prepath = fullpath + ref->path_consumed; + + *devname =cifs_build_devname (ref->node_name, prepath);if (IS_ERR (*devname)) { rc =PTR_ERR (*devname); *devname =NULL ;@@ -146,12 +167,14 @@ char *cifs_compose_mount_options(const char *sb_mountdata, goto compose_mount_options_err; } -/* md_len = strlen(...) + 12 for 'sep+prefixpath=' -* assuming that we have 'unc=' and 'ip=' in -* the original sb_mountdata
fs/cifs/cifs_dfs_ref.c char *cifs_compose_mount_options(const char *sb_mountdata, · line 177
Quoted 10 lines
fs/cifs/cifs_dfs_ref.c +7
-2+/* +* In most cases, we'll be building a shorter string than the original, +* but we do have to assume that the address in the ip= option may be +* much longer than the original. Add the max length of an address +* string to the length of the original string to allow for worst case. */ - md_len =strlen (sb_mountdata) + rc +strlen (ref->node_name) +12 ; - mountdata =kzalloc (md_len+1 ,GFP_KERNEL ); + md_len =strlen (sb_mountdata) +INET6_ADDRSTRLEN ; + mountdata =kzalloc (md_len +1 ,GFP_KERNEL );
Hmm... on third thought, I'll go ahead and spin up a smaller patch that just fixes this potential buffer overrun so we can send it to stable, and re-base this patch on top of that.
Sorry for the noise...
Signature · 1 line
Jeff Layton <[email protected]>
PATCH 1/1 cifs: fix composing of mount options for DFS referrals
In reply to a message not in the archiveWith the change to ignore the unc= and prefixpath= mount options, there is no longer any need to add them to the options string when mounting. By the same token, we now need to build a device name that includes the prefixpath when mounting.
To make things neater, the delimiters on the devicename are changed to '/' since that's preferred when mounting anyway.
v2: fix some comments and don't bother looking at whether there is
a prepath in the ref->node_name when deciding whether to pass a prepath to cifs_build_devname.
v3: rebase on top of potential buffer overrun fix for stable
--- fs/cifs/cifs_dfs_ref.c | 141 +++++++++++++++++++++++++------------------------ fs/cifs/dns_resolve.c | 4 +- 2 files changed, 73 insertions(+), 72 deletions(-)
fs/cifs/cifs_dfs_ref.c +71 -70
@@ -49,58 +49,74 @@ void cifs_dfs_release_automount_timer(void) }/** -* cifs_get_share_name - extracts share name from UNC -* @node_name: pointer to UNC string +* cifs_build_devname - build a devicename from a UNC and optional prepath +* @nodename: pointer to UNC string +* @prepath: pointer to prefixpath (or NULL if there isn't one) * -* Extracts sharename form full UNC. -* i.e. strips from UNC trailing path that is not part of share -* name and fixup missing '\' in the beginning of DFS node refferal -* if necessary. -* Returns pointer to share name on success or ERR_PTR on error. -* Caller is responsible for freeing returned string. +* Build a new cifs devicename after chasing a DFS referral. Allocate a buffer +* big enough to hold the final thing. Copy the UNC from the nodename, and +* concatenate the prepath onto the end of it if there is one. +* +* Returns pointer to the built string, or a ERR_PTR. Caller is responsible +* for freeing the returned string. */ -static char *cifs_get_share_name (const char *node_name) +static char * +cifs_build_devname (char *nodename,const char *prepath) { -int len; -char *UNC ; -char *pSep; - - len =strlen (node_name); -UNC =kmalloc (len+2 /*for term null and additional \ if it's missed */ , -GFP_KERNEL ); -if (!UNC ) -return ERR_PTR (-ENOMEM ); +size_t pplen; +size_t unclen; +char *dev; +char *pos; + +/* skip over any preceding delimiters */ + nodename +=strspn (nodename,"\\" ); +if (!*nodename) +return ERR_PTR (-EINVAL ); -/* get share name and server name */ -if (node_name[1 ] !='\\' ) { -UNC [0 ] ='\\' ; -strncpy (UNC +1 , node_name, len); - len++; -UNC [len] =0 ; - }else { -strncpy (UNC , node_name, len); -UNC [len] =0 ; - } +/* get length of UNC and set pos to last char */ + unclen =strlen (nodename); + pos = nodename + unclen -1 ; -/* find server name end */ - pSep =memchr (UNC +2 ,'\\' , len-2 ); -if (!pSep) { -cifs_dbg (VFS ,"%s: no server name end in node name: %s\n" , - __func__, node_name); -kfree (UNC ); -return ERR_PTR (-EINVAL ); +/* trim off any trailing delimiters */ +while (*pos =='\\' ) { + --pos; + --unclen; } -/* find sharename end */ - pSep++; - pSep =memchr (UNC +(pSep-UNC ),'\\' , len-(pSep-UNC )); -if (pSep) { -/* trim path up to sharename end -* now we have share name in UNC */ - *pSep =0 ; +/* allocate a buffer: +* +2 for preceding "//" +* +1 for delimiter between UNC and prepath +* +1 for trailing NULL +*/ + pplen = prepath ?strlen (prepath) :0 ; + dev =kmalloc (2 + unclen +1 + pplen +1 ,GFP_KERNEL ); +if (!dev) +return ERR_PTR (-ENOMEM ); + + pos = dev; +/* add the initial "//" */ + *pos ='/' ; + ++pos; + *pos ='/' ; + ++pos; + +/* copy in the UNC portion from referral */ +memcpy (pos, nodename, unclen); + pos += unclen; + +/* copy the prefixpath remainder (if there is one) */ +if (pplen) { + *pos ='/' ; + ++pos; +memcpy (pos, prepath, pplen); + pos += pplen; } -return UNC ; +/* NULL terminator */ + *pos ='\0' ; + +convert_delimiter (dev,'/' ); +return dev; }
@@ -124,6 +140,7 @@ char *cifs_compose_mount_options(const char *sb_mountdata, {int rc;char *mountdata =NULL ; +const char *prepath =NULL ;int md_len;char *tkn_e;char *srvIP =NULL ;
@@ -133,7 +150,10 @@ char *cifs_compose_mount_options(const char *sb_mountdata,if (sb_mountdata ==NULL )return ERR_PTR (-EINVAL ); - *devname =cifs_get_share_name (ref->node_name); +if (strlen (fullpath) - ref->path_consumed) + prepath = fullpath + ref->path_consumed; + + *devname =cifs_build_devname (ref->node_name, prepath);if (IS_ERR (*devname)) { rc =PTR_ERR (*devname); *devname =NULL ;
@@ -147,13 +167,14 @@ char *cifs_compose_mount_options(const char *sb_mountdata, goto compose_mount_options_err; } -/* md_len = strlen(...) + 12 for 'sep+prefixpath=' -* assuming that we have 'unc=' and 'ip=' in -* the original sb_mountdata +/* +* In most cases, we'll be building a shorter string than the original, +* but we do have to assume that the address in the ip= option may be +* much longer than the original. Add the max length of an address +* string to the length of the original string to allow for worst case. */ - md_len =strlen (sb_mountdata) + rc +strlen (ref->node_name) +12 + -INET6_ADDRSTRLEN ; - mountdata =kzalloc (md_len+1 ,GFP_KERNEL ); + md_len =strlen (sb_mountdata) +INET6_ADDRSTRLEN ; + mountdata =kzalloc (md_len +1 ,GFP_KERNEL );if (mountdata ==NULL ) { rc = -ENOMEM ; goto compose_mount_options_err;
@@ -197,26 +218,6 @@ char *cifs_compose_mount_options(const char *sb_mountdata,strncat (mountdata, &sep,1 );strcat (mountdata,"ip=" );strcat (mountdata, srvIP); -strncat (mountdata, &sep,1 ); -strcat (mountdata,"unc=" ); -strcat (mountdata, *devname); - -/* find & copy prefixpath */ - tkn_e =strchr (ref->node_name +2 ,'\\' ); -if (tkn_e ==NULL ) { -/* invalid unc, missing share name*/ - rc = -EINVAL ; - goto compose_mount_options_err; - } - - tkn_e =strchr (tkn_e +1 ,'\\' ); -if (tkn_e || (strlen (fullpath) - ref->path_consumed)) { -strncat (mountdata, &sep,1 ); -strcat (mountdata,"prefixpath=" ); -if (tkn_e) -strcat (mountdata, tkn_e +1 ); -strcat (mountdata, fullpath + ref->path_consumed); - }/*cifs_dbg(FYI, "%s: parent mountdata: %s\n", __func__, sb_mountdata);*/ /*cifs_dbg(FYI, "%s: submount mountdata: %s\n", __func__, mountdata );*/
fs/cifs/dns_resolve.c +2 -2
@@ -34,7 +34,7 @@/** * dns_resolve_server_name_to_ip - Resolve UNC server name to ip address. -* @unc: UNC path specifying the server +* @unc: UNC path specifying the server (with '/' as delimiter) * @ip_addr: Where to return the IP address. * * The IP address will be returned in string form, and the caller is
@@ -64,7 +64,7 @@ dns_resolve_server_name_to_ip(const char *unc, char **ip_addr) hostname = unc +2 ;/* Search for server name delimiter */ - sep =memchr (hostname,'\\' , len); + sep =memchr (hostname,'/' , len);if (sep) len = sep - hostname;else
Signature · 1 line
1.8.1.4