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

Crash in read_BIN2R() when reading an empty file with forcedVersion #225

Closed
mcol opened this issue Sep 10, 2024 · 2 comments
Closed

Crash in read_BIN2R() when reading an empty file with forcedVersion #225

mcol opened this issue Sep 10, 2024 · 2 comments

Comments

@mcol
Copy link
Contributor

mcol commented Sep 10, 2024

See this example:

zero <- tempfile(pattern = "zero", fileext = ".binx")
write(raw(), zero)

## this is fine
read_BIN2R(zero, verbose = FALSE)
# Error: [read_BIN2R()] BIN/BINX format version (0a) is not supported or file is broken. Supported
#  version numbers are: 03, 04, 05, 06, 07, 08

## this crashes
read_BIN2R(zero, verbose = FALSE, forced.VersionNumber = 8)
# Error in if (temp.RECTYPE != 0 & temp.RECTYPE != 1 & temp.RECTYPE != 128) { : 
#  argument is of length zero

When we force the version number, the code keeps reading the input file for the next few fields, but it never checks whether they are valid, so it eventually crashes.

@RLumSK
Copy link
Member

RLumSK commented Sep 10, 2024

Thanks, this is really an edge case but it makes sense to check this.

@mcol
Copy link
Contributor Author

mcol commented Sep 10, 2024

Fixed by #226.

@mcol mcol closed this as completed Sep 10, 2024
@mcol mcol added this to the v0.9.25 (autumn CRAN release) milestone Sep 10, 2024
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

No branches or pull requests

2 participants