summaryrefslogtreecommitdiff
path: root/src/html.c
diff options
context:
space:
mode:
authorMarco Benelli <mbenelli@yahoo.com>2015-11-02 13:19:04 +0100
committerMarco Benelli <mbenelli@yahoo.com>2015-11-02 13:19:04 +0100
commit0b5a8193fdc7b041023e44149a1d63b95ce98bfd (patch)
treead56de935f0c137db455a6f5d75304d50e0bae6e /src/html.c
parentb95def0719d823eb6bc11780ce8729d89c3ebf69 (diff)
Replaced sprintf with snprintf.
Diffstat (limited to 'src/html.c')
-rw-r--r--src/html.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/html.c b/src/html.c
index dfe2aec..b0a5895 100644
--- a/src/html.c
+++ b/src/html.c
@@ -29,11 +29,12 @@ struct render_state {
static void S_render_sourcepos(cmark_node *node, cmark_strbuf *html,
int options) {
- char buffer[100];
+ const size_t BUFFER_SIZE = 100;
+ char buffer[BUFFER_SIZE];
if (CMARK_OPT_SOURCEPOS & options) {
- sprintf(buffer, " data-sourcepos=\"%d:%d-%d:%d\"",
- cmark_node_get_start_line(node), cmark_node_get_start_column(node),
- cmark_node_get_end_line(node), cmark_node_get_end_column(node));
+ snprintf(buffer, BUFFER_SIZE, " data-sourcepos=\"%d:%d-%d:%d\"",
+ cmark_node_get_start_line(node), cmark_node_get_start_column(node),
+ cmark_node_get_end_line(node), cmark_node_get_end_column(node));
cmark_strbuf_puts(html, buffer);
}
}
@@ -46,7 +47,8 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type,
char start_header[] = "<h0";
char end_header[] = "</h0";
bool tight;
- char buffer[100];
+ const size_t BUFFER_SIZE = 100;
+ char buffer[BUFFER_SIZE];
bool entering = (ev_type == CMARK_EVENT_ENTER);
@@ -104,7 +106,7 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type,
S_render_sourcepos(node, html, options);
cmark_strbuf_puts(html, ">\n");
} else {
- sprintf(buffer, "<ol start=\"%d\"", start);
+ snprintf(buffer, BUFFER_SIZE, "<ol start=\"%d\"", start);
cmark_strbuf_puts(html, buffer);
S_render_sourcepos(node, html, options);
cmark_strbuf_puts(html, ">\n");