Page MenuHomeFreeBSD

libc/dbm: Differentiate between uninitialized and end-of-db cursors
ClosedPublic

Authored by bnovkov on Fri, Jun 19, 3:41 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Jul 7, 12:33 PM
Unknown Object (File)
Tue, Jul 7, 11:46 AM
Unknown Object (File)
Sat, Jul 4, 7:05 AM
Unknown Object (File)
Sat, Jul 4, 7:02 AM
Unknown Object (File)
Sat, Jul 4, 5:23 AM
Unknown Object (File)
Sat, Jul 4, 5:20 AM
Unknown Object (File)
Fri, Jul 3, 6:13 PM
Unknown Object (File)
Fri, Jul 3, 6:10 PM
Subscribers

Details

Summary

Commit 3a686b851f8f fixed a dbm_nextkey edge case when using
the function after reaching the end of the database, but it inadvertently
broke the following R_NEXT behaviour:
"If the cursor is not yet set, this is the same as the R_FIRST flag."

Fix this by adding a new cursor constant that allows us to differentiate
between an unset cursor and a cursor that overflowed.

Reported by: ae
Fixes: 3a686b851f8f
Sponsored by: Klara, Inc.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

lib/libc/db/hash/hash.c
722

The /* R_NEXT */ is kind of misleading now.

722

Are you sure that cbucket will never overflow? e.g., on line 771 or in hash_bigkey.c.

lib/libc/db/hash/hash.c
722

Hm, it could overflow but the check on line 740 explicitly casts it back to uint32_t for the MAX_BUCKET comparison.
I guess it wouldn't hurt if we turn the == into a <= though.

This revision is now accepted and ready to land.Sat, Jun 20, 2:14 PM