summaryrefslogtreecommitdiffstats
path: root/mdoc_html.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_html.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_html.c')
-rw-r--r--mdoc_html.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/mdoc_html.c b/mdoc_html.c
index 5d2d4b7d..d2cee375 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -29,6 +29,7 @@
#include <unistd.h>
#include "mandoc.h"
+#include "mandoc_aux.h"
#include "out.h"
#include "html.h"
#include "mdoc.h"
@@ -514,9 +515,10 @@ mdoc_root_post(MDOC_ARGS)
static int
mdoc_root_pre(MDOC_ARGS)
{
+ char b[BUFSIZ];
struct htmlpair tag[3];
struct tag *t, *tt;
- char b[BUFSIZ], title[BUFSIZ];
+ char *title;
strlcpy(b, meta->vol, BUFSIZ);
@@ -526,7 +528,7 @@ mdoc_root_pre(MDOC_ARGS)
strlcat(b, ")", BUFSIZ);
}
- snprintf(title, BUFSIZ - 1, "%s(%s)", meta->title, meta->msec);
+ mandoc_asprintf(&title, "%s(%s)", meta->title, meta->msec);
PAIR_SUMMARY_INIT(&tag[0], "Document Header");
PAIR_CLASS_INIT(&tag[1], "head");
@@ -557,6 +559,8 @@ mdoc_root_pre(MDOC_ARGS)
print_otag(h, TAG_TD, 2, tag);
print_text(h, title);
print_tagq(h, t);
+
+ free(title);
return(1);
}