sprintf() -> snprintf() - ploot - simple plotting tools HTML git clone git://bitreich.org/ploot git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/ploot DIR Log DIR Files DIR Refs DIR Tags DIR README DIR LICENSE --- DIR commit 1a593aa504c78dbc507ed118a004cff811620065 DIR parent 8321d90e92e7e25c50844e48f758be3b72f98a68 HTML Author: Josuah Demangeon <mail@josuah.net> Date: Mon, 7 May 2018 10:25:38 +0200 sprintf() -> snprintf() Diffstat: M plootxt.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- DIR diff --git a/plootxt.c b/plootxt.c @@ -190,11 +190,13 @@ read_labels(char *labv[LINE_MAX]) static void fmt_labels(char out[LINE_MAX], int ncol, char *labels[LINE_MAX / 2]) { - int i; + int i, n; printf("%d\n", width); - for (i = 0; i < ncol; labels++, i++) - out += sprintf(out, "│%-*s", width - 1, *labels); + for (i = 0; i < ncol; labels++, i++) { + n = LINE_MAX - (width + sizeof("│")) * i; + out += snprintf(out, n, "│%-*s", width - 1, *labels); + } } static void