libimobiledevice / libplist

A library to handle Apple Property List format in binary or XML
https://libimobiledevice.org
GNU Lesser General Public License v2.1
548 stars 304 forks source link

Mismatching `sizeof()` for date inner values #264

Open michaelwright235 opened 2 months ago

michaelwright235 commented 2 months ago

I've encountered a bug when I tried using the plist_set_date_val function:

Assertion failed: (length == sizeof(double)), function plist_get_date_val, file plist.c, line 1420.

When I was expecting the code, I found out that arguments of sizeof for date related functions are mismatching.

plist_new_date(...) (uses double):

data->length = sizeof(double);

plist_set_date_val(...) (uses timeval):

plist_set_element_val(node, PLIST_DATE, &val, sizeof(struct timeval));

plist_get_date_val(...) (uses double):

assert(length == sizeof(double));