From 3e5b98555b832772d6fe93a57005bc39222a5189 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 25 Jan 2008 21:02:52 +0100 Subject: Convert read_smb_length_return_keepalive to read_socket_with_timeout_ntstatus (This used to be commit 59e8f22f36be5a70fdb101964570ce7c10e8ff65) --- source3/lib/util_sock.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index f61cdb151e..d32d67f2fc 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -1146,10 +1146,27 @@ ssize_t read_smb_length_return_keepalive(int fd, unsigned int timeout, enum smb_read_errors *pre) { - ssize_t len=0; + size_t len=0; int msg_type; + NTSTATUS status; + + set_smb_read_error(pre, SMB_READ_OK); + + status = read_socket_with_timeout_ntstatus(fd, inbuf, 4, 4, timeout, + NULL); + + if (!NT_STATUS_IS_OK(status)) { + 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; + } - if (read_socket_with_timeout(fd, inbuf, 4, 4, timeout, pre) != 4) { + set_smb_read_error(pre, SMB_READ_ERROR); return -1; } -- cgit