Skip to content

Conversation

@altmannmarcelo
Copy link
Contributor

mysql-time: hour overflow
The way we currently parse hour at time_from_packed can overflow if
the amount of hours is greater than 255 because the hour field from
time struct is a u8.

This commit fixes the issue by converting the hours to days and hours.

Fixes: #169

This commit adds a test case for the hour overflow issue.

Test case:

```
mysql> CREATE TABLE t (c TIME);
Query OK, 0 rows affected (0,018 sec)

mysql> INSERT INTO t values ('-507:48:27');
Query OK, 1 row affected (0,009 sec)
```
The way we currently parse hour at time_from_packed can overflow if
the amount of hours is greater than 255 because the hour field from
time struct is a u8.

This commit fixes the issue by converting the hours to days and hours.

Fixes: blackbeam#169
@blackbeam blackbeam merged commit 3573816 into blackbeam:master May 6, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MySQL time hour overflows

2 participants