Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 6258226

Browse files
zhangxp1998Gerrit Code Review
authored andcommitted
Merge "Fix a bug where small manifest isn't read"
2 parents 4a5ee93 + c05d0bd commit 6258226

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

tools/ota_analysis/src/services/payload.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,20 @@ class OTAPayloadBlobWriter extends zip.Writer {
7272
// Once the prefixLength is non-zero, the address of manifest and signature
7373
// become known and can be read in. Otherwise the header needs to be read
7474
// in first to determine the prefixLength.
75-
if (this.prefixLength > 0) {
76-
if (this.offset >= this.prefixLength) {
77-
await this.payload.readManifest(this.blob)
78-
await this.payload.readSignature(this.blob)
79-
}
80-
} else if (this.offset >= _PAYLOAD_HEADER_SIZE) {
75+
if (this.offset >= _PAYLOAD_HEADER_SIZE) {
8176
await this.payload.readHeader(this.blob)
8277
this.prefixLength =
8378
_PAYLOAD_HEADER_SIZE
8479
+ this.payload.manifest_len
8580
+ this.payload.metadata_signature_len
86-
return
81+
console.log(`Computed metadata length: ${this.prefixLength}`);
82+
}
83+
if (this.prefixLength > 0) {
84+
console.log(`${this.offset}/${this.prefixLength}`);
85+
if (this.offset >= this.prefixLength) {
86+
await this.payload.readManifest(this.blob)
87+
await this.payload.readSignature(this.blob)
88+
}
8789
}
8890
// The prefix has everything we need (header, manifest, signature). Once
8991
// the offset is beyond the prefix, no need to move on.
@@ -159,12 +161,12 @@ export class Payload {
159161
this.buffer.slice(this.cursor, this.cursor + size))
160162
if (typeof view.getBigUint64 !== "function") {
161163
view.getBigUint64 =
162-
function(offset) {
163-
const a = BigInt(view.getUint32(offset))
164-
const b = BigInt(view.getUint32(offset + 4))
165-
const bigNumber = a * 4294967296n + b
166-
return bigNumber
167-
}
164+
function (offset) {
165+
const a = BigInt(view.getUint32(offset))
166+
const b = BigInt(view.getUint32(offset + 4))
167+
const bigNumber = a * 4294967296n + b
168+
return bigNumber
169+
}
168170
}
169171
this.cursor += size
170172
switch (size) {

0 commit comments

Comments
 (0)