sqlite: validate maxSize argument in createTagStore()#63792
Open
Anshikakalpana wants to merge 1 commit into
Open
sqlite: validate maxSize argument in createTagStore()#63792Anshikakalpana wants to merge 1 commit into
Anshikakalpana wants to merge 1 commit into
Conversation
Collaborator
|
Review requested:
|
Signed-off-by: anshikakalpana <anshikajain196872@gmail.com>
68d5139 to
3c0477b
Compare
aduh95
reviewed
Jun 8, 2026
| if (capacity < 0) { | ||
| THROW_ERR_OUT_OF_RANGE( | ||
| env->isolate(), | ||
| "The \"maxSize\" argument must be a non-negative integer."); |
Contributor
There was a problem hiding this comment.
If we accept 0, technically that's a negative number
Suggested change
| "The \"maxSize\" argument must be a non-negative integer."); | |
| "The \"maxSize\" argument must be a positive integer."); |
aduh95
reviewed
Jun 8, 2026
| if (args.Length() > 0 && !args[0]->IsUndefined()) { | ||
| if (!args[0]->IsInt32()) { | ||
| THROW_ERR_INVALID_ARG_TYPE( | ||
| env->isolate(), "The \"maxSize\" argument must be an integer."); |
Contributor
There was a problem hiding this comment.
If the user runs database.createTagStore(Number.MAX_SAFE_INTEGER), that error message is going to be confusing
aduh95
reviewed
Jun 8, 2026
Comment on lines
+124
to
+129
| code: 'ERR_INVALID_ARG_TYPE', | ||
| message: /maxSize/, | ||
| }); | ||
|
|
||
| assert.throws(() => db.createTagStore(1.5), { | ||
| code: 'ERR_INVALID_ARG_TYPE', |
Contributor
There was a problem hiding this comment.
This should likely be ERR_OUT_OF_RANGE, like e.g. node -e 'child_process.spawn("/dev/null", { uid: 1.3 })' does
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #63791
database.createTagStore()accepted invalid values for itsmaxSizeargument without throwing. Negative integers caused integer overflow, NaN and floats produced garbage capacity values, and strings were silently ignored.The
maxSizeparameter is documented as{integer}and represents a cache size, so negative values are meaningless.This PR adds validation to reject:
ERR_INVALID_ARG_TYPEERR_OUT_OF_RANGE