Skip to content

Commit

Permalink
time.c: fixed a potential buffer overflow in time_zonename.
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Jul 25, 2021
1 parent c2c0250 commit 26340a8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mrbgems/mruby-time/src/time.c
Expand Up @@ -695,7 +695,7 @@ time_zonename(mrb_state *mrb, struct mrb_time *tm, char *buf, size_t len)
datetime.tm_hour = offset / 60;
datetime.tm_min = offset % 60;
buf[0] = utc_sec < tm->sec ? '-' : '+';
return strftime(buf+1, len, "%H%M", &datetime) + 1;
return strftime(buf+1, len-1, "%H%M", &datetime) + 1;
#else
return strftime(buf, len, "%z", &tm->datetime);
#endif
Expand Down

0 comments on commit 26340a8

Please sign in to comment.