]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
selftest: Add test for structure with NDR_BUFFERS only in a union
authorAndrew Bartlett <abartlet@samba.org>
Wed, 4 Dec 2019 01:46:32 +0000 (14:46 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 12 Dec 2019 02:30:39 +0000 (02:30 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13876

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
python/samba/tests/blackbox/ndrdump.py
selftest/knownfail.d/ndrdump-spoolss_EnumForms [new file with mode: 0644]

index 5e4b3bfbd8cea4346a378e6949f69aaab77de0db..e356e0eaa8012804706a0676f5fc29ba2a998bd9 100644 (file)
@@ -312,3 +312,41 @@ dump OK
         # check_output will return bytes
         # convert expected to bytes for python 3
         self.assertEqual(actual, expected.encode('utf-8'))
+
+    # This is a good example of a union with an empty default
+    # and no buffers to parse.
+    def test_ndrdump_fuzzed_spoolss_EnumForms(self):
+        expected_head = b'''pull returned Success
+WARNING! 2 unread bytes
+[0000] 00 00                                              .. ''' b'''
+    spoolss_EnumForms: struct spoolss_EnumForms
+        out: struct spoolss_EnumForms
+            count                    : *
+                count                    : 0x00000100 (256)
+            info                     : *
+                info                     : *
+                    info: ARRAY(256)
+                        info                     : union spoolss_FormInfo(case 0)
+                        info                     : union spoolss_FormInfo(case 0)
+'''
+        expected_tail = b'''info                     : union spoolss_FormInfo(case 0)
+                        info                     : union spoolss_FormInfo(case 0)
+                        info                     : union spoolss_FormInfo(case 0)
+                        info                     : union spoolss_FormInfo(case 0)
+                        info                     : union spoolss_FormInfo(case 0)
+                        info                     : union spoolss_FormInfo(case 0)
+            needed                   : *
+                needed                   : 0x00000000 (0)
+            result                   : DOS code 0xa9a9a900
+dump OK
+'''
+        try:
+            actual = self.check_output(
+                "ndrdump spoolss spoolss_EnumForms out --base64-input " +\
+                "--input AAAAAQAAAAAAAAAAAAEAAACpqakAAA="
+                )
+        except BlackboxProcessError as e:
+            self.fail(e)
+        self.assertEqual(actual[:len(expected_head)],
+                         expected_head)
+        self.assertTrue(actual.endswith(expected_tail))
diff --git a/selftest/knownfail.d/ndrdump-spoolss_EnumForms b/selftest/knownfail.d/ndrdump-spoolss_EnumForms
new file mode 100644 (file)
index 0000000..fc5c6b5
--- /dev/null
@@ -0,0 +1 @@
+^samba.tests.blackbox.ndrdump.samba.tests.blackbox.ndrdump.NdrDumpTests.test_ndrdump_fuzzed_spoolss_EnumForms