Skip to content

Commit

Permalink
Warn when input bzip2 stream turns out not to be bzip2 (PR#18768).
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.r-project.org/R/trunk@87441 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
kalibera committed Dec 13, 2024
1 parent d523521 commit 0391ef6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/connections.c
Original file line number Diff line number Diff line change
Expand Up @@ -2072,6 +2072,15 @@ static size_t bzfile_read(void *ptr, size_t size, size_t nitems,
if (next_unused) free(next_unused);
}
} else if (bzerror != BZ_OK) {
/* This happens also when the file accidentally starts with BZh,
but is not a bzip2 file. (PR#18768) */
if (bzerror == BZ_DATA_ERROR_MAGIC)
/* FIXME: the warning probably should also be displayed for some
other errors, but not for BZ_SEQUENCE_ERROR, because that is
caused by the code above when the stream ends but there are no
"unused" bytes, and another read is attempted. */
warning(_("file '%s' appears not to be compressed by bzip2"),
R_ExpandFileName(con->description));
/* bzlib docs say in this case n is invalid - but historically
we still used n in that case, so I keep it for now */
nread += n;
Expand Down

0 comments on commit 0391ef6

Please sign in to comment.