Skip to content

A file with junk bytes after the tree leads to a read failure #441

@braingram

Description

@braingram

Description of the problem

The standard mentions:

There may be an arbitrary amount of unused space between the end of the tree and the first block. To find the beginning of the first block, ASDF parsers should search from the end of the tree for the first occurrence of the block_magic_token. If the file contains no tree, the first block must begin immediately after the header with no padding.

However using the following file:

#ASDF 1.0.0
#ASDF_STANDARD 1.5.0
%YAML 1.1
%TAG ! tag:stsci.edu:asdf/
--- !core/asdf-1.1.0
asdf_library: !core/software-1.0.0 {author: The ASDF Developers, homepage: 'http://github.com/asdf-format/asdf',
  name: asdf, version: 3.0.2.dev112+g143eb2d9}
history:
  extensions:
  - !core/extension_metadata-1.0.0
    extension_class: asdf.extension._manifest.ManifestExtension
    extension_uri: asdf://asdf-format.org/core/extensions/core-1.5.0
    manifest_software: !core/software-1.0.0 {name: asdf_standard, version: 1.0.4.dev187+g1458b25}
    software: !core/software-1.0.0 {name: asdf, version: 3.0.2.dev112+g143eb2d9}
arr: !core/ndarray-1.0.0
  source: 0
  datatype: int64
  byteorder: little
  shape: [42]
...
JUNK
<<<blocks, unfortunately these don't paste well>>>

Results in an error:

OSError: Invalid bytes while reading blocks b'JUNK'

Note that null characters are ok (and don't produce an error).

System information

The error occurs for all asdf version 3.0.0 and newer. 2.15 (and 2.13) were tested and don't produce errors.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions