From 8d6ad569495d389b111ab8879117cc7832287fa8 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 6 Feb 2011 18:51:34 +0100 Subject: Make sure we use at least 1024 bytes when calling getpwuid_r. On some systems, sysconf may return -1 to indicate that there's no such limit (limitless), so don't create a buffer of size -1. Reviewed-by: Bradley T. Hughes --- src/gui/kernel/qapplication_x11.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index f28868c..8fef6fb 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -5657,7 +5657,7 @@ static void sm_performSaveYourself(QSessionManagerPrivate* smd) // tell the session manager about our user as well. struct passwd *entryPtr = 0; #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) - QVarLengthArray buf(sysconf(_SC_GETPW_R_SIZE_MAX)); + QVarLengthArray buf(qMax(sysconf(_SC_GETPW_R_SIZE_MAX), 1024L)); struct passwd entry; getpwuid_r(geteuid(), &entry, buf.data(), buf.size(), &entryPtr); #else -- cgit v0.12