From: Rich Felker Date: Mon, 18 Jun 2012 00:34:04 +0000 (-0400) Subject: fdopen should set errno when it fails due to invalid mode string X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=3b43d10fafd64ac0a93fab463330a936b90ec15c;p=musl fdopen should set errno when it fails due to invalid mode string --- 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;