summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2008-01-25 22:27:59 +0100
committerVolker Lendecke <vl@samba.org>2008-02-02 11:03:22 +0100
commite604e137e21af52efdbabc28863a5ea76d8d620d (patch)
tree96927cd902b3aeaee2ab9ec70cefaeda9a1a1f58
parent48b1ee61db5f513321b7f3360eb17f94ef339872 (diff)
downloadsamba-e604e137e21af52efdbabc28863a5ea76d8d620d.tar.gz
samba-e604e137e21af52efdbabc28863a5ea76d8d620d.tar.bz2
samba-e604e137e21af52efdbabc28863a5ea76d8d620d.zip
Convert read_packet_remainder to return NTSTATUS
(This used to be commit 667864d442ea7e1faed7b032315db8856fa91481)
-rw-r--r--source3/smbd/process.c81
1 files changed, 44 insertions, 37 deletions
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 02b190f003..4d9a90a840 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -143,39 +143,15 @@ static bool valid_packet_size(size_t len)
return true;
}
-static ssize_t read_packet_remainder(int fd,
- char *buffer,
- unsigned int timeout,
- ssize_t len)
+static NTSTATUS read_packet_remainder(int fd, char *buffer,
+ unsigned int timeout, ssize_t len)
{
- NTSTATUS status;
-
if (len <= 0) {
- return len;
- }
-
- set_smb_read_error(get_srv_read_error(), SMB_READ_OK);
-
- status = read_socket_with_timeout_ntstatus(fd, buffer, len, len,
- timeout, NULL);
-
- if (NT_STATUS_IS_OK(status)) {
- return len;
- }
-
- if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) {
- set_smb_read_error(get_srv_read_error(), SMB_READ_EOF);
- return -1;
+ return NT_STATUS_OK;
}
- 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 read_socket_with_timeout_ntstatus(fd, buffer, len, len,
+ timeout, NULL);
}
/****************************************************************************
@@ -293,11 +269,29 @@ static ssize_t receive_smb_raw_talloc_partial_read(TALLOC_CTX *mem_ctx,
toread = len - STANDARD_WRITE_AND_X_HEADER_SIZE;
if(toread > 0) {
- ret = read_packet_remainder(fd,
- (*buffer) + 4 + STANDARD_WRITE_AND_X_HEADER_SIZE,
- timeout,
- toread);
- if (ret != toread) {
+ NTSTATUS status;
+
+ set_smb_read_error(get_srv_read_error(), SMB_READ_OK);
+
+ status = read_packet_remainder(
+ fd, (*buffer) + 4 + STANDARD_WRITE_AND_X_HEADER_SIZE,
+ timeout, toread);
+
+ 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;
}
}
@@ -313,7 +307,6 @@ static ssize_t receive_smb_raw_talloc(TALLOC_CTX *mem_ctx,
{
char lenbuf[4];
size_t len;
- ssize_t ret;
int min_recv_size = lp_min_receive_file_size();
NTSTATUS status;
@@ -371,8 +364,22 @@ static ssize_t receive_smb_raw_talloc(TALLOC_CTX *mem_ctx,
memcpy(*buffer, lenbuf, sizeof(lenbuf));
- ret = read_packet_remainder(fd, (*buffer)+4, timeout, len);
- if (ret != len) {
+ 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;
}