prevent overflows in config_parseduration and config_parsebytesize #4536
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
These two functions parse numbers from strings, and don't presently have any overflow protection. They're only used for parsing values from imapd.conf, so this hasn't been an issue -- the administrator can just choose not to use values that will break.
cyr_expire
reads some of its behaviours from mailbox annotations, and #4533 extends it to support "duration" values for some of these annotations, using config_parseduration as its parser. I don't think I would expect users to have permissions to set these annotations, but if somehow they can, then config_parseduration might be processing user-supplied input, and ought to be protected against overflow just in case.This PR adds overflow protection to config_parseduration, and also to config_parsebytesize for completion's sake. I also tightened up config_parseduration's parsing of bogus negative values.
@rsto previously made a version of this as #4534. I borrowed and extended his tests.