The branch, v3-4-test has been updated
       via  ecec9fb... s3: Simplify the code a bit: Catch (len==0) early
       via  fd63014... Fix bug 7081 - vfs_expand_msdfs doesn't work correctly 
(with fix identified)
      from  3a341c5... Fix bug #7072 - Accounts can't be unlocked from ldap.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-4-test


- Log -----------------------------------------------------------------
commit ecec9fb2d283f17aee8eceb39ab61d8204cff0f3
Author: Volker Lendecke <v...@samba.org>
Date:   Wed Feb 3 14:06:25 2010 -0800

    s3: Simplify the code a bit: Catch (len==0) early
    
    Part of a fix for bug #7081.

commit fd630147319b9a21426ba2a34b726c35c03396b6
Author: Jeremy Allison <j...@samba.org>
Date:   Tue Feb 2 16:43:41 2010 -0800

    Fix bug 7081 - vfs_expand_msdfs doesn't work correctly (with fix identified)
    
    Fix inspired by idea from Eric Horst <er...@cac.washington.edu>.
    
    Jeremy.
    (cherry picked from commit de24209f0a745ada4220a1751c4ed88ae6eea575)

-----------------------------------------------------------------------

Summary of changes:
 source3/modules/vfs_expand_msdfs.c |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/modules/vfs_expand_msdfs.c 
b/source3/modules/vfs_expand_msdfs.c
index 0d09d21..59f6f7a 100644
--- a/source3/modules/vfs_expand_msdfs.c
+++ b/source3/modules/vfs_expand_msdfs.c
@@ -173,20 +173,26 @@ static int expand_msdfs_readlink(struct vfs_handle_struct 
*handle,
        TALLOC_CTX *ctx = talloc_tos();
        int result;
        char *target = TALLOC_ARRAY(ctx, char, PATH_MAX+1);
+       size_t len;
 
        if (!target) {
                errno = ENOMEM;
                return -1;
        }
+       if (bufsiz == 0) {
+               errno = EINVAL;
+               return -1;
+       }
+
        result = SMB_VFS_NEXT_READLINK(handle, path, target,
                                       PATH_MAX);
 
-       if (result < 0)
+       if (result <= 0)
                return result;
 
        target[result] = '\0';
 
-       if ((strncmp(target, "msdfs:", strlen("msdfs:")) == 0) &&
+       if ((strncmp(target, "msdfs:", 6) == 0) &&
            (strchr_m(target, '@') != NULL)) {
                target = expand_msdfs_target(ctx, handle->conn, target);
                if (!target) {
@@ -195,8 +201,12 @@ static int expand_msdfs_readlink(struct vfs_handle_struct 
*handle,
                }
        }
 
-       safe_strcpy(buf, target, bufsiz-1);
-       return strlen(buf);
+       len = MIN(bufsiz, strlen(target));
+
+       memcpy(buf, target, len);
+
+       TALLOC_FREE(target);
+       return len;
 }
 
 /* VFS operations structure */


-- 
Samba Shared Repository

Reply via email to