Skip to content

Commit ca5d722

Browse files
committed
Merge branch 'master' into feature/non_scalar_default_bfbs_support
2 parents 3218ab2 + 1e6c851 commit ca5d722

File tree

2 files changed

+48
-14
lines changed

2 files changed

+48
-14
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

0 commit comments

Comments
 (0)