From 22869d99a5afea929e4722177380d6d3e083ff84 Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Sat, 24 Aug 2024 09:48:54 +0900 Subject: [PATCH] Set errno to zero before calling sysconf (#2515) FreeBSD returns -1 since it has no limits for _SC_GETPW_R_SIZE_MAX and _SC_GETGR_R_SIZE_MAX but is not required to reset errno. Also fix up logging. Fixes #2514. --- src/s3fs_util.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/s3fs_util.cpp b/src/s3fs_util.cpp index c4aa19c..f2c717f 100644 --- a/src/s3fs_util.cpp +++ b/src/s3fs_util.cpp @@ -66,20 +66,22 @@ void init_sysconf_vars() // there is no hard limit on the size of the buffer needed to // store all the groups returned. + errno = 0; long res = sysconf(_SC_GETPW_R_SIZE_MAX); if(0 > res){ if (errno != 0){ - S3FS_PRN_WARN("could not get max pw length."); + S3FS_PRN_ERR("could not get max password length."); abort(); } res = 1024; // default initial length } max_password_size = res; + errno = 0; res = sysconf(_SC_GETGR_R_SIZE_MAX); if(0 > res) { if (errno != 0) { - S3FS_PRN_ERR("could not get max name length."); + S3FS_PRN_ERR("could not get max group name length."); abort(); } res = 1024; // default initial length