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
F160693122: D57670.diff
Fri, Jun 26, 8:51 PM
Unknown Object (File)
Fri, Jun 26, 10:50 AM
Unknown Object (File)
Fri, Jun 26, 6:14 AM
Unknown Object (File)
Thu, Jun 25, 7:38 PM
Unknown Object (File)
Thu, Jun 25, 3:06 PM
Unknown Object (File)
Thu, Jun 25, 7:27 AM
Unknown Object (File)
Wed, Jun 24, 11:20 AM
Unknown Object (File)
Wed, Jun 24, 7:54 AM
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 Skipped
Unit
Tests Skipped
Build Status
Buildable 74013
Build 70896: arc lint + arc unit

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