square / wire

gRPC and protocol buffers for Android, Kotlin, Swift and Java.
https://square.github.io/wire/
Apache License 2.0
4.23k stars 571 forks source link

Avoid crash when parsing an empty `repeated [packed=true]` for fixed-length types #3044

Closed sashaweiss-signal closed 1 month ago

sashaweiss-signal commented 1 month ago

As reported in https://github.com/square/wire/issues/3043, parsing an empty repeated uint64 [packed=true] (or other fixed-length types) currently results in a fatalError.

This change adds a check for zero length when parsing such repeated ... [packed=true] fields to avoid the fatalError. The first commit adds two unit tests that demonstrate the issue, and the second commit resolves the issue.

lickel commented 1 month ago

@dnkoutso I'll leave it to you for final merge

oldergod commented 1 month ago

@sashaweiss-signal Could you please sign our cla so that I can merge the PR?

sashaweiss-signal commented 1 month ago

@oldergod just signed the CLA. Please let me know if there's anything else I should do.

(Also, what's the release schedule for this package? Wondering when this fix will be available upstream for us to consume officially.)

Thanks again!

dnkoutso commented 1 month ago

I can take this branch and run it as a test in our large internal monorepo as an extra step of precaution.

The change LGTM.