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

[TS]: builder, Fix requiredField(). Verity that the field is present in the vtable (#7739) #7752

Merged
merged 7 commits into from Jan 10, 2023

Conversation

jmillan
Copy link
Contributor

@jmillan jmillan commented Jan 3, 2023

For the example given in the bug report (#7739) CreateX would not throw when such a missing 'required' field is not present.

This bug defeats the strong typing purpose since the creation of a buffer that should throw due to not fulfilling the 'required' flag would indeed succeed and crash when accessing such non present field.

The problem is within builder.requiredField() method which does not check that the field offset is within the bounds of the vtable. This PR fixes exactly that.

@google-cla
Copy link

google-cla bot commented Jan 3, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

tests/required_strings.fbs Show resolved Hide resolved
tests/ts/JavaScriptRequiredStringTest.js Outdated Show resolved Hide resolved
tests/ts/JavaScriptRequiredStringTest.js Outdated Show resolved Hide resolved
tests/ts/required_strings_generated.js Show resolved Hide resolved
ts/builder.ts Outdated Show resolved Hide resolved
@jmillan
Copy link
Contributor Author

jmillan commented Jan 4, 2023

@dbaileychess, thanks for the review. All suggestions have been applied.

I must say that this same problem happens in C++. And thus, maybe everywhere. I've checked the C++ side and even thought the language is not a barrier for me, I didn't find a proper way to apply the fix.

How to proceed here, considering all languages are susceptible to have this issue?

Verifty that the field is present in the vtable.
@jmillan
Copy link
Contributor Author

jmillan commented Jan 8, 2023

I must say that this same problem happens in C++. And thus, maybe everywhere. I've checked the C++ side and even thought the language is not a barrier for me, I didn't find a proper way to apply the fix.

How to proceed here, considering all languages are susceptible to have this issue?

As said here this was a wrong assumption and C++ is not affected by this bug.

@jmillan jmillan changed the title [TS]: Fix vtable creation for consecutive required fileds (#7739) [TS]: builder, Fix requiredField(). Verifty that the field is present in the vtable (#7739) Jan 8, 2023
@jmillan jmillan changed the title [TS]: builder, Fix requiredField(). Verifty that the field is present in the vtable (#7739) [TS]: builder, Fix requiredField(). Verity that the field is present in the vtable (#7739) Jan 8, 2023
@jmillan
Copy link
Contributor Author

jmillan commented Jan 9, 2023

Issue description updated. The problem was not the buffer creation but a missing check (whether the field offset is in the bounds of the vtable) in builder.requiredField().

@jmillan
Copy link
Contributor Author

jmillan commented Jan 10, 2023

This PR is ready for review @dbaileychess.

@dbaileychess dbaileychess merged commit b17d59b into google:master Jan 10, 2023
@jmillan
Copy link
Contributor Author

jmillan commented Jan 13, 2023

Hi, is there an estimated time for a new release containing this fix?

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

Successfully merging this pull request may close these issues.

None yet

2 participants