Skip to content
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

iter_t operators ++ and -- have some out-of-bounds issues #3

Open
mzealey opened this issue Jul 7, 2019 · 0 comments
Open

iter_t operators ++ and -- have some out-of-bounds issues #3

mzealey opened this issue Jul 7, 2019 · 0 comments

Comments

@mzealey
Copy link

mzealey commented Jul 7, 2019

If you look up a record using lower_bound and it is after the last key in the database; you can get a crash when trying to read or seek via the iterator (i cant remember which I did that caused the crash). You need to handle the -- case a bit like the patch I made here:
PowerDNS/pdns@0844062#diff-562825383c4b03c7c0504a94cfc4d2abR388

There is a similar issue with ++, but it is slightly harder to solve as a SET_RANGE will always return the next record ie it would only get into this state as the result of a -- and I'm not sure if it would do that even then - need to look at the lmdb docs. Lets say you were on the first record of the iterator and you -- it, I'm guessing d_end goes to true but you are actually at the beginning rather than the end. I think you probably need to keep track of both states and do a MDB_FIRST type lookup, blanking a d_before_first type flag...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant