From 5d23c240b62912ccd5f6b828e096e0e5593c074b Mon Sep 17 00:00:00 2001 From: Frederic Cambus Date: Thu, 20 Aug 2015 23:17:58 +0200 Subject: [PATCH] Use 'snprintf' instead of 'sprintf' This gets rid of a linker warning when compiling on OpenBSD: ./.libs/libjq.a(jv_print.o)(.text+0x2fc): In function `jvp_dump_string': /root/jq-1.5/jv_print.c:118: warning: sprintf() is often misused, please use snprintf() --- jv_print.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jv_print.c b/jv_print.c index c5a9e120..5f4f234b 100644 --- a/jv_print.c +++ b/jv_print.c @@ -115,10 +115,10 @@ static void jvp_dump_string(jv str, int ascii_only, FILE* F, jv* S, int T) { } if (unicode_escape) { if (c <= 0xffff) { - sprintf(buf, "\\u%04x", c); + snprintf(buf, sizeof(buf), "\\u%04x", c); } else { c -= 0x10000; - sprintf(buf, "\\u%04x\\u%04x", + snprintf(buf, sizeof(buf), "\\u%04x\\u%04x", 0xD800 | ((c & 0xffc00) >> 10), 0xDC00 | (c & 0x003ff)); }