From 84f73c49db8071c06f27609ce7cc7a32a17351a9 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Thu, 9 Dec 2010 23:44:42 -0800 Subject: Convert some sprintf calls to snprintf Signed-off-by: Alan Coopersmith Reviewed-by: Julien Cristau --- src/Selection.c | 2 +- src/Shell.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Selection.c b/src/Selection.c index 1759c02..101ea6a 100644 --- a/src/Selection.c +++ b/src/Selection.c @@ -226,7 +226,7 @@ static Atom GetSelectionProperty( propCount = sarray->propCount++; sarray->list = (SelectionProp) XtRealloc((XtPointer)sarray->list, (unsigned)(sarray->propCount*sizeof(SelectionPropRec))); - (void) sprintf(propname, "%s%d", "_XT_SELECTION_", propCount); + (void) snprintf(propname, sizeof(propname), "_XT_SELECTION_%d", propCount); sarray->list[propCount].prop = XInternAtom(dpy, propname, FALSE); sarray->list[propCount].avail = FALSE; return(sarray->list[propCount].prop); diff --git a/src/Shell.c b/src/Shell.c index 732e978..ef6dad2 100644 --- a/src/Shell.c +++ b/src/Shell.c @@ -1780,7 +1780,8 @@ static void GetGeometry( } else hints.flags = 0; - sprintf( def_geom, "%dx%d+%d+%d", width, height, x, y ); + snprintf( def_geom, sizeof(def_geom), "%dx%d+%d+%d", + width, height, x, y ); flag = XWMGeometry( XtDisplay(W), XScreenNumberOfScreen(XtScreen(W)), w->shell.geometry, def_geom, @@ -3013,7 +3014,7 @@ static void SetSessionProperties( user_name = _XtGetUserName(nam_buf, sizeof nam_buf); if (user_name) props[num_props++] = ArrayPack(SmUserID, &user_name); - sprintf(pid, "%ld", (long)getpid()); + snprintf(pid, sizeof(pid), "%ld", (long)getpid()); props[num_props++] = ArrayPack(SmProcessID, &pidp); if (num_props) { -- cgit v1.2.3