aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-04-20 19:40:13 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-04-20 19:40:13 +0000
commitc0c47ffe49a70fb77831194f625f593bd29c449e (patch)
treedb8c1dbd3c3052a39baeff9ada43ecce15282496
parent29cecee7ff6894517a32d929aecee283bb85058c (diff)
downloadmandoc-c0c47ffe49a70fb77831194f625f593bd29c449e.tar.gz
mandoc-c0c47ffe49a70fb77831194f625f593bd29c449e.tar.zst
mandoc-c0c47ffe49a70fb77831194f625f593bd29c449e.zip
make sure static buffers for snprintf(3) are large enough
and cast snprintf return value to (void) where they are
-rw-r--r--eqn.c4
-rw-r--r--mdoc_man.c13
-rw-r--r--mdoc_term.c6
-rw-r--r--mdoc_validate.c12
-rw-r--r--roff.c8
5 files changed, 21 insertions, 22 deletions
diff --git a/eqn.c b/eqn.c
index 015d9eec..12b00e51 100644
--- a/eqn.c
+++ b/eqn.c
@@ -1,4 +1,4 @@
-/* $Id: eqn.c,v 1.40 2014/04/20 16:46:04 schwarze Exp $ */
+/* $Id: eqn.c,v 1.41 2014/04/20 19:40:13 schwarze Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -628,7 +628,7 @@ eqn_box(struct eqn_node *ep, struct eqn_box *last)
for (i = 0; i < (int)EQNSYM__MAX; i++)
if (EQNSTREQ(&eqnsyms[i].str, start, sz)) {
sym[63] = '\0';
- snprintf(sym, 62, "\\[%s]", eqnsyms[i].sym);
+ (void)snprintf(sym, 62, "\\[%s]", eqnsyms[i].sym);
bp->text = mandoc_strdup(sym);
return(EQN_OK);
}
diff --git a/mdoc_man.c b/mdoc_man.c
index 626933f5..29bede8f 100644
--- a/mdoc_man.c
+++ b/mdoc_man.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_man.c,v 1.62 2014/04/20 16:46:05 schwarze Exp $ */
+/* $Id: mdoc_man.c,v 1.63 2014/04/20 19:40:13 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -457,7 +457,7 @@ print_offs(const char *v)
if (Bl_stack_len)
sz += Bl_stack[Bl_stack_len - 1];
- snprintf(buf, sizeof(buf), "%zun", sz);
+ (void)snprintf(buf, sizeof(buf), "%zun", sz);
print_word(buf);
outflags |= MMAN_nl;
}
@@ -510,7 +510,7 @@ print_width(const char *v, const struct mdoc_node *child, size_t defsz)
remain = sz + 2;
}
if (numeric) {
- snprintf(buf, sizeof(buf), "%zun", sz + 2);
+ (void)snprintf(buf, sizeof(buf), "%zun", sz + 2);
print_word(buf);
} else
print_word(v);
@@ -520,9 +520,9 @@ print_width(const char *v, const struct mdoc_node *child, size_t defsz)
static void
print_count(int *count)
{
- char buf[12];
+ char buf[24];
- snprintf(buf, sizeof(buf), "%d.", ++*count);
+ (void)snprintf(buf, sizeof(buf), "%d.", ++*count);
print_word(buf);
}
@@ -1316,7 +1316,8 @@ mid_it(void)
/* Restore the indentation of the enclosing list. */
print_line(".RS", MMAN_Bk_susp);
- snprintf(buf, sizeof(buf), "%zun", Bl_stack[Bl_stack_len - 1]);
+ (void)snprintf(buf, sizeof(buf), "%zun",
+ Bl_stack[Bl_stack_len - 1]);
print_word(buf);
/* Remeber to close out this .RS block later. */
diff --git a/mdoc_term.c b/mdoc_term.c
index 4fbed5de..8472b8f3 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.264 2014/04/20 16:46:05 schwarze Exp $ */
+/* $Id: mdoc_term.c,v 1.265 2014/04/20 19:40:13 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -620,7 +620,7 @@ static int
termp_it_pre(DECL_ARGS)
{
const struct mdoc_node *bl, *nn;
- char buf[7];
+ char buf[24];
int i;
size_t width, offset, ncols, dcol;
enum mdoc_list type;
@@ -916,7 +916,7 @@ termp_it_pre(DECL_ARGS)
break;
case LIST_enum:
(pair->ppair->ppair->count)++;
- snprintf(buf, sizeof(buf), "%d.",
+ (void)snprintf(buf, sizeof(buf), "%d.",
pair->ppair->ppair->count);
term_word(p, buf);
break;
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 85ae65df..63474bd3 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.210 2014/04/20 16:46:05 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.211 2014/04/20 19:40:13 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -45,8 +45,6 @@
#define PRE_ARGS struct mdoc *mdoc, struct mdoc_node *n
#define POST_ARGS struct mdoc *mdoc
-#define NUMSIZ 32
-
enum check_ineq {
CHECK_LT,
CHECK_GT,
@@ -1388,7 +1386,7 @@ post_bl_block_width(POST_ARGS)
int i;
enum mdoct tok;
struct mdoc_node *n;
- char buf[NUMSIZ];
+ char buf[24];
n = mdoc->last;
@@ -1420,7 +1418,7 @@ post_bl_block_width(POST_ARGS)
assert(i < (int)n->args->argc);
- snprintf(buf, NUMSIZ, "%un", (unsigned int)width);
+ (void)snprintf(buf, sizeof(buf), "%un", (unsigned int)width);
free(n->args->argv[i].value[0]);
n->args->argv[i].value[0] = mandoc_strdup(buf);
@@ -1435,7 +1433,7 @@ post_bl_block_tag(POST_ARGS)
struct mdoc_node *n, *nn;
size_t sz, ssz;
int i;
- char buf[NUMSIZ];
+ char buf[24];
/*
* Calculate the -width for a `Bl -tag' list if it hasn't been
@@ -1470,7 +1468,7 @@ post_bl_block_tag(POST_ARGS)
/* Defaults to ten ens. */
- snprintf(buf, NUMSIZ, "%un", (unsigned int)sz);
+ (void)snprintf(buf, sizeof(buf), "%un", (unsigned int)sz);
/*
* We have to dynamically add this to the macro's argument list.
diff --git a/roff.c b/roff.c
index 5ea64e20..fee1a8c1 100644
--- a/roff.c
+++ b/roff.c
@@ -1,4 +1,4 @@
-/* $Id: roff.c,v 1.207 2014/04/20 16:46:05 schwarze Exp $ */
+/* $Id: roff.c,v 1.208 2014/04/20 19:40:13 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -488,7 +488,7 @@ roff_alloc(struct mparse *parse, int options)
static enum rofferr
roff_res(struct roff *r, char **bufp, size_t *szp, int ln, int pos)
{
- char ubuf[12]; /* buffer to print the number */
+ char ubuf[24]; /* buffer to print the number */
const char *start; /* start of the string to process */
const char *stesc; /* start of an escape sequence ('\\') */
const char *stnam; /* start of the name, after "[(*" */
@@ -614,11 +614,11 @@ roff_res(struct roff *r, char **bufp, size_t *szp, int ln, int pos)
ubuf[1] = '\0';
break;
case 'n':
- snprintf(ubuf, sizeof(ubuf), "%d",
+ (void)snprintf(ubuf, sizeof(ubuf), "%d",
roff_getregn(r, stnam, naml));
break;
case 'w':
- snprintf(ubuf, sizeof(ubuf), "%d",
+ (void)snprintf(ubuf, sizeof(ubuf), "%d",
24 * (int)naml);
break;
}