summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2008-01-25 23:18:56 +0100
committerVolker Lendecke <vl@samba.org>2008-02-02 11:03:22 +0100
commit9fe66ddd15b3c5b5d9a30fc79d6ed6cdb31cae12 (patch)
tree69ba8c022866a3c7d66a4a6444da90ef8d9a0d06 /source3
parent250b2b6464521fa4e2b5c737164e1ce68755677f (diff)
downloadsamba-9fe66ddd15b3c5b5d9a30fc79d6ed6cdb31cae12.tar.gz
samba-9fe66ddd15b3c5b5d9a30fc79d6ed6cdb31cae12.tar.bz2
samba-9fe66ddd15b3c5b5d9a30fc79d6ed6cdb31cae12.zip
Convert receive_smb_raw_talloc to NTSTATUS
(This used to be commit 187707591ffa2668aecd4857cb2ef2cd20bd6b08)
Diffstat (limited to 'source3')
-rw-r--r--source3/smbd/process.c90
1 files changed, 29 insertions, 61 deletions
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 10ef67c2b2..cb7d12a0c3 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -268,37 +268,21 @@ static NTSTATUS receive_smb_raw_talloc_partial_read(TALLOC_CTX *mem_ctx,
return NT_STATUS_OK;
}
-static ssize_t receive_smb_raw_talloc(TALLOC_CTX *mem_ctx,
- int fd,
- char **buffer,
- unsigned int timeout,
- size_t *p_unread)
+static NTSTATUS receive_smb_raw_talloc(TALLOC_CTX *mem_ctx, int fd,
+ char **buffer, unsigned int timeout,
+ size_t *p_unread, size_t *plen)
{
char lenbuf[4];
size_t len;
int min_recv_size = lp_min_receive_file_size();
NTSTATUS status;
- set_smb_read_error(get_srv_read_error(),SMB_READ_OK);
*p_unread = 0;
status = read_smb_length_return_keepalive(fd, lenbuf, timeout, &len);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(10, ("receive_smb_raw: %s\n", nt_errstr(status)));
-
- if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) {
- set_smb_read_error(get_srv_read_error(), SMB_READ_EOF);
- return -1;
- }
-
- if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
- set_smb_read_error(get_srv_read_error(),
- SMB_READ_TIMEOUT);
- return -1;
- }
-
- set_smb_read_error(get_srv_read_error(), SMB_READ_ERROR);
- return -1;
+ return status;
}
if (CVAL(lenbuf,0) == 0 &&
@@ -310,31 +294,14 @@ static ssize_t receive_smb_raw_talloc(TALLOC_CTX *mem_ctx,
mem_ctx, lenbuf, fd, buffer, timeout, p_unread, &len);
if (!NT_STATUS_IS_OK(status)) {
-
DEBUG(10, ("receive_smb_raw: %s\n",
nt_errstr(status)));
-
- if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) {
- set_smb_read_error(get_srv_read_error(),
- SMB_READ_EOF);
- return -1;
- }
-
- if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
- set_smb_read_error(get_srv_read_error(),
- SMB_READ_TIMEOUT);
- return -1;
- }
-
- set_smb_read_error(get_srv_read_error(),
- SMB_READ_ERROR);
- return -1;
+ return status;
}
}
if (!valid_packet_size(len)) {
- cond_set_smb_read_error(get_srv_read_error(),SMB_READ_ERROR);
- return -1;
+ return NT_STATUS_INVALID_PARAMETER;
}
/*
@@ -346,32 +313,18 @@ static ssize_t receive_smb_raw_talloc(TALLOC_CTX *mem_ctx,
if (*buffer == NULL) {
DEBUG(0, ("Could not allocate inbuf of length %d\n",
(int)len+4));
- cond_set_smb_read_error(get_srv_read_error(),SMB_READ_ERROR);
- return -1;
+ return NT_STATUS_NO_MEMORY;
}
memcpy(*buffer, lenbuf, sizeof(lenbuf));
status = read_packet_remainder(fd, (*buffer)+4, timeout, len);
if (!NT_STATUS_IS_OK(status)) {
- if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) {
- set_smb_read_error(get_srv_read_error(),
- SMB_READ_EOF);
- return -1;
- }
-
- if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
- set_smb_read_error(get_srv_read_error(),
- SMB_READ_TIMEOUT);
- return -1;
- }
-
- set_smb_read_error(get_srv_read_error(),
- SMB_READ_ERROR);
- return -1;
+ return status;
}
- return len + 4;
+ *plen = len + 4;
+ return NT_STATUS_OK;
}
static ssize_t receive_smb_talloc(TALLOC_CTX *mem_ctx,
@@ -381,18 +334,33 @@ static ssize_t receive_smb_talloc(TALLOC_CTX *mem_ctx,
size_t *p_unread,
bool *p_encrypted)
{
- ssize_t len;
+ size_t len;
+ NTSTATUS status;
*p_encrypted = false;
- len = receive_smb_raw_talloc(mem_ctx, fd, buffer, timeout, p_unread);
+ set_smb_read_error(get_srv_read_error(), SMB_READ_OK);
+
+ status = receive_smb_raw_talloc(mem_ctx, fd, buffer, timeout,
+ p_unread, &len);
+ if (!NT_STATUS_IS_OK(status)) {
+ if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) {
+ set_smb_read_error(get_srv_read_error(), SMB_READ_EOF);
+ return -1;
+ }
+
+ if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
+ set_smb_read_error(get_srv_read_error(),
+ SMB_READ_TIMEOUT);
+ return -1;
+ }
- if (len < 0) {
+ set_smb_read_error(get_srv_read_error(), SMB_READ_ERROR);
return -1;
}
if (is_encrypted_packet((uint8_t *)*buffer)) {
- NTSTATUS status = srv_decrypt_buffer(*buffer);
+ status = srv_decrypt_buffer(*buffer);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("receive_smb_talloc: SMB decryption failed on "
"incoming packet! Error %s\n",