]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
Fix bug #5909 - MS-DFS does not work on Vista, if link name includes multibyte character.
authorYasuma Takeda <yasuma@osstech.co.jp>
Thu, 20 Nov 2008 19:41:47 +0000 (11:41 -0800)
committerKarolin Seeger <kseeger@samba.org>
Mon, 12 Jan 2009 09:11:58 +0000 (10:11 +0100)
(cherry picked from commit 92f3ba8e20bd4a5a2afdd13feb5519d723784274)

source/smbd/msdfs.c

index 19527eca05819fb2d24df4f7f0047b8d6ba9099a..0ec343c25935130724d20a7ddb22012ab6af3a6d 100644 (file)
@@ -713,7 +713,6 @@ NTSTATUS get_referred_path(TALLOC_CTX *ctx,
 static int setup_ver2_dfs_referral(const char *pathname,
                                char **ppdata, 
                                struct junction_map *junction,
-                               int consumedcnt,
                                BOOL self_referral)
 {
        char* pdata = *ppdata;
@@ -770,7 +769,8 @@ static int setup_ver2_dfs_referral(const char *pathname,
        memcpy(pdata+uni_reqpathoffset2,uni_requestedpath,requestedpathlen);
 
        /* create the header */
-       SSVAL(pdata,0,consumedcnt * 2); /* path consumed */
+       SSVAL(pdata,0,requestedpathlen - 2); /* UCS2 of path consumed minus
+                                               2 byte null */
        SSVAL(pdata,2,junction->referral_count); /* number of referral in this pkt */
        if(self_referral) {
                SIVAL(pdata,4,DFSREF_REFERRAL_SERVER | DFSREF_STORAGE_SERVER); 
@@ -814,7 +814,6 @@ static int setup_ver2_dfs_referral(const char *pathname,
 static int setup_ver3_dfs_referral(const char *pathname,
                                char **ppdata, 
                                struct junction_map *junction,
-                               int consumedcnt,
                                BOOL self_referral)
 {
        char* pdata = *ppdata;
@@ -852,7 +851,8 @@ static int setup_ver3_dfs_referral(const char *pathname,
        *ppdata = pdata;
 
        /* create the header */
-       SSVAL(pdata,0,consumedcnt * 2); /* path consumed */
+       SSVAL(pdata,0,reqpathlen - 2); /* UCS2 of path consumed minus
+                                         2 byte null */
        SSVAL(pdata,2,junction->referral_count); /* number of referral */
        if(self_referral) {
                SIVAL(pdata,4,DFSREF_REFERRAL_SERVER | DFSREF_STORAGE_SERVER); 
@@ -974,11 +974,11 @@ int setup_dfs_referral(connection_struct *orig_conn,
        switch(max_referral_level) {
        case 2:
                reply_size = setup_ver2_dfs_referral(pathnamep, ppdata, &junction, 
-                                                    consumedcnt, self_referral);
+                                                    self_referral);
                break;
        case 3:
                reply_size = setup_ver3_dfs_referral(pathnamep, ppdata, &junction, 
-                                                    consumedcnt, self_referral);
+                                                    self_referral);
                break;
        default:
                DEBUG(0,("setup_dfs_referral: Invalid dfs referral version: %d\n", max_referral_level));