summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2007-07-31 12:05:40 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:29:07 -0500
commita2d6aa829faa65df14ee566e455e807693cc2bd9 (patch)
tree4d7088915b91a717884a301a14d0d5ddac98b95f /source3
parent3d769de244b9193e309a7e1c8f602985b0c1fa75 (diff)
downloadsamba-a2d6aa829faa65df14ee566e455e807693cc2bd9.tar.gz
samba-a2d6aa829faa65df14ee566e455e807693cc2bd9.tar.bz2
samba-a2d6aa829faa65df14ee566e455e807693cc2bd9.zip
r24102: Pass the fid instead of inbuf and an offset to file_fsp.
This removes the buf==NULL condition in file_fsp(), but wherever it is called we do have a buffer anyway. Volker (This used to be commit d70a1f82fed64fa332f16407bea7c6671f48c59a)
Diffstat (limited to 'source3')
-rw-r--r--source3/smbd/files.c8
-rw-r--r--source3/smbd/nttrans.c18
-rw-r--r--source3/smbd/reply.c46
-rw-r--r--source3/smbd/trans2.c8
4 files changed, 38 insertions, 42 deletions
diff --git a/source3/smbd/files.c b/source3/smbd/files.c
index 07dec80a47..9d27c69a6b 100644
--- a/source3/smbd/files.c
+++ b/source3/smbd/files.c
@@ -487,7 +487,7 @@ files_struct *file_fnum(uint16 fnum)
Get an fsp from a packet given the offset of a 16 bit fnum.
****************************************************************************/
-files_struct *file_fsp(const char *buf, int where)
+files_struct *file_fsp(uint16 fid)
{
files_struct *fsp;
@@ -495,11 +495,7 @@ files_struct *file_fsp(const char *buf, int where)
return chain_fsp;
}
- if (!buf) {
- return NULL;
- }
-
- fsp = file_fnum(SVAL(buf, where));
+ fsp = file_fnum(fid);
if (fsp) {
chain_fsp = fsp;
}
diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
index 8250942274..3676079ec8 100644
--- a/source3/smbd/nttrans.c
+++ b/source3/smbd/nttrans.c
@@ -619,7 +619,7 @@ void reply_ntcreate_and_X(connection_struct *conn,
*/
pstring rel_fname;
files_struct *dir_fsp = file_fsp(
- (char *)req->inbuf, smb_ntcreate_RootDirectoryFid);
+ SVAL(req->inbuf, smb_ntcreate_RootDirectoryFid));
size_t dir_name_len;
if(!dir_fsp) {
@@ -1377,7 +1377,7 @@ static int call_nt_transact_create(connection_struct *conn, char *inbuf, char *o
/*
* This filename is relative to a directory fid.
*/
- files_struct *dir_fsp = file_fsp(params,4);
+ files_struct *dir_fsp = file_fsp(SVAL(params,4));
size_t dir_name_len;
if(!dir_fsp) {
@@ -2078,7 +2078,7 @@ static int call_nt_transact_notify_change(connection_struct *conn, char *inbuf,
return ERROR_DOS(ERRDOS,ERRbadfunc);
}
- fsp = file_fsp((char *)setup,4);
+ fsp = file_fsp(SVAL(setup,4));
filter = IVAL(setup, 0);
recursive = (SVAL(setup, 6) != 0) ? True : False;
@@ -2173,7 +2173,7 @@ static int call_nt_transact_rename(connection_struct *conn, char *inbuf, char *o
return ERROR_DOS(ERRDOS,ERRbadfunc);
}
- fsp = file_fsp(params, 0);
+ fsp = file_fsp(SVAL(params, 0));
replace_if_exists = (SVAL(params,2) & RENAME_REPLACE_IF_EXISTS) ? True : False;
CHECK_FSP(fsp, conn);
srvstr_get_path_wcard(inbuf, SVAL(inbuf,smb_flg2), new_name, params+4,
@@ -2244,7 +2244,7 @@ static int call_nt_transact_query_security_desc(connection_struct *conn, char *i
return ERROR_DOS(ERRDOS,ERRbadfunc);
}
- fsp = file_fsp(params,0);
+ fsp = file_fsp(SVAL(params,0));
if(!fsp) {
return ERROR_DOS(ERRDOS,ERRbadfid);
}
@@ -2358,7 +2358,7 @@ static int call_nt_transact_set_security_desc(connection_struct *conn, char *inb
return ERROR_DOS(ERRDOS,ERRbadfunc);
}
- if((fsp = file_fsp(params,0)) == NULL) {
+ if((fsp = file_fsp(SVAL(params,0))) == NULL) {
return ERROR_DOS(ERRDOS,ERRbadfid);
}
@@ -2415,7 +2415,7 @@ static int call_nt_transact_ioctl(connection_struct *conn, char *inbuf, char *ou
DEBUG(10,("call_nt_transact_ioctl: function[0x%08X] FID[0x%04X] isFSctl[0x%02X] compfilter[0x%02X]\n",
function, fidnum, isFSctl, compfilter));
- fsp=file_fsp((char *)*ppsetup, 4);
+ fsp=file_fsp(SVAL(ppsetup, 4));
/* this check is done in each implemented function case for now
because I don't want to break anything... --metze
FSP_BELONGS_CONN(fsp,conn);*/
@@ -2693,7 +2693,7 @@ static int call_nt_transact_get_user_quota(connection_struct *conn, char *inbuf,
}
/* maybe we can check the quota_fnum */
- fsp = file_fsp(params,0);
+ fsp = file_fsp(SVAL(params,0));
if (!CHECK_NTQUOTA_HANDLE_OK(fsp,conn)) {
DEBUG(3,("TRANSACT_GET_USER_QUOTA: no valid QUOTA HANDLE\n"));
return ERROR_NT(NT_STATUS_INVALID_HANDLE);
@@ -2941,7 +2941,7 @@ static int call_nt_transact_set_user_quota(connection_struct *conn, char *inbuf,
}
/* maybe we can check the quota_fnum */
- fsp = file_fsp(params,0);
+ fsp = file_fsp(SVAL(params,0));
if (!CHECK_NTQUOTA_HANDLE_OK(fsp,conn)) {
DEBUG(3,("TRANSACT_GET_USER_QUOTA: no valid QUOTA HANDLE\n"));
return ERROR_NT(NT_STATUS_INVALID_HANDLE);
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index c703a4d72b..385a47bbf3 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -709,7 +709,7 @@ int reply_ioctl(connection_struct *conn,
switch (ioctl_code) {
case IOCTL_QUERY_JOB_INFO:
{
- files_struct *fsp = file_fsp(inbuf,smb_vwv0);
+ files_struct *fsp = file_fsp(SVAL(inbuf,smb_vwv0));
if (!fsp) {
END_PROFILE(SMBioctl);
return(UNIXERROR(ERRDOS,ERRbadfid));
@@ -2433,7 +2433,7 @@ int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_s
* return a zero length response here.
*/
- fsp = file_fsp(inbuf,smb_vwv0);
+ fsp = file_fsp(SVAL(inbuf,smb_vwv0));
if (!FNUM_OK(fsp,conn) || !fsp->can_read) {
/*
@@ -2538,7 +2538,7 @@ int reply_lockread(connection_struct *conn, char *inbuf,char *outbuf, int length
SMB_OFF_T startpos;
size_t numtoread;
NTSTATUS status;
- files_struct *fsp = file_fsp(inbuf,smb_vwv0);
+ files_struct *fsp = file_fsp(SVAL(inbuf,smb_vwv0));
struct byte_range_lock *br_lck = NULL;
START_PROFILE(SMBlockread);
@@ -2624,7 +2624,7 @@ int reply_read(connection_struct *conn, char *inbuf,char *outbuf, int size, int
char *data;
SMB_OFF_T startpos;
int outsize = 0;
- files_struct *fsp = file_fsp(inbuf,smb_vwv0);
+ files_struct *fsp = file_fsp(SVAL(inbuf,smb_vwv0));
START_PROFILE(SMBread);
CHECK_FSP(fsp,conn);
@@ -2827,7 +2827,7 @@ normal_read:
int reply_read_and_X(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize)
{
- files_struct *fsp = file_fsp(inbuf,smb_vwv2);
+ files_struct *fsp = file_fsp(SVAL(inbuf,smb_vwv2));
SMB_OFF_T startpos = IVAL_TO_SMB_OFF_T(inbuf,smb_vwv3);
ssize_t nread = -1;
size_t smb_maxcnt = SVAL(inbuf,smb_vwv5);
@@ -2928,7 +2928,7 @@ int reply_writebraw(connection_struct *conn, char *inbuf,char *outbuf, int size,
SMB_OFF_T startpos;
char *data=NULL;
BOOL write_through;
- files_struct *fsp = file_fsp(inbuf,smb_vwv0);
+ files_struct *fsp = file_fsp(SVAL(inbuf,smb_vwv0));
int outsize = 0;
NTSTATUS status;
START_PROFILE(SMBwritebraw);
@@ -3079,7 +3079,7 @@ int reply_writeunlock(connection_struct *conn, char *inbuf,char *outbuf,
SMB_OFF_T startpos;
char *data;
NTSTATUS status = NT_STATUS_OK;
- files_struct *fsp = file_fsp(inbuf,smb_vwv0);
+ files_struct *fsp = file_fsp(SVAL(inbuf,smb_vwv0));
int outsize = 0;
START_PROFILE(SMBwriteunlock);
@@ -3157,7 +3157,7 @@ int reply_write(connection_struct *conn, char *inbuf,char *outbuf,int size,int d
ssize_t nwritten = -1;
SMB_OFF_T startpos;
char *data;
- files_struct *fsp = file_fsp(inbuf,smb_vwv0);
+ files_struct *fsp = file_fsp(SVAL(inbuf,smb_vwv0));
int outsize = 0;
NTSTATUS status;
START_PROFILE(SMBwrite);
@@ -3240,7 +3240,7 @@ int reply_write(connection_struct *conn, char *inbuf,char *outbuf,int size,int d
int reply_write_and_X(connection_struct *conn, char *inbuf,char *outbuf,int length,int bufsize)
{
- files_struct *fsp = file_fsp(inbuf,smb_vwv2);
+ files_struct *fsp = file_fsp(SVAL(inbuf,smb_vwv2));
SMB_OFF_T startpos = IVAL_TO_SMB_OFF_T(inbuf,smb_vwv3);
size_t numtowrite = SVAL(inbuf,smb_vwv10);
BOOL write_through = BITSETW(inbuf+smb_vwv7,0);
@@ -3362,7 +3362,7 @@ int reply_lseek(connection_struct *conn, char *inbuf,char *outbuf, int size, int
SMB_OFF_T res= -1;
int mode,umode;
int outsize = 0;
- files_struct *fsp = file_fsp(inbuf,smb_vwv0);
+ files_struct *fsp = file_fsp(SVAL(inbuf,smb_vwv0));
START_PROFILE(SMBlseek);
CHECK_FSP(fsp,conn);
@@ -3434,7 +3434,7 @@ int reply_flush(connection_struct *conn, char *inbuf,char *outbuf, int size, int
{
int outsize = set_message(inbuf,outbuf,0,0,False);
uint16 fnum = SVAL(inbuf,smb_vwv0);
- files_struct *fsp = file_fsp(inbuf,smb_vwv0);
+ files_struct *fsp = file_fsp(SVAL(inbuf,smb_vwv0));
START_PROFILE(SMBflush);
if (fnum != 0xFFFF)
@@ -3501,7 +3501,7 @@ void reply_close(connection_struct *conn, struct smb_request *req)
return;
}
- fsp = file_fsp((char *)req->inbuf,smb_vwv0);
+ fsp = file_fsp(SVAL(req->inbuf,smb_vwv0));
/*
* We can only use CHECK_FSP if we know it's not a directory.
@@ -3570,7 +3570,7 @@ int reply_writeclose(connection_struct *conn,
SMB_OFF_T startpos;
char *data;
struct timespec mtime;
- files_struct *fsp = file_fsp(inbuf,smb_vwv0);
+ files_struct *fsp = file_fsp(SVAL(inbuf,smb_vwv0));
START_PROFILE(SMBwriteclose);
CHECK_FSP(fsp,conn);
@@ -3637,7 +3637,7 @@ int reply_lock(connection_struct *conn,
int outsize = set_message(inbuf,outbuf,0,0,False);
SMB_BIG_UINT count,offset;
NTSTATUS status;
- files_struct *fsp = file_fsp(inbuf,smb_vwv0);
+ files_struct *fsp = file_fsp(SVAL(inbuf,smb_vwv0));
struct byte_range_lock *br_lck = NULL;
START_PROFILE(SMBlock);
@@ -3684,7 +3684,7 @@ int reply_unlock(connection_struct *conn, char *inbuf,char *outbuf, int size,
int outsize = set_message(inbuf,outbuf,0,0,False);
SMB_BIG_UINT count,offset;
NTSTATUS status;
- files_struct *fsp = file_fsp(inbuf,smb_vwv0);
+ files_struct *fsp = file_fsp(SVAL(inbuf,smb_vwv0));
START_PROFILE(SMBunlock);
CHECK_FSP(fsp,conn);
@@ -3830,7 +3830,7 @@ int reply_printclose(connection_struct *conn,
char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
{
int outsize = set_message(inbuf,outbuf,0,0,False);
- files_struct *fsp = file_fsp(inbuf,smb_vwv0);
+ files_struct *fsp = file_fsp(SVAL(inbuf,smb_vwv0));
NTSTATUS status;
START_PROFILE(SMBsplclose);
@@ -3935,7 +3935,7 @@ int reply_printwrite(connection_struct *conn, char *inbuf,char *outbuf, int dum_
int numtowrite;
int outsize = set_message(inbuf,outbuf,0,0,False);
char *data;
- files_struct *fsp = file_fsp(inbuf,smb_vwv0);
+ files_struct *fsp = file_fsp(SVAL(inbuf,smb_vwv0));
START_PROFILE(SMBsplwr);
@@ -5533,7 +5533,7 @@ SMB_BIG_UINT get_lock_offset( char *data, int data_offset, BOOL large_file_forma
int reply_lockingX(connection_struct *conn, char *inbuf, char *outbuf,
int length, int bufsize)
{
- files_struct *fsp = file_fsp(inbuf,smb_vwv2);
+ files_struct *fsp = file_fsp(SVAL(inbuf,smb_vwv2));
unsigned char locktype = CVAL(inbuf,smb_vwv3);
unsigned char oplocklevel = CVAL(inbuf,smb_vwv3+1);
uint16 num_ulocks = SVAL(inbuf,smb_vwv6);
@@ -5860,7 +5860,7 @@ int reply_readbmpx(connection_struct *conn, char *inbuf,char *outbuf,int length,
int max_per_packet;
size_t tcount;
int pad;
- files_struct *fsp = file_fsp(inbuf,smb_vwv0);
+ files_struct *fsp = file_fsp(SVAL(inbuf,smb_vwv0));
START_PROFILE(SMBreadBmpx);
/* this function doesn't seem to work - disable by default */
@@ -5931,7 +5931,7 @@ int reply_setattrE(connection_struct *conn, char *inbuf,char *outbuf, int size,
{
struct timespec ts[2];
int outsize = 0;
- files_struct *fsp = file_fsp(inbuf,smb_vwv0);
+ files_struct *fsp = file_fsp(SVAL(inbuf,smb_vwv0));
START_PROFILE(SMBsetattrE);
outsize = set_message(inbuf,outbuf,0,0,False);
@@ -6000,7 +6000,7 @@ int reply_writebmpx(connection_struct *conn, char *inbuf,char *outbuf, int size,
BOOL write_through;
int smb_doff;
char *data;
- files_struct *fsp = file_fsp(inbuf,smb_vwv0);
+ files_struct *fsp = file_fsp(SVAL(inbuf,smb_vwv0));
NTSTATUS status;
START_PROFILE(SMBwriteBmpx);
@@ -6112,7 +6112,7 @@ int reply_writebs(connection_struct *conn, char *inbuf,char *outbuf, int dum_siz
char *data;
write_bmpx_struct *wbms;
BOOL send_response = False;
- files_struct *fsp = file_fsp(inbuf,smb_vwv0);
+ files_struct *fsp = file_fsp(SVAL(inbuf,smb_vwv0));
NTSTATUS status;
START_PROFILE(SMBwriteBs);
@@ -6201,7 +6201,7 @@ int reply_getattrE(connection_struct *conn, char *inbuf,char *outbuf, int size,
SMB_STRUCT_STAT sbuf;
int outsize = 0;
int mode;
- files_struct *fsp = file_fsp(inbuf,smb_vwv0);
+ files_struct *fsp = file_fsp(SVAL(inbuf,smb_vwv0));
START_PROFILE(SMBgetattrE);
outsize = set_message(inbuf,outbuf,11,0,True);
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index b5077ed8ff..d455a12fa1 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -2859,7 +2859,7 @@ cap_low = 0x%x, cap_high = 0x%x\n",
* but we didn't use the last 6 bytes for now
* --metze
*/
- fsp = file_fsp(params,0);
+ fsp = file_fsp(SVAL(params,0));
if (!CHECK_NTQUOTA_HANDLE_OK(fsp,conn)) {
DEBUG(3,("TRANSACT_GET_USER_QUOTA: no valid QUOTA HANDLE\n"));
return ERROR_NT(NT_STATUS_INVALID_HANDLE);
@@ -3341,7 +3341,7 @@ static int call_trans2qfilepathinfo(connection_struct *conn, char *inbuf, char *
max_data_bytes);
}
- fsp = file_fsp(params,0);
+ fsp = file_fsp(SVAL(params,0));
info_level = SVAL(params,2);
DEBUG(3,("call_trans2qfilepathinfo: TRANSACT2_QFILEINFO: level = %d\n", info_level));
@@ -5860,7 +5860,7 @@ static int call_trans2setfilepathinfo(connection_struct *conn,
return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
}
- fsp = file_fsp(params,0);
+ fsp = file_fsp(SVAL(params,0));
info_level = SVAL(params,2);
if(fsp && (fsp->is_directory || fsp->fh->fd == -1)) {
@@ -6460,7 +6460,7 @@ static int call_trans2ioctl(connection_struct *conn, char* inbuf, char* outbuf,
unsigned int max_data_bytes)
{
char *pdata = *ppdata;
- files_struct *fsp = file_fsp(inbuf,smb_vwv15);
+ files_struct *fsp = file_fsp(SVAL(inbuf,smb_vwv15));
/* check for an invalid fid before proceeding */