The branch, master has been updated
       via  22ddbb5 s3:smbd: don't limit the number of open dptrs for smb2 (bug 
#8592)
       via  39bb5a6 s3:smbd: fully construct the dptr before allocating a dnum 
in the bitmap
       via  7644547 s3:smbd: avoid string_set() in dir.c
       via  5387481 Fix -Wunused-but-set-variable compiler warnings in 
tevent_signal.c
      from  7d84805 s4: samba-tool time --help documentation improvements

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 22ddbb50534aa73240a171732d4ac1fa884fa412
Author: Stefan Metzmacher <[email protected]>
Date:   Wed Nov 9 16:04:09 2011 +0100

    s3:smbd: don't limit the number of open dptrs for smb2 (bug #8592)
    
    This fixes a crash bug that is triggered, when a client has more than
    256 directory handles with searches.
    
    metze
    
    Autobuild-User: Stefan Metzmacher <[email protected]>
    Autobuild-Date: Thu Nov 10 14:08:14 CET 2011 on sn-devel-104

commit 39bb5a62977261d0926f56b792aacaa5e772ff6f
Author: Stefan Metzmacher <[email protected]>
Date:   Wed Nov 9 15:59:22 2011 +0100

    s3:smbd: fully construct the dptr before allocating a dnum in the bitmap
    
    metze

commit 7644547a5523b77bd49d9a5d979d5e4939153401
Author: Stefan Metzmacher <[email protected]>
Date:   Thu Nov 10 10:39:34 2011 +0100

    s3:smbd: avoid string_set() in dir.c
    
    And do some more error checks.
    
    metze

commit 538748132fbf6bcc1ce0bbd474e4abf3ecdabffa
Author: Martin Schwenke <[email protected]>
Date:   Thu Nov 10 10:46:10 2011 +1100

    Fix -Wunused-but-set-variable compiler warnings in tevent_signal.c
    
    The results of some read(2) and write(2) calls are assigned into a
    variable that is never used.  Presumably this used to avoid compiler
    warnings or similar.
    
    However, from (approximately) GCC 4.6 this produces some warnings:
    
      [ 609/3910] Compiling lib/tevent/tevent_signal.c
      ../lib/tevent/tevent_signal.c: In function ‘tevent_common_signal_handler’:
      ../lib/tevent/tevent_signal.c:85:10: warning: variable ‘res’ set but not 
used [-Wunused-but-set-variable]
      ../lib/tevent/tevent_signal.c: In function ‘signal_pipe_handler’:
      ../lib/tevent/tevent_signal.c:183:10: warning: variable ‘res’ set but not 
used [-Wunused-but-set-variable]
    
    The simplest thing to do is remove the variables and cast the function
    return to void.  There is already a comment above each call.
    
    Signed-off-by: Martin Schwenke <[email protected]>
    Signed-off-by: Stefan Metzmacher <[email protected]>

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

Summary of changes:
 lib/tevent/tevent_signal.c |    6 +--
 source3/smbd/dir.c         |   66 ++++++++++++++++++++++++++++----------------
 2 files changed, 44 insertions(+), 28 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tevent/tevent_signal.c b/lib/tevent/tevent_signal.c
index b790859..fabe72c 100644
--- a/lib/tevent/tevent_signal.c
+++ b/lib/tevent/tevent_signal.c
@@ -82,7 +82,6 @@ static uint32_t tevent_sig_count(struct tevent_sigcounter s)
 static void tevent_common_signal_handler(int signum)
 {
        char c = 0;
-       ssize_t res;
        struct tevent_common_signal_list *sl;
        struct tevent_context *ev = NULL;
        int saved_errno = errno;
@@ -95,7 +94,7 @@ static void tevent_common_signal_handler(int signum)
                if (sl->se->event_ctx && sl->se->event_ctx != ev) {
                        ev = sl->se->event_ctx;
                        /* doesn't matter if this pipe overflows */
-                       res = write(ev->pipe_fds[1], &c, 1);
+                       (void) write(ev->pipe_fds[1], &c, 1);
                }
        }
 
@@ -180,9 +179,8 @@ static void signal_pipe_handler(struct tevent_context *ev, 
struct tevent_fd *fde
                                uint16_t flags, void *_private)
 {
        char c[16];
-       ssize_t res;
        /* its non-blocking, doesn't matter if we read too much */
-       res = read(fde->fd, c, sizeof(c));
+       (void) read(fde->fd, c, sizeof(c));
 }
 
 /*
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index 322c2fe..a7dc537 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -261,6 +261,10 @@ static void dptr_close_internal(struct dptr_struct *dptr)
                goto done;
        }
 
+       if (sconn->using_smb2) {
+               goto done;
+       }
+
        DLIST_REMOVE(sconn->searches.dirptrs, dptr);
 
        /*
@@ -280,7 +284,7 @@ done:
 
        /* Lanman 2 specific code */
        SAFE_FREE(dptr->wcard);
-       string_set(&dptr->path,"");
+       SAFE_FREE(dptr->path);
        SAFE_FREE(dptr);
 }
 
