summaryrefslogtreecommitdiffstats
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
commit846dd76f5940424c60690661ffd74602f74b5051 (patch)
tree010026608697be4b8db0f1a10b18a8f9fa9ef893
parentf45f622c8ebfa925e3b5340d31a0b4f9380ff675 (diff)
downloadmandoc-846dd76f5940424c60690661ffd74602f74b5051.tar.gz
make sure static buffers for snprintf(3) are large enough
and cast snprintf return value to (void) where they are
-rw-r--r--eqn.c2
-rw-r--r--mdoc_man.c11
-rw-r--r--mdoc_term.c4
-rw-r--r--mdoc_validate.c10
-rw-r--r--roff.c6
5 files changed, 16 insertions, 17 deletions
diff --git a/eqn.c b/eqn.c
index d2347cb4..5f2546ee 100644
--- a/eqn.c
+++ b/eqn.c
@@ -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 f5a7a09f..6483cce9 100644
--- a/mdoc_man.c
+++ b/mdoc_man.c
@@ -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 3df7ebc8..0bfb238d 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -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 b604fa5c..fb7863ec 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -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 a8524d98..922b1908 100644
--- a/roff.c
+++ b/roff.c
@@ -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;
}