s4:torture:vfs: fix Invalid read of size 8 valgrind valgrind error (and segv)
authorNoel Power <noel.power@suse.com>
Wed, 20 Apr 2016 13:49:44 +0000 (14:49 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Mon, 25 Apr 2016 08:35:16 +0000 (10:35 +0200)
when running smbtorture test
'vfs.fruit.SMB2/CREATE context AAPL.SMB2/CREATE context AAPL'
(on non-osx system) the following valgrind errors occur

==2419== Invalid read of size 8
==2419==    at 0x4055EA: test_aapl (fruit.c:1939)
==2419==    by 0x48B452: wrap_simple_1smb2_test (smb2.c:52)
==2419==    by 0x955368F: internal_torture_run_test (torture.c:442)
==2419==    by 0x9553A6B: torture_run_test_restricted (torture.c:542)
==2419==    by 0x26013F: run_matching (smbtorture.c:110)
==2419==    by 0x260001: run_matching (smbtorture.c:95)
==2419==    by 0x260001: run_matching (smbtorture.c:95)
==2419==    by 0x260260: torture_run_named_tests (smbtorture.c:143)
==2419==    by 0x261EDF: main (smbtorture.c:665)
==2419==  Address 0x10 is not stack'd, malloc'd or (recently) free'd
==2419==
===============================================================
INTERNAL ERROR: Signal 11 in pid 2419 (4.2.4)
Please read the Trouble-Shooting section of the Samba HOWTO
===============================================================
PANIC: internal error

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source4/torture/vfs/fruit.c

index ae978c2e84631ffe3b0288412a649ed94eb317bc..020bd1f42d86d8202bc4870bf4db32dc151f380a 100644 (file)
@@ -1936,6 +1936,14 @@ static bool test_aapl(struct torture_context *tctx,
        aapl = smb2_create_blob_find(&io.out.blobs,
                                     SMB2_CREATE_TAG_AAPL);
 
+       if (aapl == NULL) {
+               torture_result(tctx, TORTURE_FAIL,
+                              "(%s) unexpectedly no AAPL capabilities were returned.",
+                              __location__);
+               ret = false;
+               goto done;
+       }
+
        if (aapl->data.length != 50) {
                /*
                 * uint32_t CommandCode = kAAPL_SERVER_QUERY