Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Truncate NIfTI header data to avoid extensions #127

Merged
merged 5 commits into from
Dec 6, 2024

Conversation

effigies
Copy link
Contributor

@effigies effigies commented Dec 4, 2024

A couple other issues were identified while debugging.

Closes #126.

Comment on lines 94 to 107
/**
* Read bytes in a range efficiently from a given file
*
* Reads up to size bytes, starting at offset.
* If EOF is encountered, the resulting array may be smaller.
*/
async readBytes(size: number, offset = 0): Promise<Uint8Array> {
const handle = this.#openHandle()
const buf = new Uint8Array(size)
await handle.seek(offset, Deno.SeekMode.Start)
await handle.read(buf)
const nbytes = await handle.read(buf) ?? 0
handle.close()
return buf
return buf.subarray(0, nbytes)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nellh This seems like it was probably the originally intended behavior?

@effigies
Copy link
Contributor Author

effigies commented Dec 4, 2024

Generally needs review. Somewhat urgent for resolving spurious validation failures on OpenNeuro.

@nellh nellh merged commit a24486c into bids-standard:main Dec 6, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Large header extensions can result in failure to parse NIfTI headers
2 participants