summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2008-01-26 10:39:21 +0100
committerVolker Lendecke <vl@samba.org>2008-02-02 11:03:23 +0100
commitb42a5d68a3ffd88fd60c64b6a75fe2d687d9c92d (patch)
treeb8e1b6e204742449977b1731649e99cfbd9da86a /source3
parent21e7344d2f45416ea996f88be72de1a923c0ee9c (diff)
downloadsamba-b42a5d68a3ffd88fd60c64b6a75fe2d687d9c92d.tar.gz
samba-b42a5d68a3ffd88fd60c64b6a75fe2d687d9c92d.tar.bz2
samba-b42a5d68a3ffd88fd60c64b6a75fe2d687d9c92d.zip
Convert read_data() to NTSTATUS
(This used to be commit af40b71023f8c4a2133d996ea698c72b97624043)
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/util_sock.c25
-rw-r--r--source3/nmbd/asyncdns.c19
-rw-r--r--source3/smbd/reply.c9
-rw-r--r--source3/winbindd/winbindd_dual.c20
4 files changed, 30 insertions, 43 deletions
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index ede2cdae71..25d539cace 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -1046,30 +1046,9 @@ NTSTATUS read_socket_with_timeout(int fd, char *buf,
Read data from the client, reading exactly N bytes.
****************************************************************************/
-ssize_t read_data(int fd,char *buffer,size_t N, enum smb_read_errors *pre)
+NTSTATUS read_data(int fd, char *buffer, size_t N)
{
- NTSTATUS status;
-
- set_smb_read_error(pre, SMB_READ_OK);
-
- status = read_socket_with_timeout(fd, buffer, N, N, 0, NULL);
-
- if (NT_STATUS_IS_OK(status)) {
- return N;
- }
-
- if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) {
- set_smb_read_error(pre, SMB_READ_EOF);
- return -1;
- }
-
- if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
- set_smb_read_error(pre, SMB_READ_TIMEOUT);
- return -1;
- }
-
- set_smb_read_error(pre, SMB_READ_ERROR);
- return -1;
+ return read_socket_with_timeout(fd, buffer, N, N, 0, NULL);
}
/****************************************************************************
diff --git a/source3/nmbd/asyncdns.c b/source3/nmbd/asyncdns.c
index 33c1cb6cb1..5e5565991e 100644
--- a/source3/nmbd/asyncdns.c
+++ b/source3/nmbd/asyncdns.c
@@ -87,8 +87,13 @@ static void asyncdns_process(void)
DEBUGLEVEL = -1;
while (1) {
- if (read_data(fd_in, (char *)&r, sizeof(r), NULL) != sizeof(r))
+ NTSTATUS status;
+
+ status = read_data(fd_in, (char *)&r, sizeof(r));
+
+ if (!NT_STATUS_IS_OK(status)) {
break;
+ }
pull_ascii_nstring( qname, sizeof(qname), r.name.name);
r.result.s_addr = interpret_addr(qname);
@@ -194,7 +199,7 @@ void run_dns_queue(void)
struct query_record r;
struct packet_struct *p, *p2;
struct name_record *namerec;
- int size;
+ NTSTATUS status;
if (fd_in == -1)
return;
@@ -208,11 +213,11 @@ void run_dns_queue(void)
start_async_dns();
}
- if ((size=read_data(fd_in, (char *)&r, sizeof(r), NULL)) != sizeof(r)) {
- if (size) {
- DEBUG(0,("Incomplete DNS answer from child!\n"));
- fd_in = -1;
- }
+ status = read_data(fd_in, (char *)&r, sizeof(r));
+
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("read from child failed: %s\n", nt_errstr(status)));
+ fd_in = -1;
BlockSignals(True, SIGTERM);
return;
}
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index f371dde705..bced8ed984 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -3516,11 +3516,12 @@ void reply_writebraw(struct smb_request *req)
(int)tcount,(int)nwritten,(int)numtowrite));
}
- if (read_data(smbd_server_fd(), buf+4, numtowrite, NULL)
- != numtowrite ) {
+ status = read_data(smbd_server_fd(), buf+4, numtowrite);
+
+ if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("reply_writebraw: Oversize secondary write "
- "raw read failed (%s). Terminating\n",
- strerror(errno) ));
+ "raw read failed (%s). Terminating\n",
+ nt_errstr(status)));
exit_server_cleanly("secondary writebraw failed");
}
diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c
index 1f2972f9b2..48f37af4d0 100644
--- a/source3/winbindd/winbindd_dual.c
+++ b/source3/winbindd/winbindd_dual.c
@@ -40,15 +40,16 @@ extern struct winbindd_methods cache_methods;
static void child_read_request(struct winbindd_cli_state *state)
{
- ssize_t len;
+ NTSTATUS status;
/* Read data */
- len = read_data(state->sock, (char *)&state->request,
- sizeof(state->request), NULL);
+ status = read_data(state->sock, (char *)&state->request,
+ sizeof(state->request));
- if (len != sizeof(state->request)) {
- DEBUG(len > 0 ? 0 : 3, ("Got invalid request length: %d\n", (int)len));
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(3, ("child_read_request: read_data failed: %s\n",
+ nt_errstr(status)));
state->finished = True;
return;
}
@@ -72,11 +73,12 @@ static void child_read_request(struct winbindd_cli_state *state)
/* Ensure null termination */
state->request.extra_data.data[state->request.extra_len] = '\0';
- len = read_data(state->sock, state->request.extra_data.data,
- state->request.extra_len, NULL);
+ status= read_data(state->sock, state->request.extra_data.data,
+ state->request.extra_len);
- if (len != state->request.extra_len) {
- DEBUG(0, ("Could not read extra data\n"));
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("Could not read extra data: %s\n",
+ nt_errstr(status)));
state->finished = True;
return;
}