Skip to content

Commit 0391ef6

Browse files
author
kalibera
committed
Warn when input bzip2 stream turns out not to be bzip2 (PR#18768).
git-svn-id: https://svn.r-project.org/R/trunk@87441 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent d523521 commit 0391ef6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/main/connections.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2072,6 +2072,15 @@ static size_t bzfile_read(void *ptr, size_t size, size_t nitems,
20722072
if (next_unused) free(next_unused);
20732073
}
20742074
} else if (bzerror != BZ_OK) {
2075+
/* This happens also when the file accidentally starts with BZh,
2076+
but is not a bzip2 file. (PR#18768) */
2077+
if (bzerror == BZ_DATA_ERROR_MAGIC)
2078+
/* FIXME: the warning probably should also be displayed for some
2079+
other errors, but not for BZ_SEQUENCE_ERROR, because that is
2080+
caused by the code above when the stream ends but there are no
2081+
"unused" bytes, and another read is attempted. */
2082+
warning(_("file '%s' appears not to be compressed by bzip2"),
2083+
R_ExpandFileName(con->description));
20752084
/* bzlib docs say in this case n is invalid - but historically
20762085
we still used n in that case, so I keep it for now */
20772086
nread += n;

0 commit comments

Comments
 (0)