diff options
author | Stefan Metzmacher <metze@samba.org> | 2014-04-11 00:51:32 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2014-04-11 21:41:08 +0200 |
commit | 77b6860668437bbb3bb66f57f75ea4fc378de49b (patch) | |
tree | 6ec0b4f3508deac9516bceb83ea349c1243984f3 | |
parent | 8d45b75df31d5c382345186791a375e2b800066e (diff) | |
download | samba-77b6860668437bbb3bb66f57f75ea4fc378de49b.tar.gz samba-77b6860668437bbb3bb66f57f75ea4fc378de49b.tar.xz samba-77b6860668437bbb3bb66f57f75ea4fc378de49b.zip |
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>
-rw-r--r-- | source3/smbd/reply.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index e58735ed93..da59ca75ae 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -4598,12 +4598,12 @@ bool is_valid_writeX_buffer(struct smbd_server_connection *sconn, const uint8_t *inbuf) { size_t numtowrite; - connection_struct *conn = NULL; unsigned int doff = 0; 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; - NTTIME now = 0; if (is_encrypted_packet(sconn, inbuf)) { /* Can't do this on encrypted @@ -4622,19 +4622,30 @@ bool is_valid_writeX_buffer(struct smbd_server_connection *sconn, return false; } - status = smb1srv_tcon_lookup(sconn->conn, SVAL(inbuf, smb_tid), - now, &tcon); + fnum = SVAL(inbuf, smb_vwv2); + status = smb1srv_open_lookup(sconn->conn, + fnum, + 0, /* now */ + &op); 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; } - conn = tcon->compat; - if (IS_IPC(conn)) { + if (IS_IPC(fsp->conn)) { DEBUG(10,("is_valid_writeX_buffer: IPC$ tid\n")); return false; } - if (IS_PRINT(conn)) { + if (IS_PRINT(fsp->conn)) { DEBUG(10,("is_valid_writeX_buffer: printing tid\n")); return false; } |