]> xenbits.xensource.com Git - libvirt.git/commitdiff
Always open files in binary mode in virFDStreamOpenFileInternal
authorClaudio Bley <cbley@av-test.de>
Tue, 24 Sep 2013 09:57:38 +0000 (11:57 +0200)
committerClaudio Bley <cbley@av-test.de>
Tue, 24 Sep 2013 12:27:41 +0000 (14:27 +0200)
On win32, using text mode for binary files might result in short
reads since ASCII character 0x1A is interpreted as EOF. Also, it
could lead to problems using the seek functions because of the \r
handling.

Signed-off-by: Claudio Bley <cbley@av-test.de>
src/fdstream.c

index 10c7c2af95c194ca4668e53771ce515d21f30c03..f7dae390d0b9bd34ec3009fa71edd127ff74c27e 100644 (file)
@@ -593,7 +593,7 @@ virFDStreamOpenFileInternal(virStreamPtr st,
     VIR_DEBUG("st=%p path=%s oflags=%x offset=%llu length=%llu mode=%o",
               st, path, oflags, offset, length, mode);
 
-    oflags |= O_NOCTTY;
+    oflags |= O_NOCTTY | O_BINARY;
 
     if (oflags & O_CREAT)
         fd = open(path, oflags, mode);