fox-it / dissect.sql

A Dissect module implementing a parsers for the SQLite database file format, commonly used by applications to store configuration data.
GNU Affero General Public License v3.0
6 stars 4 forks source link

Negative value in SQLite3 for TIMESTAMP field overflows #948 #29

Open OlafHaalstra opened 5 days ago

OlafHaalstra commented 5 days ago

Whilst working with iTunes backups I noted that a timestamp of: -63114076800, results in the value 281411862633856 which is exactly 2^48 - 63114076800

As far as I know has to do with the Cocoa Core Data epoch (for which 0 = 01-01-2001, so -63114076800 = 01-01-0001)

Not sure if this lies within the responsibility of the dissect framework, however it does cause issues when parsing these entries. Is there any way to circumvent this?

Values that show the problem:

Poeloe commented 3 days ago

Hi Olaf, thank you for noticing and submitting this issue.

I briefly looked into the issue and it looks like that in this case key 5 for SERIAL_TYPES in c_sqlite3.py should be an int48 instead of uint48. Looking at sqlite file format in 2.1, this also explains it should be an int48, if I'm correct.

@Schamper since you've committed this code, do you maybe know how this SERIAL_TYPES mapping came to be?