From a646aa84a8892b091bc7b7b24cfa89f8e628ec0e Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 6 Jan 2019 15:05:13 -0800 Subject: Replace remaining sprintf calls with snprintf Signed-off-by: Alan Coopersmith --- Clock.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Clock.c b/Clock.c index fefe0a8..e3f8f2b 100644 --- a/Clock.c +++ b/Clock.c @@ -521,7 +521,7 @@ TimeString (ClockWidget w, struct tm *tm) if (w->clock.twentyfour) { static char brief[6]; - sprintf (brief, "%02d:%02d", tm->tm_hour, tm->tm_min); + snprintf (brief, sizeof(brief), "%02d:%02d", tm->tm_hour, tm->tm_min); return brief; } else @@ -529,7 +529,7 @@ TimeString (ClockWidget w, struct tm *tm) static char brief[9]; int hour = tm->tm_hour % 12; if (!hour) hour = 12; - sprintf (brief, "%02d:%02d %cM", hour, tm->tm_min, + snprintf (brief, sizeof(brief), "%02d:%02d %cM", hour, tm->tm_min, tm->tm_hour >= 12 ? 'P' : 'A'); return brief; } @@ -539,7 +539,8 @@ TimeString (ClockWidget w, struct tm *tm) static char utime[35]; Time_t tsec; tsec = time(NULL); - sprintf (utime, "%10lu seconds since Epoch", (unsigned long)tsec); + snprintf (utime, sizeof(utime), "%10lu seconds since Epoch", + (unsigned long)tsec); return utime; } else if (*w->clock.strftime) { /*Note: this code is probably excessively paranoid -- cgit v1.2.3