From ac8c8ca54aaed1466255161a3d727dcfade4a7d9 Mon Sep 17 00:00:00 2001 From: OBATA Akio Date: Sun, 9 Aug 2020 17:34:23 +0900 Subject: Add a knob to use fixed path `iceauth` tool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `system()` and `popen()` may unsafe unless using absolute command path. Rely on PATH environment variable set by users may result in unwanted tool. Signed-off-by: OBATA Akio Signed-off-by: Slávek Banko --- dcop/dcopclient.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'dcop/dcopclient.cpp') diff --git a/dcop/dcopclient.cpp b/dcop/dcopclient.cpp index 4e46cd828..607e2e52a 100644 --- a/dcop/dcopclient.cpp +++ b/dcop/dcopclient.cpp @@ -210,13 +210,26 @@ public: TQCString DCOPClient::iceauthPath() { -#ifdef Q_OS_WIN32 +#if defined(ICEAUTH_PATH) + if ( +# if defined(Q_WS_WIN) + access(ICEAUTH_PATH, 0) == 0 +# else + access(ICEAUTH_PATH, X_OK) == 0 +# endif + ) + { + return TQCString(ICEAUTH_PATH); + } + +#elif defined(Q_OS_WIN32) char szPath[512]; char * pszFilePart; int ret; ret = SearchPathA(NULL,"iceauth.exe",NULL,sizeof(szPath)/sizeof(szPath[0]),szPath,&pszFilePart); if(ret != 0) return TQCString(szPath); + #else TQCString path = ::getenv("PATH"); if (path.isEmpty()) @@ -230,9 +243,9 @@ TQCString DCOPClient::iceauthPath() { return fPath; } - fPath = strtok(NULL, ":\b"); } + #endif return 0; } -- cgit v1.2.1