mirror of
https://github.com/morluto/rea.git
synced 2026-11-15 03:02:56 +00:00
fix(managed): report stream-name errors at file offsets (#4418)
Co-authored-by: Mark <m-user@Marks-MacBook-Air.local>
This commit is contained in:
1 parent
9a82046b07
commit
2d95b85aa4
2 files changed
+80
-3
No files matched your search
@@ -141,8 +141,10 @@ const requireRange = (
|
||||
|
||||
const align4 = (value: number): number => Math.ceil(value / 4) * 4;
|
||||
|
||||
/** Read within the metadata root; report failures at artifact file offsets. */
|
||||
const readStreamName = (
|
||||
bytes: Buffer,
|
||||
rootOffset: number,
|
||||
offset: number,
|
||||
): { readonly name: string; readonly next: number } => {
|
||||
const endLimit = Math.min(bytes.length, offset + 32);
|
||||
@@ -153,7 +155,7 @@ const readStreamName = (
|
||||
"invalid-stream",
|
||||
"metadata.stream-name",
|
||||
"Metadata stream name is missing a bounded terminator",
|
||||
offset,
|
||||
rootOffset + offset,
|
||||
);
|
||||
const nameBytes = bytes.subarray(offset, end);
|
||||
if (nameBytes.some((byte) => byte < 0x20 || byte > 0x7e))
|
||||
@@ -161,7 +163,7 @@ const readStreamName = (
|
||||
"invalid-stream",
|
||||
"metadata.stream-name",
|
||||
"Metadata stream name is not printable ASCII",
|
||||
offset,
|
||||
rootOffset + offset,
|
||||
);
|
||||
return {
|
||||
name: nameBytes.toString("ascii"),
|
||||
@@ -250,7 +252,7 @@ const readMetadataStreams = (
|
||||
requireRange(bytes, rootOffset, cursor, 8, "metadata.stream-header");
|
||||
const relativeOffset = bytes.readUInt32LE(cursor);
|
||||
const streamSize = bytes.readUInt32LE(cursor + 4);
|
||||
const named = readStreamName(bytes, cursor + 8);
|
||||
const named = readStreamName(bytes, rootOffset, cursor + 8);
|
||||
if (streams.has(named.name))
|
||||
throw managedFailure(
|
||||
"invalid-stream",
|
||||
|
||||
Reference in new issue
Block a user