diff options
author | Rich Felker <dalias@aerifal.cx> | 2012-06-17 20:34:04 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2012-06-17 20:34:04 -0400 |
commit | 3b43d10fafd64ac0a93fab463330a936b90ec15c (patch) | |
tree | a19299dd024837b29f76f9d02648836b51274a72 /src | |
parent | 57d5fff5f7dd9af27152c84ce041c18597a22766 (diff) | |
download | musl-3b43d10fafd64ac0a93fab463330a936b90ec15c.tar.gz musl-3b43d10fafd64ac0a93fab463330a936b90ec15c.tar.bz2 musl-3b43d10fafd64ac0a93fab463330a936b90ec15c.tar.xz musl-3b43d10fafd64ac0a93fab463330a936b90ec15c.zip |
fdopen should set errno when it fails due to invalid mode string
Diffstat (limited to 'src')
-rw-r--r-- | src/stdio/__fdopen.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/stdio/__fdopen.c b/src/stdio/__fdopen.c index 07f966a5..8bd51c66 100644 --- a/src/stdio/__fdopen.c +++ b/src/stdio/__fdopen.c @@ -7,7 +7,10 @@ FILE *__fdopen(int fd, const char *mode) int plus = !!strchr(mode, '+'); /* 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 */ if (!(f=malloc(sizeof *f + UNGET + BUFSIZ))) return 0; |