Skip to content

Commit

Permalink
reduce buffer size and prevent unlikely buffer overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mwarning committed Mar 12, 2019
1 parent 2904b76 commit 59cec60
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,13 +348,13 @@ format_duration(time_t from, time_t to, char buf[64])
seconds = secs;

if (days > 0) {
sprintf(buf, "%dd %dh %dm %ds", days, hours, minutes, seconds);
snprintf(buf, 64, "%dd %dh %dm %ds", days, hours, minutes, seconds);
} else if (hours > 0) {
sprintf(buf, "%dh %dm %ds", hours, minutes, seconds);
snprintf(buf, 64, "%dh %dm %ds", hours, minutes, seconds);
} else if (minutes > 0) {
sprintf(buf, "%dm %ds", minutes, seconds);
snprintf(buf, 64, "%dm %ds", minutes, seconds);
} else {
sprintf(buf, "%ds", seconds);
snprintf(buf, 64, "%ds", seconds);
}

return buf;
Expand All @@ -379,7 +379,7 @@ void
ndsctl_status(FILE *fp)
{
char timebuf[32];
char durationbuf[128];
char durationbuf[64];
s_config *config;
t_client *client;
int indx;
Expand Down

0 comments on commit 59cec60

Please sign in to comment.