Skip to content

Commit ddfa722

Browse files
committed
MDEV-18626 ASAN stack-buffer-overflow in int10_to_str / make_date_time upon DATE_FORMAT
1 parent 49c49e6 commit ddfa722

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

mysql-test/r/func_time.result

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3444,5 +3444,11 @@ foo
34443444
Warnings:
34453445
Warning 1292 Truncated incorrect DECIMAL value: '2012-12-12 12:12:12'
34463446
#
3447+
# MDEV-18626 ASAN stack-buffer-overflow in int10_to_str / make_date_time upon DATE_FORMAT
3448+
#
3449+
SELECT DATE_FORMAT(100000000000, '%j');
3450+
DATE_FORMAT(100000000000, '%j')
3451+
NULL
3452+
#
34473453
# End of 10.1 tests
34483454
#

mysql-test/t/func_time.test

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,6 +1929,13 @@ DROP TABLE t1;
19291929

19301930
SELECT NULLIF('foo', FROM_UNIXTIME('2012-12-12 12:12:12', TRIM(0)));
19311931

1932+
--echo #
1933+
--echo # MDEV-18626 ASAN stack-buffer-overflow in int10_to_str / make_date_time upon DATE_FORMAT
1934+
--echo #
1935+
1936+
SELECT DATE_FORMAT(100000000000, '%j');
1937+
1938+
19321939
--echo #
19331940
--echo # End of 10.1 tests
19341941
--echo #

sql/item_timefunc.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ static bool make_date_time(const LEX_CSTRING &format, MYSQL_TIME *l_time,
577577
str->append_with_prefill(intbuff, length, 2, '0');
578578
break;
579579
case 'j':
580-
if (type == MYSQL_TIMESTAMP_TIME)
580+
if (type == MYSQL_TIMESTAMP_TIME || !l_time->month || !l_time->year)
581581
return 1;
582582
length= (uint) (int10_to_str(calc_daynr(l_time->year,l_time->month,
583583
l_time->day) -

0 commit comments

Comments
 (0)