Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:15.2:Staging:D
sddm
0001-Use-C-scoping-for-handling-buffer-deletion...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-Use-C-scoping-for-handling-buffer-deletion.patch of Package sddm
From 047ef56e5cfa757ebfcb03a248edad579564b5f3 Mon Sep 17 00:00:00 2001 From: David Edmundson <kde@davidedmundson.co.uk> Date: Thu, 7 Feb 2019 13:35:41 +0000 Subject: [PATCH] Use C++ scoping for handling buffer deletion --- src/helper/UserSession.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/helper/UserSession.cpp b/src/helper/UserSession.cpp index d4fd2cf..b3aec35 100644 --- a/src/helper/UserSession.cpp +++ b/src/helper/UserSession.cpp @@ -135,21 +135,19 @@ namespace SDDM { long bufsize = sysconf(_SC_GETPW_R_SIZE_MAX); if (bufsize == -1) bufsize = 16384; - char *buffer = (char *)malloc(bufsize); - if (buffer == NULL) + QScopedPointer<char, QScopedPointerPodDeleter> buffer(static_cast<char*>(malloc(bufsize))); + if (buffer.isNull()) exit(Auth::HELPER_OTHER_ERROR); - int err = getpwnam_r(username.constData(), &pw, buffer, bufsize, &rpw); + int err = getpwnam_r(username.constData(), &pw, buffer.data(), bufsize, &rpw); if (rpw == NULL) { if (err == 0) qCritical() << "getpwnam_r(" << username << ") username not found!"; else qCritical() << "getpwnam_r(" << username << ") failed with error: " << strerror(err); - free(buffer); exit(Auth::HELPER_OTHER_ERROR); } if (setgid(pw.pw_gid) != 0) { qCritical() << "setgid(" << pw.pw_gid << ") failed for user: " << username; - free(buffer); exit(Auth::HELPER_OTHER_ERROR); } @@ -181,7 +179,6 @@ namespace SDDM { &n_user_groups)) == -1 ) { qCritical() << "getgrouplist(" << username << ", " << pw.pw_gid << ") failed"; - free(buffer); exit(Auth::HELPER_OTHER_ERROR); } } @@ -198,7 +195,6 @@ namespace SDDM { // setgroups(2) handles duplicate groups if (setgroups(n_groups, groups) != 0) { qCritical() << "setgroups() failed for user: " << username; - free(buffer); exit (Auth::HELPER_OTHER_ERROR); } delete[] groups; @@ -210,7 +206,6 @@ namespace SDDM { if (initgroups(pw.pw_name, pw.pw_gid) != 0) { qCritical() << "initgroups(" << pw.pw_name << ", " << pw.pw_gid << ") failed for user: " << username; - free(buffer); exit(Auth::HELPER_OTHER_ERROR); } @@ -218,23 +213,21 @@ namespace SDDM { if (setuid(pw.pw_uid) != 0) { qCritical() << "setuid(" << pw.pw_uid << ") failed for user: " << username; - free(buffer); exit(Auth::HELPER_OTHER_ERROR); } if (chdir(pw.pw_dir) != 0) { qCritical() << "chdir(" << pw.pw_dir << ") failed for user: " << username; qCritical() << "verify directory exist and has sufficient permissions"; - free(buffer); exit(Auth::HELPER_OTHER_ERROR); } - free(buffer); + const QString homeDir = QString::fromLocal8Bit(pw.pw_dir); //we cannot use setStandardError file as this code is run in the child process //we want to redirect after we setuid so that the log file is owned by the user // determine stderr log file based on session type QString sessionLog = QStringLiteral("%1/%2") - .arg(QString::fromLocal8Bit(pw.pw_dir)) + .arg(homeDir) .arg(sessionType == QLatin1String("x11") ? mainConfig.X11.SessionLogFile.get() : mainConfig.Wayland.SessionLogFile.get()); -- 2.20.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor