summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2010-11-27 20:52:34 +0000
committerschwarze <schwarze@openbsd.org>2010-11-27 20:52:34 +0000
commit4dcc0b9a900ed55625ee8548cdc52cecf5a398e8 (patch)
treeaaef420c111546facfba88a89c4deb3906ab5244
parentRework the way saved registers are displayed in arm backtraces, to yield a (diff)
downloadwireguard-openbsd-4dcc0b9a900ed55625ee8548cdc52cecf5a398e8.tar.xz
wireguard-openbsd-4dcc0b9a900ed55625ee8548cdc52cecf5a398e8.zip
Two related bugfixes:
1) When using a user-defined string of length 0 as a macro, do not access memory before the start of the string (segfault). 2) When beginning to define a user-defined macro, initialize the string representing the macro to the empty string, not to the NULL pointer, such that, in case the macro turns out to not have any content, like in .de IX .. the macro will be defined and empty instead of undefined. This avoids large numbers of bogus mandoc ERROR messages about undefined macros (which are actually defined and empty), in particular in man(7) code generated from pod2man(1), for example in Perl and OpenSSL.
-rw-r--r--usr.bin/mandoc/roff.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c
index 8c5973e7307..a9bc0937dca 100644
--- a/usr.bin/mandoc/roff.c
+++ b/usr.bin/mandoc/roff.c
@@ -1,4 +1,4 @@
-/* $Id: roff.c,v 1.18 2010/11/25 23:07:58 schwarze Exp $ */
+/* $Id: roff.c,v 1.19 2010/11/27 20:52:34 schwarze Exp $ */
/*
* Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -642,7 +642,7 @@ roff_block(ROFF_ARGS)
* added from roff_block_text() in multiline mode.
*/
if (ROFF_de == tok)
- roff_setstr(r, name, NULL, 0);
+ roff_setstr(r, name, "", 0);
if ('\0' == (*bufp)[pos])
return(ROFF_IGN);
@@ -1140,7 +1140,7 @@ roff_userdef(ROFF_ARGS)
if (0 == *szp)
*szp = strlen(*bufp) + 1;
- return(*szp && '\n' == (*bufp)[(int)*szp - 2] ?
+ return(*szp > 1 && '\n' == (*bufp)[(int)*szp - 2] ?
ROFF_REPARSE : ROFF_APPEND);
}