summaryrefslogtreecommitdiffstats
path: root/mdoc_term.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-04-20 20:18:12 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-04-20 20:18:12 +0000
commit0e671b23106993a04ea9629722c1308693db3523 (patch)
tree349486bf660b15ebf9ca04fe31b0617fcfa8bd95 /mdoc_term.c
parent846dd76f5940424c60690661ffd74602f74b5051 (diff)
downloadmandoc-0e671b23106993a04ea9629722c1308693db3523.tar.gz
fix unchecked snprintf(3) in page header printing:
the length of the title is unknown, and speed doesn't matter here, so use asprintf/free rather than a static buffer
Diffstat (limited to 'mdoc_term.c')
-rw-r--r--mdoc_term.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/mdoc_term.c b/mdoc_term.c
index 0bfb238d..8e02881c 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -30,6 +30,7 @@
#include <string.h>
#include "mandoc.h"
+#include "mandoc_aux.h"
#include "out.h"
#include "term.h"
#include "mdoc.h"
@@ -441,9 +442,10 @@ print_mdoc_foot(struct termp *p, const void *arg)
static void
print_mdoc_head(struct termp *p, const void *arg)
{
- char buf[BUFSIZ], title[BUFSIZ];
- size_t buflen, titlen;
- const struct mdoc_meta *meta;
+ char buf[BUFSIZ];
+ const struct mdoc_meta *meta;
+ char *title;
+ size_t buflen, titlen;
meta = (const struct mdoc_meta *)arg;
@@ -473,7 +475,7 @@ print_mdoc_head(struct termp *p, const void *arg)
strlcat(buf, ")", BUFSIZ);
}
- snprintf(title, BUFSIZ, "%s(%s)", meta->title, meta->msec);
+ mandoc_asprintf(&title, "%s(%s)", meta->title, meta->msec);
titlen = term_strlen(p, title);
p->flags |= TERMP_NOBREAK | TERMP_NOSPACE;
@@ -508,6 +510,7 @@ print_mdoc_head(struct termp *p, const void *arg)
p->flags &= ~TERMP_NOSPACE;
p->offset = 0;
p->rmargin = p->maxrmargin;
+ free(title);
}
static size_t