Open files in binary mode This turns off some misfeatures on Windows, and does nothing on POSIX. Signed-off-by: Ran Benita <ran@unusedvar.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
diff --git a/bench/compose.c b/bench/compose.c
index 6951bd5..7ff0798 100644
--- a/bench/compose.c
+++ b/bench/compose.c
@@ -46,7 +46,7 @@ main(void)
assert(ctx);
path = test_get_path("compose/en_US.UTF-8/Compose");
- file = fopen(path, "r");
+ file = fopen(path, "rb");
if (file == NULL) {
perror(path);
free(path);
diff --git a/fuzz/compose/target.c b/fuzz/compose/target.c
index a7f15c1..25b4a25 100644
--- a/fuzz/compose/target.c
+++ b/fuzz/compose/target.c
@@ -31,7 +31,7 @@ main(int argc, char *argv[])
while (__AFL_LOOP(1000))
#endif
{
- file = fopen(argv[1], "r");
+ file = fopen(argv[1], "rb");
assert(file);
table = xkb_compose_table_new_from_file(ctx, file,
"en_US.UTF-8",
diff --git a/fuzz/keymap/target.c b/fuzz/keymap/target.c
index e8c6fb5..9984476 100644
--- a/fuzz/keymap/target.c
+++ b/fuzz/keymap/target.c
@@ -30,7 +30,7 @@ main(int argc, char *argv[])
while (__AFL_LOOP(1000))
#endif
{
- file = fopen(argv[1], "r");
+ file = fopen(argv[1], "rb");
assert(file);
keymap = xkb_keymap_new_from_file(ctx, file,
XKB_KEYMAP_FORMAT_TEXT_V1,
diff --git a/src/compose/parser.c b/src/compose/parser.c
index c1ec0f8..0f85a92 100644
--- a/src/compose/parser.c
+++ b/src/compose/parser.c
@@ -478,7 +478,7 @@ do_include(struct xkb_compose_table *table, struct scanner *s,
return false;
}
- file = fopen(path, "r");
+ file = fopen(path, "rb");
if (!file) {
scanner_err(s, "failed to open included Compose file \"%s\": %s",
path, strerror(errno));
diff --git a/src/compose/paths.c b/src/compose/paths.c
index f2a28b4..f37c759 100644
--- a/src/compose/paths.c
+++ b/src/compose/paths.c
@@ -67,7 +67,7 @@ resolve_name(const char *filename, enum resolve_name_direction direction,
if (ret < 0 || (size_t) ret >= sizeof(path))
return false;
- file = fopen(path, "r");
+ file = fopen(path, "rb");
if (!file)
return false;
diff --git a/src/compose/table.c b/src/compose/table.c
index cba577f..bdfb907 100644
--- a/src/compose/table.c
+++ b/src/compose/table.c
@@ -178,14 +178,14 @@ xkb_compose_table_new_from_locale(struct xkb_context *ctx,
cpath = get_xcomposefile_path();
if (cpath) {
- file = fopen(cpath, "r");
+ file = fopen(cpath, "rb");
if (file)
goto found_path;
}
cpath = path = get_home_xcompose_file_path();
if (path) {
- file = fopen(path, "r");
+ file = fopen(path, "rb");
if (file)
goto found_path;
}
@@ -194,7 +194,7 @@ xkb_compose_table_new_from_locale(struct xkb_context *ctx,
cpath = path = get_locale_compose_file_path(table->locale);
if (path) {
- file = fopen(path, "r");
+ file = fopen(path, "rb");
if (file)
goto found_path;
}
diff --git a/src/xkbcomp/include.c b/src/xkbcomp/include.c
index 56b51cc..8b97558 100644
--- a/src/xkbcomp/include.c
+++ b/src/xkbcomp/include.c
@@ -233,7 +233,7 @@ FindFileInXkbPath(struct xkb_context *ctx, const char *name,
continue;
}
- file = fopen(buf, "r");
+ file = fopen(buf, "rb");
if (file)
break;
}
diff --git a/src/xkbcomp/rules.c b/src/xkbcomp/rules.c
index 8d5c266..a4cfe49 100644
--- a/src/xkbcomp/rules.c
+++ b/src/xkbcomp/rules.c
@@ -411,7 +411,7 @@ matcher_include(struct matcher *m, struct scanner *parent_scanner,
return;
}
- file = fopen(s.buf, "r");
+ file = fopen(s.buf, "rb");
if (file) {
bool ret = read_rules_file(m->ctx, m, include_depth + 1, file, s.buf);
if (!ret)
diff --git a/test/common.c b/test/common.c
index 1a56521..3784d8b 100644
--- a/test/common.c
+++ b/test/common.c
@@ -270,7 +270,7 @@ test_compile_file(struct xkb_context *context, const char *path_rel)
if (!path)
return NULL;
- file = fopen(path, "r");
+ file = fopen(path, "rb");
if (!file) {
fprintf(stderr, "Failed to open path: %s\n", path);
free(path);
diff --git a/test/compose.c b/test/compose.c
index 89b0e7e..37d33bb 100644
--- a/test/compose.c
+++ b/test/compose.c
@@ -180,7 +180,7 @@ test_seqs(struct xkb_context *ctx)
FILE *file;
path = test_get_path("compose/en_US.UTF-8/Compose");
- file = fopen(path, "r");
+ file = fopen(path, "rb");
assert(file);
free(path);
@@ -354,7 +354,7 @@ test_state(struct xkb_context *ctx)
FILE *file;
path = test_get_path("compose/en_US.UTF-8/Compose");
- file = fopen(path, "r");
+ file = fopen(path, "rb");
assert(file);
free(path);
diff --git a/test/interactive-evdev.c b/test/interactive-evdev.c
index edf3919..79da5ec 100644
--- a/test/interactive-evdev.c
+++ b/test/interactive-evdev.c
@@ -445,7 +445,7 @@ main(int argc, char *argv[])
}
if (keymap_path) {
- FILE *file = fopen(keymap_path, "r");
+ FILE *file = fopen(keymap_path, "rb");
if (!file) {
ret = EXIT_FAILURE;
fprintf(stderr, "Couldn't open '%s': %s\n",