Repository navigation
Conversation
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
readstat_parse_csv sizes column_width, variables, is_date and is_date_time from the number of cells in the header row, but csv_metadata_cell indexes all of them with the cell number of every data row and never compares it to the header count. A CSV whose data row has more cells than the header (a single trailing comma is enough, e.g.
athen1,) makes pass 1 read and writecolumn_width[1]past an 8-byte heap allocation (ASan heap-buffer-overflow at read_csv.c:85/86 when runningreadstat in.csv meta.json out.csv), and in pass 2 thecsv_valuecallbacks in mod_csv/mod_dta/mod_sav would readvariables[]andis_date[]out of bounds as well.Skip such cells in csv_metadata_cell before any per-column array is touched, and fail the parse with READSTAT_ERROR_COLUMN_COUNT_MISMATCH once libcsv is done, since its callbacks can't stop the parse themselves. Pass 1 fails before any output is written, and rows with fewer cells than the header behave as before. Checked under ASan with the CLI's two-pass flow against libcsv: the overflow is gone, and well-formed and short-row CSVs parse the same as before.