-
Notifications
You must be signed in to change notification settings - Fork 94
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
SERVER-95889 Make FLE2IndexedEqualityEncryptedValueV2 wrap mc_FLE2IndexedEncryptedValueV2_t #910
Conversation
src/mc-fle2-payload-iev-private-v2.h
Outdated
@@ -80,7 +80,39 @@ | |||
* | |||
*/ | |||
|
|||
typedef struct _mc_FLE2IndexedEncryptedValueV2_t mc_FLE2IndexedEncryptedValueV2_t; | |||
typedef enum { | |||
kTypeInitV2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're going to find that even these names are too generic given how C ODRs its enums into the global symbol space. It wasn't a problem when these were scoped to a single TU, but now that they're in a header, we should give them more distinctness.
e.g.
typedef enum {
kFLE2IEVTypeInitV2,
kFLE2IEVTypeEqualityV2,
kFLE2IEVTypeRangeV2,
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
src/mongocrypt-util.c
Outdated
@@ -124,6 +124,34 @@ const char *mc_bson_type_to_string(bson_type_t t) { | |||
} | |||
} | |||
|
|||
bool mc_is_valid_bson_type(int bson_type) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function seems.... sus.
You seem to just be checking if the value is in the explicit list of named numeric values.
Thing is that's not very meaningful in terms of if a type is "valid" or not.
(MAXKEY, MINKEY]
(the set of 128 values from 0x80..0xFF
) are all "valid" as BSON types, for example. Those two constants define the endpoints of the "User Defined BSONElements" range.
On the other side, EOD and UNDEFINED don't make sense as valid encodable types. (Though "Undefined" is defined, it's just no longer a valid type, so that one gets.... complicated).
TL;DR - The only truly "invalid" type is EOD.
Unless I'm misunderstanding the purpose of this method, I'd probably just reduce it to:
return bson_type != BSON_TYPE_EOD;
Further Reading: https://bsonspec.org/spec.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went ahead and modified this in order to get a test passing, feel free to change it back if necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, I didn't realize that [MAXKEY, MINKEY]
are valid, I was wondering what those meant. Thanks for the clarification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with minor comments.
Main repo PR: https://github.com/10gen/mongo/pull/29265