You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.9 KiB
69 lines
1.9 KiB
3 years ago
|
autofs-5.1.8 - fix sysconf(3) return handling
|
||
|
|
||
|
From: Fabian Groffen <grobian@gentoo.org>
|
||
|
|
||
|
The sysconf(3) return handling doesn't handle a -1 return with errno
|
||
|
not changed which indicated a maximum or minimum limit that's not
|
||
|
known.
|
||
|
|
||
|
Add handling of this case.
|
||
|
|
||
|
Signed-off-by: Fabian Groffen <grobian@gentoo.org>
|
||
|
Signed-off-by: Ian Kent <raven@themaw.net>
|
||
|
---
|
||
|
CHANGELOG | 1 +
|
||
|
lib/mounts.c | 13 +++++++++++--
|
||
|
2 files changed, 12 insertions(+), 2 deletions(-)
|
||
|
|
||
|
diff --git a/CHANGELOG b/CHANGELOG
|
||
|
index dacc2fa0..a063a126 100644
|
||
|
--- a/CHANGELOG
|
||
|
+++ b/CHANGELOG
|
||
|
@@ -13,6 +13,7 @@
|
||
|
- fix use after free in tree_mapent_delete_offset_tree().
|
||
|
- fix memory leak in xdr_exports().
|
||
|
- avoid calling pthread_getspecific() with NULL key_thread_attempt_id.
|
||
|
+- fix sysconf(3) return handling.
|
||
|
|
||
|
19/10/2021 autofs-5.1.8
|
||
|
- add xdr_exports().
|
||
|
diff --git a/lib/mounts.c b/lib/mounts.c
|
||
|
index c731f464..ad8f3de4 100644
|
||
|
--- a/lib/mounts.c
|
||
|
+++ b/lib/mounts.c
|
||
|
@@ -2385,11 +2385,17 @@ void set_tsd_user_vars(unsigned int logopt, uid_t uid, gid_t gid)
|
||
|
|
||
|
/* Try to get passwd info */
|
||
|
|
||
|
+ /* sysconf may return -1 with unchanged errno to indicate unlimited
|
||
|
+ * size, same for the call for _SC_GETGR_R_SIZE_MAX below
|
||
|
+ */
|
||
|
+ errno = 0;
|
||
|
tmplen = sysconf(_SC_GETPW_R_SIZE_MAX);
|
||
|
- if (tmplen < 0) {
|
||
|
+ if (tmplen < 0 && errno != 0) {
|
||
|
error(logopt, "failed to get buffer size for getpwuid_r");
|
||
|
goto free_tsv;
|
||
|
}
|
||
|
+ if (tmplen < 0)
|
||
|
+ tmplen = 1024; /* assume something reasonable */
|
||
|
|
||
|
pw_tmp = malloc(tmplen + 1);
|
||
|
if (!pw_tmp) {
|
||
|
@@ -2422,11 +2428,14 @@ void set_tsd_user_vars(unsigned int logopt, uid_t uid, gid_t gid)
|
||
|
|
||
|
/* Try to get group info */
|
||
|
|
||
|
+ errno = 0;
|
||
|
grplen = sysconf(_SC_GETGR_R_SIZE_MAX);
|
||
|
- if (grplen < 0) {
|
||
|
+ if (grplen < 0 && errno != 0) {
|
||
|
error(logopt, "failed to get buffer size for getgrgid_r");
|
||
|
goto free_tsv_home;
|
||
|
}
|
||
|
+ if (grplen < 0)
|
||
|
+ grplen = 1024;
|
||
|
|
||
|
gr_tmp = NULL;
|
||
|
status = ERANGE;
|