The branch, master has been updated
       via  61953ab s3: Simplify smb_splice_chain
       via  b07ae1a s3: Simplify smb_splice_chain
       via  4708b97 s3: Simplify smb_splice_chain
       via  5b7609d s3: Simplify smb_splice_chain
       via  da322e4 s3: Simplify smb_splice_chain
       via  947a8bc s3: Turn some SMB_ASSERTS into proper return
       via  28901ac s3: Fix a DEBUG msg
      from  a1849da upgradedns: Rename to less generic name samba_upgradedns.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 61953ab35a59611e307d684a5f8dfa165e95053d
Author: Volker Lendecke <v...@samba.org>
Date:   Fri Feb 24 16:16:23 2012 +0100

    s3: Simplify smb_splice_chain
    
    No code change, just remove a {} block left over as the else branch
    from the previous commit
    
    Autobuild-User: Volker Lendecke <v...@samba.org>
    Autobuild-Date: Fri Feb 24 18:07:48 CET 2012 on sn-devel-104

commit b07ae1ab7b19d033e19c4b78c375c608f22548b3
Author: Volker Lendecke <v...@samba.org>
Date:   Fri Feb 24 16:16:23 2012 +0100

    s3: Simplify smb_splice_chain
    
    first_request won't be true anymore, we always splice fully existing
    records in smbd

commit 4708b97ce56d40f5956d88289699fc7139b663f1
Author: Volker Lendecke <v...@samba.org>
Date:   Fri Feb 24 16:16:23 2012 +0100

    s3: Simplify smb_splice_chain
    
    With the last commit, bytes_padding is not set anymore

commit 5b7609db56799daf781cf81666e93a3417ad77f2
Author: Volker Lendecke <v...@samba.org>
Date:   Fri Feb 24 16:16:23 2012 +0100

    s3: Simplify smb_splice_chain
    
    bytes_alignment used to be used in libsmb, which uses different code
    now

commit da322e4f3f0967bd65ec0f4cfbea83d9e8ccd77e
Author: Volker Lendecke <v...@samba.org>
Date:   Fri Feb 24 16:16:23 2012 +0100

    s3: Simplify smb_splice_chain
    
    We use it in smbd/process.c only now. This only splices in finished
    buffers, both callers used the same arguments. Pull that into the
    routine itself.

commit 947a8bc44afc47961e2477ce0b7d8a16573b0f97
Author: Volker Lendecke <v...@samba.org>
Date:   Fri Feb 24 16:02:02 2012 +0100

    s3: Turn some SMB_ASSERTS into proper return
    
    We deal with the error properly further up

commit 28901acd27bb7b1bfc19ad1a7e0167d55124682c
Author: Volker Lendecke <v...@samba.org>
Date:   Fri Feb 24 15:45:37 2012 +0100

    s3: Fix a DEBUG msg

-----------------------------------------------------------------------

Summary of changes:
 source3/smbd/process.c |  108 +++++++++++++++---------------------------------
 1 files changed, 34 insertions(+), 74 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 3cb44c4..391ddc7 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -1745,7 +1745,9 @@ static bool find_andx_cmd_ofs(uint8_t *buf, size_t *pofs)
 
        cmd = CVAL(buf, smb_com);
 
-       SMB_ASSERT(is_andx_req(cmd));
+       if (!is_andx_req(cmd)) {
+               return false;
+       }
 
        ofs = smb_vwv0;
 
@@ -1761,7 +1763,9 @@ static bool find_andx_cmd_ofs(uint8_t *buf, size_t *pofs)
                 */
                ofs = SVAL(buf, ofs+2) + 4 + 1;
 
-               SMB_ASSERT(ofs+4 < talloc_get_size(buf));
+               if (ofs+4 >= talloc_get_size(buf)) {
+                       return false;
+               }
        }
 
        *pofs = ofs;
@@ -1771,39 +1775,27 @@ static bool find_andx_cmd_ofs(uint8_t *buf, size_t 
*pofs)
 /**
  * @brief Do the smb chaining at a buffer level
  * @param[in] poutbuf          Pointer to the talloc'ed buffer to be modified
- * @param[in] smb_command      The command that we want to issue
- * @param[in] wct              How many words?
- * @param[in] vwv              The words, already in network order
- * @param[in] bytes_alignment  How shall we align "bytes"?
- * @param[in] num_bytes                How many bytes?
- * @param[in] bytes            The data the request ships
- *
- * smb_splice_chain() adds the vwv and bytes to the request already present in
- * *poutbuf.
+ * @param[in] andx_buf         Buffer to be appended
  */
 
