Fixed bug where fopen(3) used the wrong mode in call to fdopen(3).

This commit is contained in:
Jonas 'Sortie' Termansen 2012-03-01 14:30:20 +01:00
parent 081bb6481c
commit 982b9a732a
1 changed files with 2 additions and 0 deletions

View File

@ -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);