diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2020-01-05 23:34:09 +0100 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2020-01-05 23:34:09 +0100 |
commit | 057ce728fcb43e6b91a54f98f6f6d9ed8fe680a6 (patch) | |
tree | f8fbbf51720409b25fe23e5bdbe1b1d7cafde918 /nx-X11/programs/Xserver/hw/nxagent/Dialog.c | |
parent | 46ef20bdb97bc134bb855f8604828ec314716a32 (diff) | |
parent | 80b6d6b9cc456a943e307ec069c0c395c6ba650e (diff) | |
download | nx-libs-057ce728fcb43e6b91a54f98f6f6d9ed8fe680a6.tar.gz nx-libs-057ce728fcb43e6b91a54f98f6f6d9ed8fe680a6.tar.bz2 nx-libs-057ce728fcb43e6b91a54f98f6f6d9ed8fe680a6.zip |
Merge branch 'uli42-pr/strings_fixes' into 3.6.x
Attributes GH PR #884: https://github.com/ArcticaProject/nx-libs/pull/884
Diffstat (limited to 'nx-X11/programs/Xserver/hw/nxagent/Dialog.c')
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/Dialog.c | 18 |
1 files changed, 14 insertions, 4 deletions
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 <nx/NX.h> #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. |