mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
parent
21e7344d2f
commit
b42a5d68a3
@ -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);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user