Ensure all calls `fopen` use "rb" mode
Some commercial systems have wrong notion about opening files in
non-binary mode, pre-emptively open all the files as binary.
diff --git a/examples/in-memory.c b/examples/in-memory.c
index e7705dd..b86089a 100644
--- a/examples/in-memory.c
+++ b/examples/in-memory.c
@@ -45,7 +45,7 @@
struct stat st;
FILE *fp;
- if ((fp = fopen(archive, "r")) == NULL) {
+ if ((fp = fopen(archive, "rb")) == NULL) {
if (errno != ENOENT) {
fprintf(stderr, "can't open %s: %s\n", archive, strerror(errno));
return -1;
diff --git a/regress/add_from_filep.c b/regress/add_from_filep.c
index cb6fe92..170e061 100644
--- a/regress/add_from_filep.c
+++ b/regress/add_from_filep.c
@@ -69,7 +69,7 @@
return 1;
}
- if ((fp = fopen(file, "r")) == NULL) {
+ if ((fp = fopen(file, "rb")) == NULL) {
fprintf(stderr, "%s: can't open input file '%s': %s\n", prg, file, strerror(errno));
return 1;
}
diff --git a/regress/ziptool_regress.c b/regress/ziptool_regress.c
index 0b60fd0..9d7b540 100644
--- a/regress/ziptool_regress.c
+++ b/regress/ziptool_regress.c
@@ -151,7 +151,7 @@
return NULL;
}
- if ((fp = fopen(archive, "r")) == NULL) {
+ if ((fp = fopen(archive, "rb")) == NULL) {
if (errno == ENOENT) {
src = zip_source_buffer_create(NULL, 0, 0, error);
}
diff --git a/src/zipcmp.c b/src/zipcmp.c
index f01876d..03ba51b 100644
--- a/src/zipcmp.c
+++ b/src/zipcmp.c
@@ -273,7 +273,7 @@
Bytef buffer[8192];
- if ((f = fopen(fname, "r")) == NULL) {
+ if ((f = fopen(fname, "rb")) == NULL) {
fprintf(stderr, "%s: can't open %s: %s\n", progname, fname, strerror(errno));
return -1;
}