s3: Fix a NULL pointer dereference
authorVolker Lendecke <vl@samba.org>
Tue, 9 Mar 2010 10:14:14 +0000 (11:14 +0100)
committerKarolin Seeger <kseeger@samba.org>
Mon, 29 Mar 2010 07:41:00 +0000 (09:41 +0200)
Found by Laurent Gaffie <laurent.gaffie@gmail.com>.

Thanks!

Volker
(cherry picked from commit 25452a2268ac7013da28125f3df22085139af12d)

Fix bug #7229 (NULL pointer dereference).
(cherry picked from commit bf40d130a1761daa14ce6a2cf3d02dbd9095c2b5)

source3/smbd/process.c

index 572f37dbbebbdbc211ad20ee78cfb471f4a2f9ab..3367d70a82734ecae229419fef2be5176765acaf 100644 (file)
@@ -1812,6 +1812,15 @@ void chain_reply(struct smb_request *req)
         */
 
        if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) {
+               if (req->chain_outbuf == NULL) {
+                       req->chain_outbuf = TALLOC_REALLOC_ARRAY(
+                               req, req->outbuf, uint8_t,
+                               smb_len(req->outbuf) + 4);
+                       if (req->chain_outbuf == NULL) {
+                               smb_panic("talloc failed");
+                       }
+               }
+               req->outbuf = NULL;
                goto error;
        }
 
@@ -1839,7 +1848,7 @@ void chain_reply(struct smb_request *req)
                req->chain_outbuf = TALLOC_REALLOC_ARRAY(
                        req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4);
                if (req->chain_outbuf == NULL) {
-                       goto error;
+                       smb_panic("talloc failed");
                }
                req->outbuf = NULL;
        } else {