Convert read_smb_length to return NTSTATUS
authorVolker Lendecke <vl@samba.org>
Fri, 25 Jan 2008 20:31:40 +0000 (21:31 +0100)
committerVolker Lendecke <vl@samba.org>
Sat, 2 Feb 2008 10:03:21 +0000 (11:03 +0100)
(This used to be commit 5750c3a51b4ddac635a98195d1621b24f91bad3f)

source3/lib/util_sock.c
source3/smbd/reply.c

index f62b20b6fcaccd201ebeec5e979a3a69740ee3ef..32dd2bd8a8fc6dc0e7e54a43a459f1bb2990d5ea 100644 (file)
@@ -1174,31 +1174,18 @@ NTSTATUS read_smb_length_return_keepalive(int fd, char *inbuf,
  Timeout is in milliseconds.
 ****************************************************************************/
 
-ssize_t read_smb_length(int fd, char *inbuf, unsigned int timeout, enum smb_read_errors *pre)
+NTSTATUS read_smb_length(int fd, char *inbuf, unsigned int timeout,
+                        size_t *len)
 {
-       size_t len;
        uint8_t msgtype = SMBkeepalive;
 
-       set_smb_read_error(pre, SMB_READ_OK);
-
        while (msgtype == SMBkeepalive) {
                NTSTATUS status;
 
                status = read_smb_length_return_keepalive(fd, inbuf, timeout,
-                                                         &len);
+                                                         len);
                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;
-                       }
-
-                       set_smb_read_error(pre, SMB_READ_ERROR);
-                       return -1;
+                       return status;
                }
 
                msgtype = CVAL(inbuf, 0);
@@ -1207,7 +1194,7 @@ ssize_t read_smb_length(int fd, char *inbuf, unsigned int timeout, enum smb_read
        DEBUG(10,("read_smb_length: got smb length of %lu\n",
                  (unsigned long)len));
 
-       return len;
+       return NT_STATUS_OK;
 }
 
 /****************************************************************************
index 18376031eca23711b747384326c7d63912ff780c..46c14d158eef2e0827bcc7a20cd2c157dde0a705 100644 (file)
@@ -3492,18 +3492,12 @@ void reply_writebraw(struct smb_request *req)
        }
 
        /* Now read the raw data into the buffer and write it */
-       if (read_smb_length(smbd_server_fd(),buf,
-                       SMB_SECONDARY_WAIT, get_srv_read_error()) == -1) {
+       status = read_smb_length(smbd_server_fd(), buf, SMB_SECONDARY_WAIT,
+                                &numtowrite);
+       if (!NT_STATUS_IS_OK(status)) {
                exit_server_cleanly("secondary writebraw failed");
        }
 
-       /*
-        * Even though this is not an smb message,
-        * smb_len returns the generic length of a packet.
-        */
-
-       numtowrite = smb_len(buf);
-
        /* Set up outbuf to return the correct size */
        reply_outbuf(req, 1, 0);