-static bool smb_splice_chain(uint8_t **poutbuf, uint8_t smb_command,
-                            uint8_t wct, const uint16_t *vwv,
-                            size_t bytes_alignment,
-                            uint32_t num_bytes, const uint8_t *bytes)
+static bool smb_splice_chain(uint8_t **poutbuf, const uint8_t *andx_buf)
 {
+       uint8_t smb_command     = CVAL(andx_buf, smb_com);
+       uint8_t wct             = CVAL(andx_buf, smb_wct);
+       const uint16_t *vwv     = (const uint16_t *)(andx_buf + smb_vwv);
+       uint32_t num_bytes      = smb_buflen(andx_buf);
+       const uint8_t *bytes    = (const uint8_t *)smb_buf(andx_buf);
+
        uint8_t *outbuf;
        size_t old_size, new_size;
        size_t ofs;
        size_t chain_padding = 0;
-       size_t bytes_padding = 0;
-       bool first_request;
-
-       old_size = talloc_get_size(*poutbuf);
+       size_t andx_cmd_ofs;
 
-       /*
-        * old_size == smb_wct means we're pushing the first request in for
-        * libsmb/
-        */
 
-       first_request = (old_size == smb_wct);
+       old_size = talloc_get_size(*poutbuf);
 
-       if (!first_request && ((old_size % 4) != 0)) {
+       if ((old_size % 4) != 0) {
                /*
                 * Align the wct field of subsequent requests to a 4-byte
                 * boundary
@@ -1813,20 +1805,14 @@ static bool smb_splice_chain(uint8_t **poutbuf, uint8_t 
smb_command,
 
        /*
         * After the old request comes the new wct field (1 byte), the vwv's
-        * and the num_bytes field. After at we might need to align the bytes
-        * given to us to "bytes_alignment", increasing the num_bytes value.
+        * and the num_bytes field.
         */
 
        new_size = old_size + chain_padding + 1 + wct * sizeof(uint16_t) + 2;
-
-       if ((bytes_alignment != 0) && ((new_size % bytes_alignment) != 0)) {
-               bytes_padding = bytes_alignment - (new_size % bytes_alignment);
-       }
-
-       new_size += bytes_padding + num_bytes;
+       new_size += num_bytes;
 
        if ((smb_command != SMBwriteX) && (new_size > 0xffff)) {
-               DEBUG(1, ("splice_chain: %u bytes won't fit\n",
+               DEBUG(1, ("smb_splice_chain: %u bytes won't fit\n",
                          (unsigned)new_size));
                return false;
        }
@@ -1838,27 +1824,20 @@ static bool smb_splice_chain(uint8_t **poutbuf, uint8_t 
smb_command,
        }
        *poutbuf = outbuf;
 
-       if (first_request) {
-               SCVAL(outbuf, smb_com, smb_command);
-       } else {
-               size_t andx_cmd_ofs;
-
-               if (!find_andx_cmd_ofs(outbuf, &andx_cmd_ofs)) {
-                       DEBUG(1, ("invalid command chain\n"));
-                       *poutbuf = talloc_realloc(
-                               NULL, *poutbuf, uint8_t, old_size);
-                       return false;
-               }
-
-               if (chain_padding != 0) {
-                       memset(outbuf + old_size, 0, chain_padding);
-                       old_size += chain_padding;
-               }
+       if (!find_andx_cmd_ofs(outbuf, &andx_cmd_ofs)) {
+               DEBUG(1, ("invalid command chain\n"));
+               *poutbuf = talloc_realloc(NULL, *poutbuf, uint8_t, old_size);
+               return false;
+       }
 
-               SCVAL(outbuf, andx_cmd_ofs, smb_command);
-               SSVAL(outbuf, andx_cmd_ofs + 2, old_size - 4);
+       if (chain_padding != 0) {
+               memset(outbuf + old_size, 0, chain_padding);
+               old_size += chain_padding;
        }
 
+       SCVAL(outbuf, andx_cmd_ofs, smb_command);
+       SSVAL(outbuf, andx_cmd_ofs + 2, old_size - 4);
+
        ofs = old_size;
 
        /*
@@ -1881,19 +1860,10 @@ static bool smb_splice_chain(uint8_t **poutbuf, uint8_t 
smb_command,
         * bcc (byte count)
         */
 
-       SSVAL(outbuf, ofs, num_bytes + bytes_padding);
+       SSVAL(outbuf, ofs, num_bytes);
        ofs += sizeof(uint16_t);
 
        /*
-        * padding
-        */
-
-       if (bytes_padding != 0) {
-               memset(outbuf + ofs, 0, bytes_padding);
-               ofs += bytes_padding;
-       }
-
-       /*
         * The bytes field
         */
 
@@ -1979,12 +1949,7 @@ void chain_reply(struct smb_request *req)
                SSVAL(req->chain_outbuf, smb_tid, SVAL(req->outbuf, smb_tid));
                SSVAL(req->chain_outbuf, smb_uid, SVAL(req->outbuf, smb_uid));
 
-               if (!smb_splice_chain(&req->chain_outbuf,
-                                     CVAL(req->outbuf, smb_com),
-                                     CVAL(req->outbuf, smb_wct),
-                                     (uint16_t *)(req->outbuf + smb_vwv),
-                                     0, smb_buflen(req->outbuf),
-                                     (uint8_t *)smb_buf(req->outbuf))) {
+               if (!smb_splice_chain(&req->chain_outbuf, req->outbuf)) {
                        goto error;
                }
                TALLOC_FREE(req->outbuf);
@@ -2140,12 +2105,7 @@ void chain_reply(struct smb_request *req)
        SSVAL(req->chain_outbuf, smb_rcls, SVAL(req->outbuf, smb_rcls));
        SSVAL(req->chain_outbuf, smb_err, SVAL(req->outbuf, smb_err));
 
-       if (!smb_splice_chain(&req->chain_outbuf,
-                             CVAL(req->outbuf, smb_com),
-                             CVAL(req->outbuf, smb_wct),
-                             (uint16_t *)(req->outbuf + smb_vwv),
-                             0, smb_buflen(req->outbuf),
-                             (uint8_t *)smb_buf(req->outbuf))) {
+       if (!smb_splice_chain(&req->chain_outbuf, req->outbuf)) {
                exit_server_cleanly("chain_reply: smb_splice_chain failed\n");
        }
        TALLOC_FREE(req->outbuf);


-- 
Samba Shared Repository

Reply via email to