]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Use binary mode when opening files.
authorTim Kientzle <kientzle@acm.org>
Sat, 13 Dec 2014 05:45:33 +0000 (21:45 -0800)
committerTim Kientzle <kientzle@acm.org>
Sat, 13 Dec 2014 05:45:33 +0000 (21:45 -0800)
contrib/untar.c

index c3abf527635f327b98bde7225afa1f4cb3dbfbff..3d954f638be02ff244659cd919373e2fe62a4fe2 100644 (file)
@@ -99,7 +99,7 @@ static FILE *
 create_file(char *pathname, int mode)
 {
        FILE *f;
-       f = fopen(pathname, "w+");
+       f = fopen(pathname, "wb+");
        if (f == NULL) {
                /* Try creating parent dir and then creating file. */
                char *p = strrchr(pathname, '/');
@@ -107,7 +107,7 @@ create_file(char *pathname, int mode)
                        *p = '\0';
                        create_dir(pathname, 0755);
                        *p = '/';
-                       f = fopen(pathname, "w+");
+                       f = fopen(pathname, "wb+");
                }
        }
        return (f);
@@ -217,7 +217,7 @@ main(int argc, char **argv)
 
        ++argv; /* Skip program name */
        for ( ;*argv != NULL; ++argv) {
-               a = fopen(*argv, "r");
+               a = fopen(*argv, "rb");
                if (a == NULL)
                        fprintf(stderr, "Unable to open %s\n", *argv);
                else {