1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-29 21:47:30 +03:00

Fixed bug found by Richard Sharpe. After increasing files_struct size by

MAX_OPEN_DIRECTORIES for nttrans I forgot to update the code that
enumerates the array.
Created new MAX_FNUMS in local.h, changed all code that iterates
through the files_struct array to use this.
(sorry Richard).
Jeremy.
This commit is contained in:
Jeremy Allison -
parent 953c5dbbae
commit 339b102222
6 changed files with 16 additions and 14 deletions

View File

@ -42,6 +42,8 @@
file handle per directory, but large numbers do use more memory */
#define MAX_OPEN_DIRECTORIES 64
#define MAX_FNUMS (MAX_OPEN_FILES+MAX_OPEN_DIRECTORIES)
/* Default size of shared memory used for share mode locking */
#ifndef SHMEM_SIZE
#define SHMEM_SIZE (1024*(MAX_OPEN_FILES+MAX_OPEN_DIRECTORIES))

View File

@ -781,7 +781,7 @@ struct parm_struct
#endif /* LOCKING_VERSION */
/* these are useful macros for checking validity of handles */
#define VALID_FNUM(fnum) (((fnum) >= 0) && ((fnum) < MAX_OPEN_FILES))
#define VALID_FNUM(fnum) (((fnum) >= 0) && ((fnum) < MAX_FNUMS))
#define OPEN_FNUM(fnum) (VALID_FNUM(fnum) && Files[fnum].open && !Files[fnum].is_directory)
#define VALID_CNUM(cnum) (((cnum) >= 0) && ((cnum) < MAX_CONNECTIONS))
#define OPEN_CNUM(cnum) (VALID_CNUM(cnum) && Connections[cnum].open)

View File

@ -1983,7 +1983,7 @@ static BOOL api_PrintJobInfo(int cnum,uint16 vuid,char *param,char *data,
become_root(True);
for (i=0;i<MAX_OPEN_FILES;i++)
for (i=0;i<MAX_FNUMS;i++)
if (Files[i].open && Files[i].print_file)
{
pstring wd;

View File

@ -1490,7 +1490,7 @@ int reply_ulogoffX(char *inbuf,char *outbuf,int length,int bufsize)
open by this user */
if ((vuser != 0) && (lp_security() != SEC_SHARE)) {
int i;
for (i=0;i<MAX_OPEN_FILES;i++) {
for (i=0;i<MAX_FNUMS;i++) {
files_struct *fsp = &Files[i];
if ((fsp->vuid == vuid) && fsp->open) {
if(!fsp->is_directory)
@ -2396,7 +2396,7 @@ int reply_flush(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
if (fnum == 0xFFFF)
{
int i;
for (i=0;i<MAX_OPEN_FILES;i++)
for (i=0;i<MAX_FNUMS;i++)
if (OPEN_FNUM(i))
sync_file(i);
}

View File

@ -67,7 +67,7 @@ extern int dcelogin_atmost_once;
extern DOM_SID global_machine_sid;
connection_struct Connections[MAX_CONNECTIONS];
files_struct Files[MAX_OPEN_FILES+MAX_OPEN_DIRECTORIES];
files_struct Files[MAX_FNUMS];
/*
* Indirection for file fd's. Needed as POSIX locking
@ -3145,7 +3145,7 @@ global_oplocks_open = %d\n", timestring(), dev, inode, global_oplocks_open));
/* We need to search the file open table for the
entry containing this dev and inode, and ensure
we have an oplock on it. */
for( fnum = 0; fnum < MAX_OPEN_FILES; fnum++)
for( fnum = 0; fnum < MAX_FNUMS; fnum++)
{
if(OPEN_FNUM(fnum))
{
@ -4002,14 +4002,14 @@ int find_free_file(void )
increases the chance that the errant client will get an error rather
than causing corruption */
if (first_file == 0) {
first_file = (getpid() ^ (int)time(NULL)) % MAX_OPEN_FILES;
first_file = (getpid() ^ (int)time(NULL)) % MAX_FNUMS;
if (first_file == 0) first_file = 1;
}
if (first_file >= MAX_OPEN_FILES)
if (first_file >= MAX_FNUMS)
first_file = 1;
for (i=first_file;i<MAX_OPEN_FILES;i++)
for (i=first_file;i<MAX_FNUMS;i++)
if (!Files[i].open && !Files[i].reserved) {
memset(&Files[i], 0, sizeof(Files[i]));
first_file = i+1;
@ -4035,7 +4035,7 @@ int find_free_file(void )
* files batch oplocked for quite a long time
* after they have finished with them.
*/
for (i=first_file;i<MAX_OPEN_FILES;i++) {
for (i=first_file;i<MAX_FNUMS;i++) {
if(attempt_close_oplocked_file( &Files[i])) {
memset(&Files[i], 0, sizeof(Files[i]));
first_file = i+1;
@ -4044,7 +4044,7 @@ int find_free_file(void )
}
}
for (i=1;i<MAX_OPEN_FILES;i++) {
for (i=1;i<MAX_FNUMS;i++) {
if(attempt_close_oplocked_file( &Files[i])) {
memset(&Files[i], 0, sizeof(Files[i]));
first_file = i+1;
@ -4487,7 +4487,7 @@ close all open files for a connection
static void close_open_files(int cnum)
{
int i;
for (i=0;i<MAX_OPEN_FILES;i++)
for (i=0;i<MAX_FNUMS;i++)
if( Files[i].cnum == cnum && Files[i].open) {
if(Files[i].is_directory)
close_directory(i);
@ -5367,7 +5367,7 @@ static void init_structs(void )
string_init(&Connections[i].origpath,"");
}
for (i=0;i<MAX_OPEN_FILES;i++)
for (i=0;i<MAX_FNUMS;i++)
{
Files[i].open = False;
string_init(&Files[i].name,"");

View File

@ -57,7 +57,7 @@ unsigned int Ucrit_IsActive = 0; /* added by OH */
void become_root(BOOL save_dir) {}
void unbecome_root(BOOL restore_dir) {}
connection_struct Connections[MAX_CONNECTIONS];
files_struct Files[MAX_OPEN_FILES];
files_struct Files[MAX_FNUMS];
struct current_user current_user;