source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: make sure static buffers for snprintf(3) are large enough and
@ 2014-04-20 19:40 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2014-04-20 19:40 UTC (permalink / raw)
  To: source

Log Message:
-----------
make sure static buffers for snprintf(3) are large enough
and cast snprintf return value to (void) where they are

Modified Files:
--------------
    mdocml:
        eqn.c
        mdoc_man.c
        mdoc_term.c
        mdoc_validate.c
        roff.c

Revision Data
-------------
Index: eqn.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/eqn.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -Leqn.c -Leqn.c -u -p -r1.40 -r1.41
--- eqn.c
+++ eqn.c
@@ -628,7 +628,7 @@ eqn_box(struct eqn_node *ep, struct eqn_
 	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);
 		}
Index: mdoc_man.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_man.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -Lmdoc_man.c -Lmdoc_man.c -u -p -r1.62 -r1.63
--- mdoc_man.c
+++ 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 
 		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 
 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. */
Index: mdoc_validate.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_validate.c,v
retrieving revision 1.210
retrieving revision 1.211
diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.210 -r1.211
--- mdoc_validate.c
+++ 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.
Index: mdoc_term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_term.c,v
retrieving revision 1.264
retrieving revision 1.265
diff -Lmdoc_term.c -Lmdoc_term.c -u -p -r1.264 -r1.265
--- mdoc_term.c
+++ 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;
Index: roff.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/roff.c,v
retrieving revision 1.207
retrieving revision 1.208
diff -Lroff.c -Lroff.c -u -p -r1.207 -r1.208
--- roff.c
+++ roff.c
@@ -488,7 +488,7 @@ roff_alloc(struct mparse *parse, int opt
 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, si
 			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;
 		}
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-04-20 19:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-20 19:40 mdocml: make sure static buffers for snprintf(3) are large enough and schwarze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).