File 0167-fix-group-reading.diff of Package libqt4

qt-bugs@ issue : none
Trolltech task ID : none yet
bugs.kde.org number : None
applied: no
author: Dirk Mueller <mueller@kde.org>

in big user environments, getgrgid_r() needs more memory than sysconf() returns.
Try a bit harder.

--- src/corelib//io/qfsfileengine_unix.cpp
+++ src/corelib//io/qfsfileengine_unix.cpp
@@ -835,9 +835,13 @@
         size_max = sysconf(_SC_GETGR_R_SIZE_MAX);
         if (size_max == -1)
             size_max = 1024;
-        buf.resize(size_max);
-        struct group entry;
-        getgrgid_r(ownerId(own), &entry, buf.data(), buf.size(), &gr);
+        for (;size_max < 256000; size_max += size_max) {
+            buf.resize(size_max);
+            struct group entry;
+            if (!getgrgid_r(ownerId(own), &entry, buf.data(), buf.size(), &gr) || errno != ERANGE)
+                break;
+
+        }
 #else
         gr = getgrgid(ownerId(own));
 #endif
openSUSE Build Service is sponsored by