Skip to content

Commit b2d5407

Browse files
committed
SAS7BDAT: better support for Linux-created files
1 parent 8ef4197 commit b2d5407

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/sas/readstat_sas.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,9 @@ readstat_error_t sas_read_header(readstat_io_t *io, sas_header_info_t *hinfo,
309309
retval = READSTAT_ERROR_READ;
310310
goto cleanup;
311311
}
312-
char major;
312+
char major, revision_tag;
313313
int minor, revision;
314-
if (sscanf(header_end.release, "%c.%04dM%1d", &major, &minor, &revision) != 3) {
314+
if (sscanf(header_end.release, "%c.%04d%c%1d", &major, &minor, &revision_tag, &revision) != 4) {
315315
retval = READSTAT_ERROR_PARSE;
316316
goto cleanup;
317317
}
@@ -326,6 +326,11 @@ readstat_error_t sas_read_header(readstat_io_t *io, sas_header_info_t *hinfo,
326326
retval = READSTAT_ERROR_PARSE;
327327
goto cleanup;
328328
}
329+
// revision_tag is usually M, but J has been observed in the wild (not created with SAS?)
330+
if (revision_tag != 'M' && revision_tag != 'J') {
331+
retval = READSTAT_ERROR_PARSE;
332+
goto cleanup;
333+
}
329334
hinfo->minor_version = minor;
330335
hinfo->revision = revision;
331336

0 commit comments

Comments
 (0)