Skip to content

Commit

Permalink
Strip trailing padding from encoded config ubjson. (#2404)
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperl committed Jun 12, 2024
1 parent 94aa83c commit 571e8c9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions system/extensions/host/run-image.toit
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,14 @@ class FirmwareServiceProvider extends FirmwareServiceProviderBase:

constructor --ota-dir-active/string? --ota-dir-inactive/string?:
catch:
config-ubjson_ = file.read-content "$ota-dir-active/$CONFIG-FILE-NAME_"
content := file.read-content "$ota-dir-active/$CONFIG-FILE-NAME_"
// TODO(kasper): We use an explicit Decoder to avoid barfing
// on any padding that follows the encoded ubjson. This is
// necessary for now, because for a while we didn't correctly
// strip such padding before writing the config file to disk.
decoder := ubjson.Decoder config-ubjson_
decoder := ubjson.Decoder content
config_ = decoder.decode
config-ubjson_ = content[..decoder.offset_]
ota-dir-active_ = ota-dir-active
ota-dir-inactive_ = ota-dir-inactive
super "system/firmware/host" --major=0 --minor=1
Expand Down

0 comments on commit 571e8c9

Please sign in to comment.