aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/man_term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2011-12-04 00:44:12 +0000
committerIngo Schwarze <schwarze@openbsd.org>2011-12-04 00:44:12 +0000
commit7c0b7e474e29ae0b4e927c6d06ad2881e2f95eec (patch)
treedaded8457cd9a70770363a061aaa716956a0c353 /man_term.c
parent0f10c53eb575a6891b9d903803ee9f23251f36fd (diff)
downloadmandoc-7c0b7e474e29ae0b4e927c6d06ad2881e2f95eec.tar.gz
mandoc-7c0b7e474e29ae0b4e927c6d06ad2881e2f95eec.tar.zst
mandoc-7c0b7e474e29ae0b4e927c6d06ad2881e2f95eec.zip
Jumping out of man_unscope() for the root node is a bad idea
because that will skip root node validation, potentially entering rendering modules will NULL pointers lurking in the meta data. Instead, always validate the root node and (as suggested by joerg@) assert validity of the meta data before using it in the renderers. ok joerg@
Diffstat (limited to 'man_term.c')
-rw-r--r--man_term.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/man_term.c b/man_term.c
index febd60af..cd2c5977 100644
--- a/man_term.c
+++ b/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.124 2011/11/18 17:04:06 joerg Exp $ */
+/* $Id: man_term.c,v 1.125 2011/12/04 00:44:12 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -963,15 +963,17 @@ print_man_foot(struct termp *p, const void *arg)
const struct man_meta *meta;
meta = (const struct man_meta *)arg;
+ assert(meta->title);
+ assert(meta->msec);
+ assert(meta->date);
term_fontrepl(p, TERMFONT_NONE);
term_vspace(p);
term_vspace(p);
term_vspace(p);
- snprintf(title, BUFSIZ, "%s(%s)", meta->title ? meta->title : "",
- meta->msec ? meta->msec : "");
- datelen = term_strlen(p, meta->date ? meta->date : "");
+ snprintf(title, BUFSIZ, "%s(%s)", meta->title, meta->msec);
+ datelen = term_strlen(p, meta->date);
p->flags |= TERMP_NOSPACE | TERMP_NOBREAK;
p->offset = 0;
@@ -987,7 +989,7 @@ print_man_foot(struct termp *p, const void *arg)
if (p->offset + datelen >= p->rmargin)
p->rmargin = p->offset + datelen;
- term_word(p, meta->date ? meta->date : "");
+ term_word(p, meta->date);
term_flushln(p);
p->flags &= ~TERMP_NOBREAK;
@@ -1008,6 +1010,8 @@ print_man_head(struct termp *p, const void *arg)
const struct man_meta *m;
m = (const struct man_meta *)arg;
+ assert(m->title);
+ assert(m->msec);
/*
* Note that old groff would spit out some spaces before the
@@ -1024,8 +1028,7 @@ print_man_head(struct termp *p, const void *arg)
strlcpy(buf, m->vol, BUFSIZ);
buflen = term_strlen(p, buf);
- snprintf(title, BUFSIZ, "%s(%s)", m->title ? m->title : "",
- m->msec ? m->msec : "");
+ snprintf(title, BUFSIZ, "%s(%s)", m->title, m->msec);
titlen = term_strlen(p, title);
p->flags |= TERMP_NOBREAK | TERMP_NOSPACE;