@@ -499,6 +503,35 @@ NTSTATUS dptr_create(connection_struct *conn, files_struct 
*fsp,
 
        ZERO_STRUCTP(dptr);
 
+       dptr->path = SMB_STRDUP(path);
+       if (!dptr->path) {
+               SAFE_FREE(dptr);
+               TALLOC_FREE(dir_hnd);
+               return NT_STATUS_NO_MEMORY;
+       }
+       dptr->conn = conn;
+       dptr->dir_hnd = dir_hnd;
+       dptr->spid = spid;
+       dptr->expect_close = expect_close;
+       dptr->wcard = SMB_STRDUP(wcard);
+       if (!dptr->wcard) {
+               SAFE_FREE(dptr->path);
+               SAFE_FREE(dptr);
+               TALLOC_FREE(dir_hnd);
+               return NT_STATUS_NO_MEMORY;
+       }
+       if (lp_posix_pathnames() || (wcard[0] == '.' && wcard[1] == 0)) {
+               dptr->has_wild = True;
+       } else {
+               dptr->has_wild = wcard_has_wild;
+       }
+
+       dptr->attr = attr;
+
+       if (sconn->using_smb2) {
+               goto done;
+       }
+
        if(old_handle) {
 
                /*
@@ -522,6 +555,8 @@ NTSTATUS dptr_create(connection_struct *conn, files_struct 
*fsp,
                        dptr->dnum = bitmap_find(sconn->searches.dptr_bmap, 0);
                        if(dptr->dnum == -1 || dptr->dnum > 254) {
                                DEBUG(0,("dptr_create: returned %d: Error - all 
old dirptrs in use ?\n", dptr->dnum));
+                               SAFE_FREE(dptr->path);
+                               SAFE_FREE(dptr->wcard);
                                SAFE_FREE(dptr);
                                TALLOC_FREE(dir_hnd);
                                return NT_STATUS_TOO_MANY_OPENED_FILES;
@@ -552,6 +587,8 @@ NTSTATUS dptr_create(connection_struct *conn, files_struct 
*fsp,
 
                        if(dptr->dnum == -1 || dptr->dnum < 255) {
                                DEBUG(0,("dptr_create: returned %d: Error - all 
new dirptrs in use ?\n", dptr->dnum));
+                               SAFE_FREE(dptr->path);
+                               SAFE_FREE(dptr->wcard);
                                SAFE_FREE(dptr);
                                TALLOC_FREE(dir_hnd);
                                return NT_STATUS_TOO_MANY_OPENED_FILES;
@@ -563,28 +600,9 @@ NTSTATUS dptr_create(connection_struct *conn, files_struct 
*fsp,
 
        dptr->dnum += 1; /* Always bias the dnum by one - no zero dnums 
allowed. */
 
-       string_set(&dptr->path,path);
-       dptr->conn = conn;
-       dptr->dir_hnd = dir_hnd;
-       dptr->spid = spid;
-       dptr->expect_close = expect_close;
-       dptr->wcard = SMB_STRDUP(wcard);
-       if (!dptr->wcard) {
-               bitmap_clear(sconn->searches.dptr_bmap, dptr->dnum - 1);
-               SAFE_FREE(dptr);
-               TALLOC_FREE(dir_hnd);
-               return NT_STATUS_NO_MEMORY;
-       }
-       if (lp_posix_pathnames() || (wcard[0] == '.' && wcard[1] == 0)) {
-               dptr->has_wild = True;
-       } else {
-               dptr->has_wild = wcard_has_wild;
-       }
-
-       dptr->attr = attr;
-
        DLIST_ADD(sconn->searches.dirptrs, dptr);
 
+done:
        DEBUG(3,("creating new dirptr %d for path %s, expect_close = %d\n",
                dptr->dnum,path,expect_close));  
 
@@ -1358,7 +1376,7 @@ static int smb_Dir_destructor(struct smb_Dir *dirp)
 #endif
                SMB_VFS_CLOSEDIR(dirp->conn,dirp->dir);
        }
-       if (dirp->conn->sconn) {
+       if (dirp->conn->sconn && !dirp->conn->sconn->using_smb2) {
                dirp->conn->sconn->searches.dirhandles_open--;
        }
        return 0;
@@ -1389,7 +1407,7 @@ struct smb_Dir *OpenDir(TALLOC_CTX *mem_ctx, 
connection_struct *conn,
                goto fail;
        }
 
-       if (sconn) {
+       if (sconn && !sconn->using_smb2) {
                sconn->searches.dirhandles_open++;
        }
        talloc_set_destructor(dirp, smb_Dir_destructor);
@@ -1433,7 +1451,7 @@ static struct smb_Dir *OpenDir_fsp(TALLOC_CTX *mem_ctx, 
connection_struct *conn,
                goto fail;
        }
 
-       if (sconn) {
+       if (sconn && !sconn->using_smb2) {
                sconn->searches.dirhandles_open++;
        }
        talloc_set_destructor(dirp, smb_Dir_destructor);


-- 
Samba Shared Repository

Reply via email to