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>
Thu, 6 May 2010 12:08:30 +0000 (14:08 +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)
(cherry picked from commit 6e8c643688a323c9a68baa9f015cffec65d75115)

source3/smbd/process.c

index b4976f77f8d7c942df9841305fec1e7132749d2a..2abea8f4bcc3fd96d30a0f7f3331f8fb810687c9 100644 (file)
@@ -1604,6 +1604,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;
        }
 
@@ -1631,7 +1640,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 {