Summary: | Windows: crash on NULL dereference if email has invalid date | ||
---|---|---|---|
Product: | Claws Mail (Windows) | Reporter: | Harald van Dijk <cb> |
Component: | default | Assignee: | users |
Status: | RESOLVED FIXED | ||
Severity: | major | ||
Priority: | P3 | ||
Version: | 3.15.0 | ||
Hardware: | PC | ||
OS: | Windows 10 | ||
Attachments: |
Handle invalid dates
Handle invalid dates |
Description
Harald van Dijk
2017-01-26 23:59:49 UTC
Nice catch. However, instead of going back to mktime(), on Windows I'd prefer to normalize the date/time values using g_date_time_add_*() family of functions. Created attachment 1717 [details]
Handle invalid dates
Sure. I also encountered another issue during testing: I have a few e-mails where the year in the header is simply given as 11. This should be changed to 2011 on all platforms. I don't see any reason why the if (year < 1000) block was moved, it doesn't make sense to exclude Windows here, so I moved it back to where it originally was. Does the attached patch look good?
Tested only on Ubuntu, with the #ifdef changed to forcibly enable this code path; I haven't set up my Windows machine to be able to compile anything.
And I think g_date_time_add_full cannot return NULL for anything that fits in an e-mail header, but I didn't want to take chances.
Created attachment 1718 [details]
Handle invalid dates
I see that my first attempt was wrong as it potentially leaked tz, and I see that it could be simplified because g_date_time_unref checks for null pointers and just returns another null pointer, avoiding problems. g_date_time_add_full does the same. So here is a second attempt at a patch, making use of that.
Oops, looks like I completely missed your patch, sorry. A similar fix has been included in recently released 3.15.0, minus the Y2K year fix-up code move. |