From: Volker Lendecke Date: Mon, 29 Dec 2008 21:06:08 +0000 (+0100) Subject: Second part of the bugfix for #5933 X-Git-Tag: samba-3.3.0~121 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=897e0ee57ed913206eb705ed56fb691aa488bb9a;p=thirdparty%2Fsamba.git Second part of the bugfix for #5933 Incrementing the next vuid did not correctly overflow Now we survive BENCH-SESSSETUP with -o 100000. Takes a while though :-) Thanks a lot to Ofer Tal for reporting #5933 (cherry picked from commit b99206414f6a90c9b2223a25f3ddf5290861363d) --- diff --git a/source/smbd/password.c b/source/smbd/password.c index 54f30687734..87c525e9c57 100644 --- a/source/smbd/password.c +++ b/source/smbd/password.c @@ -27,7 +27,7 @@ static char *session_workgroup = NULL; /* this holds info on user ids that are already validated for this VC */ static user_struct *validated_users; -static int next_vuid = VUID_OFFSET; +static uint16_t next_vuid = VUID_OFFSET; static int num_validated_vuids; enum server_allocated_state { SERVER_ALLOCATED_REQUIRED_YES, @@ -147,6 +147,16 @@ void invalidate_all_vuids(void) } } +static void increment_next_vuid(uint16_t *vuid) +{ + *vuid += 1; + + /* Check for vuid wrap. */ + if (*vuid == UID_FIELD_INVALID) { + *vuid = VUID_OFFSET; + } +} + /**************************************************** Create a new partial auth user struct. *****************************************************/ @@ -175,11 +185,8 @@ int register_initial_vuid(void) /* Allocate a free vuid. Yes this is a linear search... */ while( get_valid_user_struct_internal(next_vuid, SERVER_ALLOCATED_REQUIRED_ANY) != NULL ) { + increment_next_vuid(&next_vuid); next_vuid++; - /* Check for vuid wrap. */ - if (next_vuid == UID_FIELD_INVALID) { - next_vuid = VUID_OFFSET; - } } DEBUG(10,("register_initial_vuid: allocated vuid = %u\n", @@ -192,7 +199,7 @@ int register_initial_vuid(void) * need to allocate a vuid between the first and second calls * to NTLMSSP. */ - next_vuid++; + increment_next_vuid(&next_vuid); num_validated_vuids++; DLIST_ADD(validated_users, vuser);