mirror of
https://github.com/samba-team/samba.git
synced 2025-02-04 17:47:26 +03:00
s3:smbd: use smb1srv_open_lookup() in is_valid_writeX_buffer()
It's more logical to check the fnum instead of tid here. This will make it easier to reuse the logic for SMB2 and allows per fsp recvfile detection. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
8d45b75df3
commit
77b6860668
@ -4598,12 +4598,12 @@ bool is_valid_writeX_buffer(struct smbd_server_connection *sconn,
|
|||||||
const uint8_t *inbuf)
|
const uint8_t *inbuf)
|
||||||
{
|
{
|
||||||
size_t numtowrite;
|
size_t numtowrite;
|
||||||
connection_struct *conn = NULL;
|
|
||||||
unsigned int doff = 0;
|
unsigned int doff = 0;
|
||||||
size_t len = smb_len_large(inbuf);
|
size_t len = smb_len_large(inbuf);
|
||||||
struct smbXsrv_tcon *tcon;
|
uint16_t fnum;
|
||||||
|
struct smbXsrv_open *op = NULL;
|
||||||
|
struct files_struct *fsp = NULL;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
NTTIME now = 0;
|
|
||||||
|
|
||||||
if (is_encrypted_packet(sconn, inbuf)) {
|
if (is_encrypted_packet(sconn, inbuf)) {
|
||||||
/* Can't do this on encrypted
|
/* Can't do this on encrypted
|
||||||
@ -4622,19 +4622,30 @@ bool is_valid_writeX_buffer(struct smbd_server_connection *sconn,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = smb1srv_tcon_lookup(sconn->conn, SVAL(inbuf, smb_tid),
|
fnum = SVAL(inbuf, smb_vwv2);
|
||||||
now, &tcon);
|
status = smb1srv_open_lookup(sconn->conn,
|
||||||
|
fnum,
|
||||||
|
0, /* now */
|
||||||
|
&op);
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
DEBUG(10,("is_valid_writeX_buffer: bad tid\n"));
|
DEBUG(10,("is_valid_writeX_buffer: bad fnum\n"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
fsp = op->compat;
|
||||||
|
if (fsp == NULL) {
|
||||||
|
DEBUG(10,("is_valid_writeX_buffer: bad fsp\n"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (fsp->conn == NULL) {
|
||||||
|
DEBUG(10,("is_valid_writeX_buffer: bad fsp->conn\n"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
conn = tcon->compat;
|
|
||||||
|
|
||||||
if (IS_IPC(conn)) {
|
if (IS_IPC(fsp->conn)) {
|
||||||
DEBUG(10,("is_valid_writeX_buffer: IPC$ tid\n"));
|
DEBUG(10,("is_valid_writeX_buffer: IPC$ tid\n"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (IS_PRINT(conn)) {
|
if (IS_PRINT(fsp->conn)) {
|
||||||
DEBUG(10,("is_valid_writeX_buffer: printing tid\n"));
|
DEBUG(10,("is_valid_writeX_buffer: printing tid\n"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user