summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2022-04-24 13:34:54 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2022-04-24 13:34:54 +0000
commit04d198e5b66cf644f9fbb2ac1d70f4498d13b6c3 (patch)
tree03e1a12597089f9ee2c3cde84249428c0382572c /regress
parent55c1309fa3a9c1f4e5a4acad95f6ed6dd4da35d3 (diff)
If a .shift request has a negative argument, do not use a negative array
index but use 0 instead of the argument, just like groff. Warn about the invalid argument. While here, fix the column number in another warning message. Segfault reported by tb@, found with afl(1).
Diffstat (limited to 'regress')
-rw-r--r--regress/usr.bin/mandoc/roff/shift/bad.in8
-rw-r--r--regress/usr.bin/mandoc/roff/shift/bad.out_ascii6
-rw-r--r--regress/usr.bin/mandoc/roff/shift/bad.out_lint5
3 files changed, 13 insertions, 6 deletions
diff --git a/regress/usr.bin/mandoc/roff/shift/bad.in b/regress/usr.bin/mandoc/roff/shift/bad.in
index 809832defd8..22eff7e0c3c 100644
--- a/regress/usr.bin/mandoc/roff/shift/bad.in
+++ b/regress/usr.bin/mandoc/roff/shift/bad.in
@@ -1,5 +1,5 @@
-.\" $OpenBSD: bad.in,v 1.1 2018/08/23 14:16:12 schwarze Exp $
-.TH SHIFT_BAD 1 "August 23, 2018"
+.\" $OpenBSD: bad.in,v 1.2 2022/04/24 13:34:53 schwarze Exp $
+.TH SHIFT_BAD 1 "April 24, 2022"
.SH NAME
.B shift-bad
\(en wrong usage of macro arguments
@@ -22,6 +22,10 @@ argument used after call: "\$1"
.de mym
.shift badarg
after shift badarg: "\\$1"
+.br
+.shift -1
+after shift \-1: "\\$1"
+.br
.shift 2
after excessive shift: \\n(.$ "\\$1"
..
diff --git a/regress/usr.bin/mandoc/roff/shift/bad.out_ascii b/regress/usr.bin/mandoc/roff/shift/bad.out_ascii
index 2d6a2922c2f..ddb8c521aff 100644
--- a/regress/usr.bin/mandoc/roff/shift/bad.out_ascii
+++ b/regress/usr.bin/mandoc/roff/shift/bad.out_ascii
@@ -14,8 +14,10 @@ DDEESSCCRRIIPPTTIIOONN
argument used after call: ""
- after shift badarg: "arg2" after excessive shift: 0 ""
+ after shift badarg: "arg2"
+ after shift -1: "arg2"
+ after excessive shift: 0 ""
final text
-OpenBSD August 23, 2018 SHIFT_BAD(1)
+OpenBSD April 24, 2022 SHIFT_BAD(1)
diff --git a/regress/usr.bin/mandoc/roff/shift/bad.out_lint b/regress/usr.bin/mandoc/roff/shift/bad.out_lint
index 1f696fc8681..b122415e989 100644
--- a/regress/usr.bin/mandoc/roff/shift/bad.out_lint
+++ b/regress/usr.bin/mandoc/roff/shift/bad.out_lint
@@ -3,5 +3,6 @@ mandoc: bad.in:15:2: ERROR: ignoring request outside macro: shift
mandoc: bad.in:17:31: ERROR: argument number is not numeric: \$x
mandoc: bad.in:19:28: ERROR: using macro argument outside macro: \$1
mandoc: bad.in:20:2: ERROR: ignoring request outside macro: shift
-mandoc: bad.in:28:8: ERROR: argument is not numeric, using 1: shift badarg
-mandoc: bad.in:28:9: ERROR: excessive shift: 2, but max is 1
+mandoc: bad.in:32:8: ERROR: argument is not numeric, using 1: shift badarg
+mandoc: bad.in:32:8: ERROR: negative argument, using 0: shift -1
+mandoc: bad.in:32:8: ERROR: excessive shift: 2, but max is 1