So I'm playing with mailcore2 on linux and I've encountered a problem with RangeMake. Put shortly, something like mailcore::RangeMake (start_uid_value, end_uid_value), where start is anything higher than 1 when end is UINT64_MAX results in an overflow.
Take the following snippet:
auto range = mailcore::RangeMake (90000, UINT64_MAX);
auto fetch_messages_operation = session->fetchMessagesByUIDOperation(new mailcore::String (folder_path), (mailcore::IMAPMessagesRequestKind) kind, uidRange);
The actual command will try to fetch 90000:89999 because of an overflow. Honestly, I think this behavior of Range is confusing since the library is expecting start index and length when the developer might be giving start index and end index, but I realise that this might be hard to change in all the applications that depend on mailcore2.
Instead, I propose a clipping mechanism that will clip the end index to UINT64_MAX if the range overflows it. This would've saved me many hours of debugging.
Hello everyone,
So I'm playing with mailcore2 on linux and I've encountered a problem with
RangeMake
. Put shortly, something likemailcore::RangeMake (start_uid_value, end_uid_value)
, wherestart
is anything higher than 1 whenend
isUINT64_MAX
results in an overflow.Take the following snippet:
The actual command will try to fetch
90000:89999
because of an overflow. Honestly, I think this behavior ofRange
is confusing since the library is expecting start index and length when the developer might be giving start index and end index, but I realise that this might be hard to change in all the applications that depend on mailcore2.Instead, I propose a clipping mechanism that will clip the end index to UINT64_MAX if the range overflows it. This would've saved me many hours of debugging.
What do you think?