Skip to content
Snippets Groups Projects
Commit 783a7040 authored by Timur Safin's avatar Timur Safin Committed by Igor Munkin
Browse files

datetime: fix buffer overflow in tnt_strptime

Fixes #8502
Needed for #8490

NO_DOC=bugfix
NO_TEST=covered by fuzzing test
parent 66ebe8c3
No related branches found
No related tags found
No related merge requests found
## bugfix/datetime
* Fixed a bug with buffer overflow in tnt_strptime (gh-8502).
......@@ -125,9 +125,11 @@ tnt_strptime(const char *__restrict buf, const char *__restrict fmt,
c = *ptr++;
if (c != '%') {
if (isspace((u_char)c))
/* Eat up white-space in buffer and in format. */
if (isspace((u_char)c)) {
while (*buf != 0 && isspace((u_char)*buf))
buf++;
}
else if (c != *buf++)
return NULL;
continue;
......@@ -661,9 +663,10 @@ tnt_strptime(const char *__restrict buf, const char *__restrict fmt,
if ((flags & (FLAG_YEAR | FLAG_YDAY)) == (FLAG_YEAR | FLAG_YDAY)) {
if (!(flags & FLAG_MONTH)) {
i = 0;
while (tm->tm_yday >=
start_of_month[isleap(tm->tm_year +
TM_YEAR_BASE)][i])
while (i <= 12 &&
tm->tm_yday >=
start_of_month[isleap(tm->tm_year +
TM_YEAR_BASE)][i])
i++;
if (i > 12) {
i = 1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment