From ce43e4346fd8c4262f14b8abcddad209e021fbf1 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sun, 29 Dec 2019 12:40:29 +0100 Subject: Dialog.c: fix format-truncation warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dialog.c: In function ‘nxagentLaunchDialog’: Dialog.c:320:53: warning: ‘%s’ directive output may be truncated writing up to 1023 bytes into a region of size 256 [-Wformat-truncation=] snprintf(dialogDisplay, sizeof(dialogDisplay), "%s", nxagentDisplayName); ^~ ~~~~~~~~~~~~~~~~~~ Dialog.c:320:5: note: ‘snprintf’ output between 1 and 1024 bytes into a destination of size 256 snprintf(dialogDisplay, sizeof(dialogDisplay), "%s", nxagentDisplayName); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- nx-X11/programs/Xserver/hw/nxagent/Dialog.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'nx-X11/programs') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Dialog.c b/nx-X11/programs/Xserver/hw/nxagent/Dialog.c index c20a6a475..2d4eb6229 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Dialog.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Dialog.c @@ -40,6 +40,7 @@ #include "Args.h" #include "Display.h" #include "Dialog.h" +#include "Utils.h" #include #include "compext/Compext.h" @@ -182,7 +183,6 @@ void nxagentResetDialog(int pid) void nxagentLaunchDialog(DialogType dialogType) { - char dialogDisplay[256]; sigset_t set, oldSet; int *pid; char *type; @@ -302,13 +302,23 @@ void nxagentLaunchDialog(DialogType dialogType) fprintf(stderr, "nxagentLaunchDialog: Launching dialog type [%d] message [%s].\n", type, message); #endif + char *dialogDisplay = NULL; + int len = 0; if (dialogType == DIALOG_FAILED_RECONNECTION) { - snprintf(dialogDisplay, sizeof(dialogDisplay), "%s", nxagentDisplayName); + len = asprintf(&dialogDisplay, "%s", nxagentDisplayName); } else { - snprintf(dialogDisplay, sizeof(dialogDisplay), ":%s", display); + len = asprintf(&dialogDisplay, ":%s", display); + } + + if (len == -1) + { + #ifdef DEBUG + fprintf(stderr, "%s: could not allocate display string.\n", __func__); + #endif + return; } /* @@ -329,7 +339,7 @@ void nxagentLaunchDialog(DialogType dialogType) DECODE_DIALOG_TYPE(dialogType), *pid, dialogDisplay); #endif - dialogDisplay[0] = '\0'; + SAFE_free(dialogDisplay); /* * Restore the previous set of blocked signal. -- cgit v1.2.3 From 2a4af0c74c7a167477d57dd1d065782516313c9b Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sun, 29 Dec 2019 12:54:07 +0100 Subject: Error.c: fix format-truncation warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Error.c: In function ‘nxagentGetSessionPath’: Error.c:543:62: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 253 [-Wformat-truncation=] snprintf(nxagentSessionDir, DEFAULT_STRING_LENGTH, "%s/C-%s", rootPath, nxagentSessionId); ^~ ~~~~~~~~~~~~~~~~ Error.c:543:5: note: ‘snprintf’ output 4 or more bytes (assuming 259) into a destination of size 256 snprintf(nxagentSessionDir, DEFAULT_STRING_LENGTH, "%s/C-%s", rootPath, nxagentSessionId); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- nx-X11/programs/Xserver/hw/nxagent/Error.c | 54 ++++++++++----------------- nx-X11/programs/Xserver/hw/nxagent/Keyboard.c | 5 --- 2 files changed, 19 insertions(+), 40 deletions(-) (limited to 'nx-X11/programs') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Error.c b/nx-X11/programs/Xserver/hw/nxagent/Error.c index 6b91ea94d..21bc7fd02 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Error.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Error.c @@ -97,7 +97,7 @@ static char nxagentRootDir[DEFAULT_STRING_LENGTH] = { 0 }; * Session log Directory. */ -static char nxagentSessionDir[DEFAULT_STRING_LENGTH] = { 0 }; +static char *nxagentSessionDir = NULL; void nxagentGetClientsPath(void); @@ -483,9 +483,13 @@ char *nxagentGetRootPath(void) return rootPath; } +/* + * returns a pointer to the static nxagentSessionDir. The caller must not free + * this pointer! + */ char *nxagentGetSessionPath(void) { - if (*nxagentSessionDir == '\0') + if (!nxagentSessionDir) { /* * If nxagentSessionId does not exist we assume that the @@ -496,7 +500,7 @@ char *nxagentGetSessionPath(void) if (*nxagentSessionId == '\0') { #ifdef TEST - fprintf(stderr, "nxagentGetSessionPath: Session id does not exist. Assuming session path NULL.\n"); + fprintf(stderr, "%s: Session id does not exist. Assuming session path NULL.\n", __func__); #endif return NULL; @@ -509,58 +513,42 @@ char *nxagentGetSessionPath(void) return NULL; } - /* FIXME: necessary? */ - snprintf(nxagentSessionDir, DEFAULT_STRING_LENGTH, "%s", rootPath); + /* FIXME: this is currently only freed if the dir cannot be created + and will last over the runtime otherwise. We should add a free call + eventually... */ + int len = asprintf(&nxagentSessionDir, "%s/C-%s", rootPath, nxagentSessionId); + SAFE_free(rootPath); - if (strlen(nxagentSessionDir) + strlen("/C-") + strlen(nxagentSessionId) > DEFAULT_STRING_LENGTH - 1) + if (len == -1) { #ifdef PANIC - fprintf(stderr, "nxagentGetSessionPath: PANIC!: Invalid value for the NX session directory '%s'.\n", - nxagentSessionDir); + fprintf(stderr, "%s: PANIC!: Could not alloc sessiondir string'.\n", __func__); #endif - SAFE_free(rootPath); - return NULL; } - snprintf(nxagentSessionDir, DEFAULT_STRING_LENGTH, "%s/C-%s", rootPath, nxagentSessionId); - - SAFE_free(rootPath); - struct stat dirStat; if ((stat(nxagentSessionDir, &dirStat) == -1) && (errno == ENOENT)) { if (mkdir(nxagentSessionDir, 0777) < 0 && (errno != EEXIST)) { #ifdef PANIC - fprintf(stderr, "nxagentGetSessionPath: PANIC! Can't create directory '%s'. Error is %d '%s'.\n", + fprintf(stderr, "%s: PANIC! Can't create directory '%s'. Error is %d '%s'.\n", __func__, nxagentSessionDir, errno, strerror(errno)); #endif + SAFE_free(nxagentSessionDir); return NULL; } } #ifdef TEST - fprintf(stderr, "nxagentGetSessionPath: NX session is '%s'.\n", - nxagentSessionDir); - #endif - - } - - char *sessionPath = strdup(nxagentSessionDir); - - if (sessionPath == NULL) - { - #ifdef PANIC - fprintf(stderr, "nxagentGetSessionPath:: PANIC! Can't allocate memory for the session path.\n"); + fprintf(stderr, "%s: NX session is '%s'.\n", __func__, nxagentSessionDir); #endif - - return NULL; } - return sessionPath; + return nxagentSessionDir; } void nxagentGetClientsPath(void) @@ -569,7 +557,7 @@ void nxagentGetClientsPath(void) { char *sessionPath = nxagentGetSessionPath(); - if (sessionPath == NULL) + if (!sessionPath) { return; } @@ -580,14 +568,10 @@ void nxagentGetClientsPath(void) fprintf(stderr, "nxagentGetClientsPath: PANIC! Invalid value for the NX clients Log File Path ''.\n"); #endif - SAFE_free(sessionPath); - return; } snprintf(nxagentClientsLogName, NXAGENTCLIENTSLOGNAMELENGTH, "%s/clients", sessionPath); - - SAFE_free(sessionPath); } return; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index c145e4dba..695fce40d 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -1449,13 +1449,8 @@ static char* getKeyboardFilePath(void) { if ((asprintf(&keyboard_file_path, "%s/keyboard", sessionpath) == -1)) { - SAFE_free(sessionpath); FatalError("malloc for keyboard file path failed."); } - else - { - SAFE_free(sessionpath); - } } else { -- cgit v1.2.3 From 03544b3ab661d3e26a806879be38331ff42e0030 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sun, 29 Dec 2019 13:15:30 +0100 Subject: Error.c: make nxagentClientsLogName a pointer no more hardcoded string length --- nx-X11/programs/Xserver/hw/nxagent/Args.c | 12 +++++++++++- nx-X11/programs/Xserver/hw/nxagent/Error.c | 19 ++++++++++--------- nx-X11/programs/Xserver/hw/nxagent/Error.h | 3 +-- 3 files changed, 22 insertions(+), 12 deletions(-) (limited to 'nx-X11/programs') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Args.c b/nx-X11/programs/Xserver/hw/nxagent/Args.c index 339c6d85b..0336be822 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Args.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Args.c @@ -1296,7 +1296,17 @@ static void nxagentParseSingleOption(char *name, char *value) } else if (strcmp(name, "clients") == 0) { - snprintf(nxagentClientsLogName, NXAGENTCLIENTSLOGNAMELENGTH, "%s", value); + char *new = strdup(value); + if (new) + { + SAFE_free(nxagentClientsLogName); + nxagentClientsLogName = new; + } + else + { + fprintf(stderr, "Warning: Ignoring option [%s] because of memory problems\n", + validateString(name)); + } return; } else if (strcmp(name, "client") == 0) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Error.c b/nx-X11/programs/Xserver/hw/nxagent/Error.c index 21bc7fd02..a5d4426e9 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Error.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Error.c @@ -79,7 +79,7 @@ static int nxagentClientsLog = -1; * Clients log file name. */ -char nxagentClientsLogName[NXAGENTCLIENTSLOGNAMELENGTH] = { 0 }; +char *nxagentClientsLogName = NULL; /* * User's home. @@ -250,12 +250,12 @@ int nxagentExitHandler(const char *message) void nxagentOpenClientsLogFile(void) { - if (*nxagentClientsLogName == '\0') + if (!nxagentClientsLogName) { nxagentGetClientsPath(); } - if (nxagentClientsLogName != NULL && *nxagentClientsLogName != '\0') + if (nxagentClientsLogName && *nxagentClientsLogName != '\0') { nxagentClientsLog = open(nxagentClientsLogName, O_RDWR | O_CREAT | O_APPEND, 0600); @@ -553,7 +553,7 @@ char *nxagentGetSessionPath(void) void nxagentGetClientsPath(void) { - if (*nxagentClientsLogName == '\0') + if (!nxagentClientsLogName) { char *sessionPath = nxagentGetSessionPath(); @@ -562,16 +562,17 @@ void nxagentGetClientsPath(void) return; } - if (strlen(sessionPath) + strlen("/clients") > NXAGENTCLIENTSLOGNAMELENGTH - 1) + /* FIXME: this is currently never freed as it is thought to last + over the complete runtime. We should add a free call at shutdown + eventually... */ + int len = asprintf(&nxagentClientsLogName, "%s/clients", sessionPath); + if (len == -1) { #ifdef PANIC - fprintf(stderr, "nxagentGetClientsPath: PANIC! Invalid value for the NX clients Log File Path ''.\n"); + fprintf(stderr, "%s: PANIC! Could not alloc NX clients Log File Path.\n", __func__); #endif - return; } - - snprintf(nxagentClientsLogName, NXAGENTCLIENTSLOGNAMELENGTH, "%s/clients", sessionPath); } return; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Error.h b/nx-X11/programs/Xserver/hw/nxagent/Error.h index f23385e0a..9f5cfef74 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Error.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Error.h @@ -30,8 +30,7 @@ * Clients log file name. */ -#define NXAGENTCLIENTSLOGNAMELENGTH 256 -extern char nxagentClientsLogName[NXAGENTCLIENTSLOGNAMELENGTH]; +extern char *nxagentClientsLogName; extern char nxagentVerbose; -- cgit v1.2.3 From d6cc85e56c49f77f75e9bc33753e7d996d9a4b80 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sun, 29 Dec 2019 13:26:34 +0100 Subject: Error.c: make nxagentHomeDir a pointer no more hardcoded string length --- nx-X11/programs/Xserver/hw/nxagent/Error.c | 43 ++++++++++++------------------ 1 file changed, 17 insertions(+), 26 deletions(-) (limited to 'nx-X11/programs') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Error.c b/nx-X11/programs/Xserver/hw/nxagent/Error.c index a5d4426e9..14c5321d4 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Error.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Error.c @@ -85,7 +85,7 @@ char *nxagentClientsLogName = NULL; * User's home. */ -static char nxagentHomeDir[DEFAULT_STRING_LENGTH] = { 0 }; +static char *nxagentHomeDir = NULL; /* * NX root directory. @@ -323,9 +323,13 @@ void nxagentEndRedirectToClientsLog(void) nxagentCloseClientsLogFile(); } +/* + * returns a pointer to the static nxagentHomeDir. The caller must not free + * this pointer! + */ char *nxagentGetHomePath(void) { - if (*nxagentHomeDir == '\0') + if (!nxagentHomeDir) { /* * Check the NX_HOME environment. @@ -336,7 +340,7 @@ char *nxagentGetHomePath(void) if (homeEnv == NULL || *homeEnv == '\0') { #ifdef TEST - fprintf(stderr, "nxagentGetHomePath: No environment for NX_HOME.\n"); + fprintf(stderr, "%s: No environment for NX_HOME.\n", __func__); #endif homeEnv = getenv("HOME"); @@ -344,40 +348,31 @@ char *nxagentGetHomePath(void) if (homeEnv == NULL || *homeEnv == '\0') { #ifdef PANIC - fprintf(stderr, "nxagentGetHomePath: PANIC! No environment for HOME.\n"); + fprintf(stderr, "%s: PANIC! No environment for HOME.\n", __func__); #endif return NULL; } } - if (strlen(homeEnv) > DEFAULT_STRING_LENGTH - 1) + /* FIXME: this is currently never freed as it is thought to last + over the complete runtime. We should add a free call at shutdown + eventually... */ + nxagentHomeDir = strdup(homeEnv); + if (!nxagentHomeDir) { #ifdef PANIC - fprintf(stderr, "nxagentGetHomePath: PANIC! Invalid value for the NX " - "home directory '%s'.\n", homeEnv); + fprintf(stderr, "%s: PANIC! Can't allocate memory for the home path.\n", __func__); #endif + return NULL; } - snprintf(nxagentHomeDir, DEFAULT_STRING_LENGTH, "%s", homeEnv); - #ifdef TEST - fprintf(stderr, "nxagentGetHomePath: Assuming NX user's home directory '%s'.\n", nxagentHomeDir); - #endif - } - - char *homePath = strdup(nxagentHomeDir); - - if (homePath == NULL) - { - #ifdef PANIC - fprintf(stderr, "nxagentGetHomePath: PANIC! Can't allocate memory for the home path.\n"); + fprintf(stderr, "%s: Assuming NX user's home directory '%s'.\n", __func__, nxagentHomeDir); #endif - - return NULL; } - return homePath; + return nxagentHomeDir; } char *nxagentGetRootPath(void) @@ -416,8 +411,6 @@ char *nxagentGetRootPath(void) "home directory '%s'.\n", homeEnv); #endif - SAFE_free(homeEnv); - return NULL; } @@ -427,8 +420,6 @@ char *nxagentGetRootPath(void) snprintf(nxagentRootDir, DEFAULT_STRING_LENGTH, "%s/.nx", homeEnv); - SAFE_free(homeEnv); - /* * Create the NX root directory. */ -- cgit v1.2.3 From 609b23f1981930a9036186c0f8751dc84c198b05 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sun, 29 Dec 2019 13:35:09 +0100 Subject: Error.c: make nxagentRootDir a pointer no more hardcoded string length --- nx-X11/programs/Xserver/hw/nxagent/Error.c | 59 +++++++++++------------------- 1 file changed, 22 insertions(+), 37 deletions(-) (limited to 'nx-X11/programs') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Error.c b/nx-X11/programs/Xserver/hw/nxagent/Error.c index 14c5321d4..7daee1829 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Error.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Error.c @@ -91,7 +91,7 @@ static char *nxagentHomeDir = NULL; * NX root directory. */ -static char nxagentRootDir[DEFAULT_STRING_LENGTH] = { 0 }; +static char *nxagentRootDir = NULL; /* * Session log Directory. @@ -375,9 +375,13 @@ char *nxagentGetHomePath(void) return nxagentHomeDir; } +/* + * returns a pointer to the static nxagentRootDir. The caller must not free + * this pointer! + */ char *nxagentGetRootPath(void) { - if (*nxagentRootDir == '\0') + if (!nxagentRootDir) { /* * Check the NX_ROOT environment. @@ -388,7 +392,7 @@ char *nxagentGetRootPath(void) if (rootEnv == NULL || *rootEnv == '\0') { #ifdef TEST - fprintf(stderr, "nxagentGetRootPath: WARNING! No environment for NX_ROOT.\n"); + fprintf(stderr, "%s: WARNING! No environment for NX_ROOT.\n", __func__); #endif /* @@ -403,23 +407,23 @@ char *nxagentGetRootPath(void) return NULL; } - if (strlen(homeEnv) > DEFAULT_STRING_LENGTH - - strlen("/.nx") - 1) + /* FIXME: this is currently never freed as it is thought to last + over the complete runtime. We should add a free call at shutdown + eventually... */ + int len = asprintf(&nxagentRootDir, "%s/.nx", homeEnv); + if (len == -1) { #ifdef PANIC - fprintf(stderr, "nxagentGetRootPath: PANIC! Invalid value for the NX " - "home directory '%s'.\n", homeEnv); + fprintf(stderr, "%s: could not build NX Root Dir string\n", __func__); #endif return NULL; } #ifdef TEST - fprintf(stderr, "nxagentGetRootPath: Assuming NX root directory in '%s'.\n", homeEnv); + fprintf(stderr, "%s: Assuming NX root directory in '%s'.\n", __func__, homeEnv); #endif - snprintf(nxagentRootDir, DEFAULT_STRING_LENGTH, "%s/.nx", homeEnv); - /* * Create the NX root directory. */ @@ -430,7 +434,7 @@ char *nxagentGetRootPath(void) if (mkdir(nxagentRootDir, 0777) < 0 && (errno != EEXIST)) { #ifdef PANIC - fprintf(stderr, "nxagentGetRootPath: PANIC! Can't create directory '%s'. Error is %d '%s'.\n", + fprintf(stderr, "%s: PANIC! Can't create directory '%s'. Error is %d '%s'.\n", __func__, nxagentRootDir, errno, strerror(errno)); #endif @@ -440,38 +444,20 @@ char *nxagentGetRootPath(void) } else { - if (strlen(rootEnv) > DEFAULT_STRING_LENGTH - 1) - { - #ifdef PANIC - fprintf(stderr, "nxagentGetRootPath: PANIC! Invalid value for the NX root directory '%s'.\n", - rootEnv); - #endif - - return NULL; - } - - snprintf(nxagentRootDir, DEFAULT_STRING_LENGTH, "%s", rootEnv); + /* FIXME: this is currently never freed as it is thought to last + over the complete runtime. We should add a free call + eventually... */ + nxagentRootDir = strdup(rootEnv); } #ifdef TEST - fprintf(stderr, "nxagentGetRootPath: Assuming NX root directory '%s'.\n", + fprintf(stderr, "%s: Assuming NX root directory '%s'.\n", __func__, nxagentRootDir); #endif } - char *rootPath = strdup(nxagentRootDir); - - if (rootPath == NULL) - { - #ifdef PANIC - fprintf(stderr, "nxagentGetRootPath: Can't allocate memory for the root path.\n"); - #endif - - return NULL; - } - - return rootPath; + return nxagentRootDir; } /* @@ -499,7 +485,7 @@ char *nxagentGetSessionPath(void) char *rootPath = nxagentGetRootPath(); - if (rootPath == NULL) + if (!rootPath) { return NULL; } @@ -508,7 +494,6 @@ char *nxagentGetSessionPath(void) and will last over the runtime otherwise. We should add a free call eventually... */ int len = asprintf(&nxagentSessionDir, "%s/C-%s", rootPath, nxagentSessionId); - SAFE_free(rootPath); if (len == -1) { -- cgit v1.2.3 From 1d50b2ab3bb8cd15316e492a11ad06c4230a429c Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sun, 29 Dec 2019 13:36:06 +0100 Subject: Error.c: drop now obsolete DEFAULT_STRING_LENGTH --- nx-X11/programs/Xserver/hw/nxagent/Error.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'nx-X11/programs') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Error.c b/nx-X11/programs/Xserver/hw/nxagent/Error.c index 7daee1829..2e7a13067 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Error.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Error.c @@ -72,9 +72,6 @@ static int nxagentStderrBackup = -1; static int nxagentClientsLog = -1; -#define DEFAULT_STRING_LENGTH 256 - - /* * Clients log file name. */ -- cgit v1.2.3 From 80b6d6b9cc456a943e307ec069c0c395c6ba650e Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sun, 5 Jan 2020 23:17:19 +0100 Subject: Error.c: simplify some NULL pointer checks --- nx-X11/programs/Xserver/hw/nxagent/Error.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'nx-X11/programs') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Error.c b/nx-X11/programs/Xserver/hw/nxagent/Error.c index 2e7a13067..ab8da2db4 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Error.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Error.c @@ -334,7 +334,7 @@ char *nxagentGetHomePath(void) char *homeEnv = getenv("NX_HOME"); - if (homeEnv == NULL || *homeEnv == '\0') + if (!homeEnv || *homeEnv == '\0') { #ifdef TEST fprintf(stderr, "%s: No environment for NX_HOME.\n", __func__); @@ -342,7 +342,7 @@ char *nxagentGetHomePath(void) homeEnv = getenv("HOME"); - if (homeEnv == NULL || *homeEnv == '\0') + if (!homeEnv || *homeEnv == '\0') { #ifdef PANIC fprintf(stderr, "%s: PANIC! No environment for HOME.\n", __func__); @@ -386,7 +386,7 @@ char *nxagentGetRootPath(void) char *rootEnv = getenv("NX_ROOT"); - if (rootEnv == NULL || *rootEnv == '\0') + if (!rootEnv || *rootEnv == '\0') { #ifdef TEST fprintf(stderr, "%s: WARNING! No environment for NX_ROOT.\n", __func__); @@ -399,7 +399,7 @@ char *nxagentGetRootPath(void) char *homeEnv = nxagentGetHomePath(); - if (homeEnv == NULL) + if (!homeEnv) { return NULL; } -- cgit v1.2.3