r225: Patch from Pat.Hayward@propero.net to make the session_users list dynamic.
authorJeremy Allison <jra@samba.org>
Wed, 14 Apr 2004 22:35:28 +0000 (22:35 +0000)
committerJeremy Allison <jra@samba.org>
Wed, 14 Apr 2004 22:35:28 +0000 (22:35 +0000)
I restricted it to 128k max to prevent DOS attacks.
Jeremy.

source/smbd/password.c
source/smbd/trans2.c

index ef5d0a97ac7df540caf749a0d3cb69508e1880c4..d15970cbefee3934576c1e0e15b902a7dac04a2f 100644 (file)
@@ -21,7 +21,8 @@
 #include "includes.h"
 
 /* users from session setup */
-static pstring session_users="";
+static char *session_userlist = NULL;
+static int len_session_userlist = 0;
 
 /* this holds info on user ids that are already validated for this VC */
 static user_struct *validated_users;
@@ -295,14 +296,33 @@ void add_session_user(const char *user)
 
        fstrcpy(suser,passwd->pw_name);
 
-       if (suser && *suser && !in_list(suser,session_users,False)) {
-               if (strlen(suser) + strlen(session_users) + 2 >= sizeof(pstring)) {
-                       DEBUG(1,("Too many session users??\n"));
-               } else {
-                       pstrcat(session_users," ");
-                       pstrcat(session_users,suser);
+       if(!*suser)
+               return;
+
+       if( session_userlist && in_list(suser,session_userlist,False) )
+               return;
+
+       if( !session_userlist || (strlen(suser) + strlen(session_userlist) + 2 >= len_session_userlist) ) {
+               char *newlist;
+
+               if (len_session_userlist > 128 * PSTRING_LEN) {
+                       DEBUG(3,("add_session_user: session userlist already too large.\n"));
+                       return;
+               }
+               newlist = Realloc( session_userlist, len_session_userlist + PSTRING_LEN );
+               if( newlist == NULL ) {
+                       DEBUG(1,("Unable to resize session_userlist\n"));
+                       return;
                }
+               if (!session_userlist) {
+                       *newlist = '\0';
+               }
+               session_userlist = newlist;
+               len_session_userlist += PSTRING_LEN;
        }
+
+       safe_strcat(session_userlist," ",len_session_userlist-1);
+       safe_strcat(session_userlist,suser,len_session_userlist-1);
 }
 
 /****************************************************************************
@@ -468,7 +488,7 @@ BOOL authorise_login(int snum, fstring user, DATA_BLOB password,
        /* now check the list of session users */
        if (!ok) {
                char *auser;
-               char *user_list = strdup(session_users);
+               char *user_list = strdup(session_userlist);
                if (!user_list)
                        return(False);
                
index 16c2d83aa223f88c86a5fcc9774d748d9e5dc93f..1d07e7851daa179a542043ef92a2a71d7e2cde75 100644 (file)
@@ -1239,7 +1239,7 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn,
                        SOFF_T(p,0,get_allocation_size(NULL,&sbuf)); /* Number of bytes used on disk - 64 Bit */
                        p+= 8;
 
-                       put_long_date(p,sbuf.st_ctime);       /* Creation Time 64 Bit */
+                       put_long_date(p,sbuf.st_ctime);       /* Inode change Time 64 Bit */
                        put_long_date(p+8,sbuf.st_atime);     /* Last access time 64 Bit */
                        put_long_date(p+16,sbuf.st_mtime);    /* Last modification time 64 Bit */
                        p+= 24;