mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Fixed bug where fopen(3) used the wrong mode in call to fdopen(3).
This commit is contained in:
parent
081bb6481c
commit
982b9a732a
1 changed files with 2 additions and 0 deletions
|
@ -170,6 +170,7 @@ FILE* fopen(const char* path, const char* mode)
|
||||||
int oflags = 0;
|
int oflags = 0;
|
||||||
char c;
|
char c;
|
||||||
// TODO: This is too hacky and a little buggy.
|
// TODO: This is too hacky and a little buggy.
|
||||||
|
const char* origmode = mode;
|
||||||
while ( ( c = *mode++ ) )
|
while ( ( c = *mode++ ) )
|
||||||
{
|
{
|
||||||
switch ( c )
|
switch ( c )
|
||||||
|
@ -185,6 +186,7 @@ FILE* fopen(const char* path, const char* mode)
|
||||||
default: errno = EINVAL; return 0;
|
default: errno = EINVAL; return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mode = origmode;
|
||||||
int fd = open(path, omode | oflags, 0666);
|
int fd = open(path, omode | oflags, 0666);
|
||||||
if ( fd < 0 ) { return NULL; }
|
if ( fd < 0 ) { return NULL; }
|
||||||
FILE* fp = fdopen(fd, mode);
|
FILE* fp = fdopen(fd, mode);
|
||||||
|
|
Loading…
Reference in a new issue