diff options
author | Timo Teräs <timo.teras@iki.fi> | 2017-06-21 11:29:38 +0300 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2017-06-21 11:29:38 +0300 |
commit | d985d2b50a41eb5f9ba682f4afe72ac2c59b53e8 (patch) | |
tree | 767a67cd54db1beb8549106f1b729699411df431 /main/musl/0047-set-errno-when-getpw-_r-getgr-_r-and-getspnam_r-fail.patch | |
parent | 6b899d49bd1d15c8390bd53e710da0b26a36218e (diff) | |
download | aports-d985d2b50a41eb5f9ba682f4afe72ac2c59b53e8.tar.bz2 aports-d985d2b50a41eb5f9ba682f4afe72ac2c59b53e8.tar.xz |
main/musl: cherry-pick upstream fixes
Diffstat (limited to 'main/musl/0047-set-errno-when-getpw-_r-getgr-_r-and-getspnam_r-fail.patch')
-rw-r--r-- | main/musl/0047-set-errno-when-getpw-_r-getgr-_r-and-getspnam_r-fail.patch | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/main/musl/0047-set-errno-when-getpw-_r-getgr-_r-and-getspnam_r-fail.patch b/main/musl/0047-set-errno-when-getpw-_r-getgr-_r-and-getspnam_r-fail.patch new file mode 100644 index 0000000000..fa687c429d --- /dev/null +++ b/main/musl/0047-set-errno-when-getpw-_r-getgr-_r-and-getspnam_r-fail.patch @@ -0,0 +1,74 @@ +From 2d7d05f031e014068a61d3076c6178513395d2ae Mon Sep 17 00:00:00 2001 +From: Rich Felker <dalias@aerifal.cx> +Date: Thu, 15 Jun 2017 13:01:34 -0400 +Subject: [PATCH] set errno when getpw*_r, getgr*_r, and getspnam_r fail + +these functions return an error code, and are not explicitly +documented to set errno, but they are nonstandard and the historical +implementations do set errno as well, and some applications expect +this behavior. do likewise for compatibility. + +patch by Rudolph Pereira. +--- + src/passwd/getgr_r.c | 1 + + src/passwd/getpw_r.c | 1 + + src/passwd/getspnam_r.c | 8 +++++--- + 3 files changed, 7 insertions(+), 3 deletions(-) + +diff --git a/src/passwd/getgr_r.c b/src/passwd/getgr_r.c +index 7246e8a4..f3e8f603 100644 +--- a/src/passwd/getgr_r.c ++++ b/src/passwd/getgr_r.c +@@ -34,6 +34,7 @@ static int getgr_r(const char *name, gid_t gid, struct group *gr, char *buf, siz + free(mem); + free(line); + pthread_setcancelstate(cs, 0); ++ if (rv) errno = rv; + return rv; + } + +diff --git a/src/passwd/getpw_r.c b/src/passwd/getpw_r.c +index e8cc811e..0c87ab05 100644 +--- a/src/passwd/getpw_r.c ++++ b/src/passwd/getpw_r.c +@@ -27,6 +27,7 @@ static int getpw_r(const char *name, uid_t uid, struct passwd *pw, char *buf, si + } + free(line); + pthread_setcancelstate(cs, 0); ++ if (rv) errno = rv; + return rv; + } + +diff --git a/src/passwd/getspnam_r.c b/src/passwd/getspnam_r.c +index 92339528..e488b67f 100644 +--- a/src/passwd/getspnam_r.c ++++ b/src/passwd/getspnam_r.c +@@ -72,14 +72,15 @@ int getspnam_r(const char *name, struct spwd *sp, char *buf, size_t size, struct + + /* Disallow potentially-malicious user names */ + if (*name=='.' || strchr(name, '/') || !l) +- return EINVAL; ++ return errno = EINVAL; + + /* Buffer size must at least be able to hold name, plus some.. */ +- if (size < l+100) return ERANGE; ++ if (size < l+100) ++ return errno = EINVAL; + + /* Protect against truncation */ + if (snprintf(path, sizeof path, "/etc/tcb/%s/shadow", name) >= sizeof path) +- return EINVAL; ++ return errno = EINVAL; + + fd = open(path, O_RDONLY|O_NOFOLLOW|O_NONBLOCK|O_CLOEXEC); + if (fd >= 0) { +@@ -112,5 +113,6 @@ int getspnam_r(const char *name, struct spwd *sp, char *buf, size_t size, struct + break; + } + pthread_cleanup_pop(1); ++ if (rv) errno = rv; + return rv; + } +-- +2.13.0 + |