diff options
author | Marc Hoersken <info@marc-hoersken.de> | 2012-09-11 01:42:58 +0200 |
---|---|---|
committer | Marc Hoersken <info@marc-hoersken.de> | 2012-09-11 01:42:58 +0200 |
commit | a6df3550cf5e28eba08a449fb820469ed316389e (patch) | |
tree | 9dd2ab2c89dc80a299588830094affdf0880e569 /src | |
parent | 8a57b3c9726763208caa5223c0d3a0c6751aa1d8 (diff) | |
download | curl-a6df3550cf5e28eba08a449fb820469ed316389e.tar.gz |
tool_metalink.c: Fixed validation of binary files containing EOF
Since Windows/MinGW threat 0x1A as the EOF character, reading binary
files which contain that byte does not work using text mode.
The read function will only read until the first 0x1A byte. This
means that the hash is not computed from the whole file and the
final validation check using hash comparision fails.
Diffstat (limited to 'src')
-rw-r--r-- | src/tool_metalink.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/tool_metalink.c b/src/tool_metalink.c index 6e4a31c43..773158711 100644 --- a/src/tool_metalink.c +++ b/src/tool_metalink.c @@ -339,7 +339,8 @@ static int check_hash(const char *filename, digest_context *dctx; int check_ok; int fd; - fd = open(filename, O_RDONLY); + /* O_BINARY is required in order to avoid binary EOF in text mode */ + fd = open(filename, O_RDONLY | O_BINARY); if(fd == -1) { fprintf(error, "Metalink: validating (%s) FAILED (%s)\n", filename, strerror(errno)); |