mirror of
https://git.freebsd.org/ports.git
synced 2025-07-17 17:29:23 -04:00
29 lines
996 B
C
29 lines
996 B
C
--- services/plugins/vix/vixTools.c.orig 2018-02-24 17:50:37 UTC
|
|
+++ services/plugins/vix/vixTools.c
|
|
@@ -10135,7 +10135,7 @@ abort:
|
|
struct passwd pwd;
|
|
struct passwd *ppwd = &pwd;
|
|
char *buffer = NULL; // a pool of memory for Posix_Getpwnam_r() to use.
|
|
- size_t bufferSize;
|
|
+ long bufferSize;
|
|
|
|
/*
|
|
* For POSIX systems, look up the uid of 'username', and compare
|
|
@@ -10148,9 +10148,15 @@ abort:
|
|
* Multiply by 4 to compensate for the conversion to UTF-8 by
|
|
* the Posix_Getpwnam_r() wrapper.
|
|
*/
|
|
- bufferSize = (size_t) sysconf(_SC_GETPW_R_SIZE_MAX) * 4;
|
|
+ errno = 0;
|
|
+ bufferSize = sysconf(_SC_GETPW_R_SIZE_MAX);
|
|
+ if ((errno != 0) || (bufferSize <= 0)) {
|
|
+ bufferSize = 16 * 1024; // Unlimited; pick something reasonable
|
|
+ }
|
|
|
|
- buffer = Util_SafeMalloc(bufferSize);
|
|
+ bufferSize *= 4;
|
|
+
|
|
+ buffer = Util_SafeMalloc((size_t)bufferSize);
|
|
|
|
if (Posix_Getpwnam_r(username, &pwd, buffer, bufferSize, &ppwd) != 0 ||
|
|
NULL == ppwd) {
|