mirror of
https://github.com/fluencelabs/musl
synced 2025-05-30 16:11:40 +00:00
fdopen should set errno when it fails due to invalid mode string
This commit is contained in:
parent
57d5fff5f7
commit
3b43d10faf
@ -7,7 +7,10 @@ FILE *__fdopen(int fd, const char *mode)
|
|||||||
int plus = !!strchr(mode, '+');
|
int plus = !!strchr(mode, '+');
|
||||||
|
|
||||||
/* Check for valid initial mode character */
|
/* Check for valid initial mode character */
|
||||||
if (!strchr("rwa", *mode)) return 0;
|
if (!strchr("rwa", *mode)) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Allocate FILE+buffer or fail */
|
/* Allocate FILE+buffer or fail */
|
||||||
if (!(f=malloc(sizeof *f + UNGET + BUFSIZ))) return 0;
|
if (!(f=malloc(sizeof *f + UNGET + BUFSIZ))) return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user