summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2019-01-06 15:05:13 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2019-01-06 15:05:13 -0800
commita646aa84a8892b091bc7b7b24cfa89f8e628ec0e (patch)
treedc09d20dc5bf27e7d7261c6691eaa793552a9689
parent62a8e169e13c218dd43e245eea959562769d9ffa (diff)
Replace remaining sprintf calls with snprintf
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--Clock.c7
1 files 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