1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-09 09:57:48 +03:00

Fixed potential file descriptor leak with MS-Access fix.

Jeremy.
This commit is contained in:
Jeremy Allison -
parent a1eb2752a8
commit 192887fe72
2 changed files with 34 additions and 3 deletions

View File

@ -60,6 +60,8 @@ static int fd_open(struct connection_struct *conn, char *fname,
int fd_close(struct connection_struct *conn, files_struct *fsp)
{
if (fsp->fd == -1)
return -1;
return fd_close_posix(conn, fsp);
}
@ -699,9 +701,15 @@ files_struct *open_file_shared(connection_struct *conn,char *fname, SMB_STRUCT_S
* we can do. We also ensure we're not going to create or tuncate
* the file as we only want an access decision at this stage. JRA.
*/
open_file(fsp,conn,fname,psbuf,flags|(flags2&~(O_TRUNC|O_CREAT)),mode);
fsp_open = open_file(fsp,conn,fname,psbuf,flags|(flags2&~(O_TRUNC|O_CREAT)),mode);
DEBUG(4,("open_file_shared : share_mode deny - calling open_file with \
flags=0x%X flags2=0x%X mode=0%o returned %d\n",
flags,(flags2&~(O_TRUNC|O_CREAT)),(int)mode,(int)fsp_open ));
unlock_share_entry(conn, dev, inode);
if (fsp_open)
fd_close(conn, fsp);
file_free(fsp);
return NULL;
}

View File

@ -2431,7 +2431,7 @@ static void run_opentest(int dummy)
return;
}
/* This will fail - but the error should be ERRnoaccess, not ERRshare. */
/* This will fail - but the error should be ERRnoaccess, not ERRbadshare. */
fnum2 = cli_open(&cli1, fname, O_RDWR, DENY_ALL);
cli_error( &cli1, &eclass, &errnum, NULL);
@ -2444,14 +2444,37 @@ static void run_opentest(int dummy)
}
printf("finished open test 1\n");
cli_close(&cli1, fnum1);
/* Now try not readonly and ensure ERRbadshare is returned. */
cli_setatr(&cli1, fname, 0, 0);
fnum1 = cli_open(&cli1, fname, O_RDONLY, DENY_WRITE);
if (fnum1 == -1) {
printf("open of %s failed (%s)\n", fname, cli_errstr(&cli1));
return;
}
/* This will fail - but the error should be ERRshare. */
fnum2 = cli_open(&cli1, fname, O_RDWR, DENY_ALL);
cli_error( &cli1, &eclass, &errnum, NULL);
if (eclass != ERRDOS || errnum != ERRbadshare) {
printf("wrong error code (%x,%x) = %s\n", (unsigned int)eclass,
(unsigned int)errnum, cli_errstr(&cli1) );
} else {
printf("correct error code ERRDOS/ERRbadshare returned\n");
}
cli_unlink(&cli1, fname);
close_connection(&cli1);
printf("finished open test 1\n");
printf("finished open test 2\n");
}
static void list_fn(file_info *finfo, const char *name, void *state)