From 982b9a732a34e83bb5d71ea6741a9d89a94c445c Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Thu, 1 Mar 2012 14:30:20 +0100 Subject: [PATCH] Fixed bug where fopen(3) used the wrong mode in call to fdopen(3). --- libmaxsi/fdio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libmaxsi/fdio.c b/libmaxsi/fdio.c index 9d213442..4b22148e 100644 --- a/libmaxsi/fdio.c +++ b/libmaxsi/fdio.c @@ -170,6 +170,7 @@ FILE* fopen(const char* path, const char* mode) int oflags = 0; char c; // TODO: This is too hacky and a little buggy. + const char* origmode = mode; while ( ( c = *mode++ ) ) { switch ( c ) @@ -185,6 +186,7 @@ FILE* fopen(const char* path, const char* mode) default: errno = EINVAL; return 0; } } + mode = origmode; int fd = open(path, omode | oflags, 0666); if ( fd < 0 ) { return NULL; } FILE* fp = fdopen(fd, mode);