Rergression for printing a @map after calling clear().
authormpi <mpi@openbsd.org>
Wed, 1 Sep 2021 13:22:36 +0000 (13:22 +0000)
committermpi <mpi@openbsd.org>
Wed, 1 Sep 2021 13:22:36 +0000 (13:22 +0000)
Adapted from a test case generated by AFL++.

ok jasper@

regress/usr.sbin/btrace/Makefile
regress/usr.sbin/btrace/read-map-after-clear.bt [new file with mode: 0644]
regress/usr.sbin/btrace/read-map-after-clear.ok [new file with mode: 0644]

index 145512c..0e2aba1 100644 (file)
@@ -1,11 +1,11 @@
-# $OpenBSD: Makefile,v 1.11 2021/08/31 12:51:56 mpi Exp $
+# $OpenBSD: Makefile,v 1.12 2021/09/01 13:22:36 mpi Exp $
 
 BTRACE?=                /usr/sbin/btrace
 
 # scripts that don't need /dev/dt
 BT_LANG_SCRIPTS=       arithm beginend boolean comments delete exit if map \
                        map-unnamed maxoperand min+max+sum multismts nsecs+var \
-                       precedence print
+                       precedence print read-map-after-clear
 
 BT_KERN_SCRIPTS=
 
diff --git a/regress/usr.sbin/btrace/read-map-after-clear.bt b/regress/usr.sbin/btrace/read-map-after-clear.bt
new file mode 100644 (file)
index 0000000..7326691
--- /dev/null
@@ -0,0 +1,7 @@
+BEGIN
+{
+        @map[7] = 2;
+        clear(@map);
+        printf("=> Print after clear should not crash %d:\n", @map);
+}
+
diff --git a/regress/usr.sbin/btrace/read-map-after-clear.ok b/regress/usr.sbin/btrace/read-map-after-clear.ok
new file mode 100644 (file)
index 0000000..f1ede83
--- /dev/null
@@ -0,0 +1 @@
+=> Print after clear should not crash 0: