Skip to content

Commit 3235944

Browse files
committed
Merge branch 'master' into feature/wireshark
2 parents 443b593 + 1e6c851 commit 3235944

22 files changed

+73
-35
lines changed

.github/workflows/build.yml

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -310,14 +310,17 @@ jobs:
310310

311311
build-android:
312312
name: Build Android (on Linux)
313+
if: false #disabled due to continual failure
313314
runs-on: ubuntu-24.04
314315
steps:
315316
- uses: actions/checkout@v3
316317
- name: set up Java
317-
uses: actions/setup-java@v3
318+
uses: actions/setup-java@v4
318319
with:
319-
distribution: 'temurin'
320-
java-version: '11'
320+
distribution: temurin
321+
java-version: 17
322+
- name: set up Gradle
323+
uses: gradle/actions/setup-gradle@v4
321324
- name: set up flatc
322325
run: |
323326
cmake -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF -DFLATBUFFERS_STRICT_MODE=ON .
@@ -398,11 +401,13 @@ jobs:
398401
# https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md#xcode
399402
- name: Set up Xcode version
400403
run: sudo xcode-select -s /Applications/Xcode_14.3.app/Contents/Developer
401-
- uses: gradle/[email protected]
402-
- uses: actions/setup-java@v3
404+
- name: set up Java
405+
uses: actions/setup-java@v4
403406
with:
404-
distribution: 'temurin'
405-
java-version: '11'
407+
distribution: temurin
408+
java-version: 17
409+
- name: set up Gradle
410+
uses: gradle/actions/setup-gradle@v4
406411
- name: Build flatc
407412
run: |
408413
cmake -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF .
@@ -414,15 +419,18 @@ jobs:
414419

415420
build-kotlin-linux:
416421
name: Build Kotlin Linux
422+
if: false #disabled due to continual failure
417423
runs-on: ubuntu-24.04
418424
steps:
419425
- name: Checkout
420426
uses: actions/checkout@v3
421-
- uses: actions/setup-java@v3
427+
- name: set up Java
428+
uses: actions/setup-java@v4
422429
with:
423-
distribution: 'temurin'
424-
java-version: '11'
425-
- uses: gradle/[email protected]
430+
distribution: temurin
431+
java-version: 17
432+
- name: set up Gradle
433+
uses: gradle/actions/setup-gradle@v4
426434
- name: Build flatc
427435
run: |
428436
cmake -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF .
@@ -518,6 +526,8 @@ jobs:
518526
- uses: SwiftyLab/setup-swift@latest
519527
with:
520528
swift-version: '6.1'
529+
# To be removed when swiftylab fixes the CI
530+
visual-studio-components: Microsoft.VisualStudio.Component.Windows11SDK.22621
521531
- run: swift build
522532
- run: swift test
523533

go/grpc.go

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
package flatbuffers
22

3-
// Codec implements gRPC-go Codec which is used to encode and decode messages.
4-
var Codec = "flatbuffers"
3+
import "errors"
4+
5+
var (
6+
// Codec implements gRPC-go Codec which is used to encode and decode messages.
7+
Codec = "flatbuffers"
8+
9+
// ErrInsufficientData is returned when the data is too short to read the root UOffsetT.
10+
ErrInsufficientData = errors.New("insufficient data")
11+
12+
// ErrInvalidRootOffset is returned when the root UOffsetT is out of bounds.
13+
ErrInvalidRootOffset = errors.New("invalid root offset")
14+
)
515

616
// FlatbuffersCodec defines the interface gRPC uses to encode and decode messages. Note
717
// that implementations of this interface must be thread safe; a Codec's
@@ -15,7 +25,21 @@ func (FlatbuffersCodec) Marshal(v interface{}) ([]byte, error) {
1525

1626
// Unmarshal parses the wire format into v.
1727
func (FlatbuffersCodec) Unmarshal(data []byte, v interface{}) error {
18-
v.(flatbuffersInit).Init(data, GetUOffsetT(data))
28+
// Need at least 4 bytes to read the root table offset (UOffsetT).
29+
// Vtable soffset_t and metadata are read later during field access.
30+
if len(data) < SizeUOffsetT {
31+
return ErrInsufficientData
32+
}
33+
34+
off := GetUOffsetT(data)
35+
36+
// The root UOffsetT must be within the data buffer
37+
// Compare in the unsigned domain to avoid signedness pitfalls
38+
if off > UOffsetT(len(data)-SizeUOffsetT) {
39+
return ErrInvalidRootOffset
40+
}
41+
42+
v.(flatbuffersInit).Init(data, off)
1943
return nil
2044
}
2145

src/idl_gen_ts.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,11 +1944,15 @@ class TsGenerator : public BaseGenerator {
19441944

19451945
// Emit the fully qualified name
19461946
if (parser_.opts.generate_name_strings) {
1947+
const std::string fullyQualifiedName = struct_def.defined_namespace->GetFullyQualifiedName(struct_def.name);
1948+
19471949
GenDocComment(code_ptr);
1948-
code += "static getFullyQualifiedName():string {\n";
1950+
code += "static getFullyQualifiedName(): \"";
1951+
code += fullyQualifiedName;
1952+
code += "\" {\n";
19491953
code +=
19501954
" return '" +
1951-
struct_def.defined_namespace->GetFullyQualifiedName(struct_def.name) +
1955+
fullyQualifiedName +
19521956
"';\n";
19531957
code += "}\n\n";
19541958
}

tests/ts/my-game/example/ability.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ mutate_distance(value:number):boolean {
3333
return true;
3434
}
3535

36-
static getFullyQualifiedName():string {
36+
static getFullyQualifiedName(): "MyGame.Example.Ability" {
3737
return 'MyGame.Example.Ability';
3838
}
3939

tests/ts/my-game/example/monster.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ mutate_double_inf_default(value:number):boolean {
813813
return true;
814814
}
815815

816-
static getFullyQualifiedName():string {
816+
static getFullyQualifiedName(): "MyGame.Example.Monster" {
817817
return 'MyGame.Example.Monster';
818818
}
819819

tests/ts/my-game/example/referrable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ mutate_id(value:bigint):boolean {
4040
return true;
4141
}
4242

43-
static getFullyQualifiedName():string {
43+
static getFullyQualifiedName(): "MyGame.Example.Referrable" {
4444
return 'MyGame.Example.Referrable';
4545
}
4646

tests/ts/my-game/example/stat.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ mutate_count(value:number):boolean {
6363
return true;
6464
}
6565

66-
static getFullyQualifiedName():string {
66+
static getFullyQualifiedName(): "MyGame.Example.Stat" {
6767
return 'MyGame.Example.Stat';
6868
}
6969

tests/ts/my-game/example/struct-of-structs-of-structs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ a(obj?:StructOfStructs):StructOfStructs|null {
2020
return (obj || new StructOfStructs()).__init(this.bb_pos, this.bb!);
2121
}
2222

23-
static getFullyQualifiedName():string {
23+
static getFullyQualifiedName(): "MyGame.Example.StructOfStructsOfStructs" {
2424
return 'MyGame.Example.StructOfStructsOfStructs';
2525
}
2626

tests/ts/my-game/example/struct-of-structs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ c(obj?:Ability):Ability|null {
2929
return (obj || new Ability()).__init(this.bb_pos + 12, this.bb!);
3030
}
3131

32-
static getFullyQualifiedName():string {
32+
static getFullyQualifiedName(): "MyGame.Example.StructOfStructs" {
3333
return 'MyGame.Example.StructOfStructs';
3434
}
3535

tests/ts/my-game/example/test-simple-table-with-enum.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ mutate_color(value:Color):boolean {
4141
return true;
4242
}
4343

44-
static getFullyQualifiedName():string {
44+
static getFullyQualifiedName(): "MyGame.Example.TestSimpleTableWithEnum" {
4545
return 'MyGame.Example.TestSimpleTableWithEnum';
4646
}
4747

0 commit comments

Comments
 (0)