-
Notifications
You must be signed in to change notification settings - Fork 287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update imap-date.c to check if number of days is correct #198
base: main
Are you sure you want to change the base?
Conversation
Add some basic checks to ensure tm_mday values is correct for the month entered, especially for doveadm search conditions
Looks like the following utc_mktime() already fully validates all the dates. However, we're mostly just ignoring the results and assuming the timestamp is too large or too small. I think something like the patch below would work better, except the 2038 check needs to be better somehow.
|
Maybe the check is needed only with 32bit time_t, and with 64bit time_t just handle all (time_t)-1 return values as invalid. |
Without this check, you can search messages with "doveadm" with dates like "32-Jan-2022" or "31-Apr-2023", with very strange results. This simple check just prevent this situation, before calling imap_mktime. |
But you get better correctness with the patch I added, e.g. you can't use "29-Feb-2023". Just would need to replace |
Perhaps we can consider this basic check a date input validation, working both on 32 and 64 bit systems and also after 2038. |
It's unnecessary to add such basic validation though if it can be done perfectly instead.. I did a bit improved patch that seems to catch all the cases correctly with 32bit and 64bit time_t. Tracking internally in DOP-3196. |
Add some basic checks to ensure tm_mday values is correct for the month entered, especially for doveadm search conditions