aboutsummaryrefslogtreecommitdiffstatshomepage
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
commitfece5afe88597138c5b8649d9a19911461e3622b (patch)
tree673903aa78a85c00d4d4169be13b68808d419833 /mdoc_term.c
parentc0c47ffe49a70fb77831194f625f593bd29c449e (diff)
downloadmandoc-fece5afe88597138c5b8649d9a19911461e3622b.tar.gz
mandoc-fece5afe88597138c5b8649d9a19911461e3622b.tar.zst
mandoc-fece5afe88597138c5b8649d9a19911461e3622b.zip
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.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/mdoc_term.c b/mdoc_term.c
index 8472b8f3..fac902bc 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.265 2014/04/20 19:40:13 schwarze Exp $ */
+/* $Id: mdoc_term.c,v 1.266 2014/04/20 20:18:12 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -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