Skip to content

Commit 640a67d

Browse files
committed
fix potential Denial of Service via specially crafted payloads
1 parent 9d41448 commit 640a67d

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

lib/types/utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ export function findBox(input: Uint8Array, boxName: string, offset: number) {
7979
const box = readBox(input, offset)
8080
if (!box) break
8181
if (box.name === boxName) return box
82-
offset += box.size
82+
// Fix the infinite loop by ensuring offset always increases
83+
// If box.size is 0, advance by at least 8 bytes (the size of the box header)
84+
offset += box.size > 0 ? box.size : 8
8385
}
8486
}

0 commit comments

Comments
 (0)