From 78ee6607ca35319c4785c5c48f7eed618e56d7d0 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 17 Feb 2013 09:56:53 -0800 Subject: convert sprintf calls to snprintf Signed-off-by: Alan Coopersmith --- xfd.c | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) (limited to 'xfd.c') diff --git a/xfd.c b/xfd.c index bf49d32..18f262f 100644 --- a/xfd.c +++ b/xfd.c @@ -316,11 +316,11 @@ main(int argc, char *argv[]) minn = GridFirstChar (fontGrid); maxn = GridLastChar (fontGrid); - sprintf (buf, xfd_resources.range_format, - minn >> 8, minn & 0xff, - minn >> 8, minn & 0xff, - maxn >> 8, maxn & 0xff, - maxn >> 8, maxn & 0xff); + snprintf (buf, sizeof(buf), xfd_resources.range_format, + minn >> 8, minn & 0xff, + minn >> 8, minn & 0xff, + maxn >> 8, maxn & 0xff, + maxn >> 8, maxn & 0xff); i = 0; XtSetArg (av[i], XtNlabel, buf); i++; @@ -364,11 +364,11 @@ SelectChar(Widget w, XtPointer closure, XtPointer data) { XGlyphInfo extents; XftTextExtents32 (XtDisplay (w), xft, &c, 1, &extents); - sprintf (buf, xfd_resources.metrics_format, - extents.xOff, - extents.x, - extents.xOff - extents.width + extents.x, - extents.y, extents.height - extents.y, - xft->ascent, xft->descent); + snprintf (buf, sizeof(buf), xfd_resources.metrics_format, + extents.xOff, - extents.x, + extents.xOff - extents.width + extents.x, + extents.y, extents.height - extents.y, + xft->ascent, xft->descent); } } else @@ -389,26 +389,26 @@ SelectChar(Widget w, XtPointer closure, XtPointer data) char2b.byte2 = p->thechar & 0xff; XTextExtents16 (fs, &char2b, 1, &direction, &fontascent, &fontdescent, &metrics); - sprintf (buf, xfd_resources.metrics_format, - metrics.width, metrics.lbearing, metrics.rbearing, - metrics.ascent, metrics.descent, fontascent, fontdescent); + snprintf (buf, sizeof(buf), xfd_resources.metrics_format, + metrics.width, metrics.lbearing, metrics.rbearing, + metrics.ascent, metrics.descent, fontascent, fontdescent); } } XtSetValues (metricsLabel, &arg, ONE); if (has_char) { - sprintf (buf, xfd_resources.select_format, - n >> 8, n & 0xff, - n >> 8, n & 0xff, - n >> 8, n & 0xff); + snprintf (buf, sizeof(buf), xfd_resources.select_format, + n >> 8, n & 0xff, + n >> 8, n & 0xff, + n >> 8, n & 0xff); } else { - sprintf (buf, xfd_resources.nochar_format, - n >> 8, n & 0xff, - n >> 8, n & 0xff, - n >> 8, n & 0xff); + snprintf (buf, sizeof(buf), xfd_resources.nochar_format, + n >> 8, n & 0xff, + n >> 8, n & 0xff, + n >> 8, n & 0xff); } XtSetValues (selectLabel, &arg, ONE); @@ -452,7 +452,8 @@ change_page(int page) unsigned int col = (unsigned int) (newstart & 0xff); XtSetArg (arg, XtNlabel, buf); - sprintf (buf, xfd_resources.start_format, newstart, row, col); + snprintf (buf, sizeof(buf), xfd_resources.start_format, + newstart, row, col); XtSetValues (startLabel, &arg, ONE); } -- cgit v1.2.3