From cac1af52d93222e3705ea20f999ba7178010963e Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 3 Jan 2018 00:59:59 +0100 Subject: Args.c: simplify nxagentGetDialogName() --- nx-X11/programs/Xserver/hw/nxagent/Args.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'nx-X11/programs/Xserver/hw') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Args.c b/nx-X11/programs/Xserver/hw/nxagent/Args.c index ee18f3b0d..14f696e2d 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Args.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Args.c @@ -2098,31 +2098,24 @@ void ddxUseMsg() static int nxagentGetDialogName() { - snprintf(nxagentDialogName, NXAGENTDIALOGNAMELENGTH, "NX"); - if (*nxagentSessionId != '\0') { int length = strlen(nxagentSessionId); - strcpy(nxagentDialogName, "NX - "); - /* if the session id contains an MD5 hash in a well-known format cut it off */ if (length > (MD5_LENGTH * 2 + 1) && *(nxagentSessionId + (length - (MD5_LENGTH * 2 + 1))) == '-') { - strncat(nxagentDialogName, nxagentSessionId, - MIN(NXAGENTDIALOGNAMELENGTH - strlen(nxagentDialogName), length - (MD5_LENGTH * 2 + 1)) - 1); - } - else - { - strncat(nxagentDialogName, nxagentSessionId, NXAGENTDIALOGNAMELENGTH - strlen(nxagentDialogName) - 1); + length -= (MD5_LENGTH * 2 + 1); } - nxagentDialogName[NXAGENTDIALOGNAMELENGTH - 1] = '\0'; + snprintf(nxagentDialogName, NXAGENTDIALOGNAMELENGTH, "NX - %.*s", length, nxagentSessionId); return 1; } + snprintf(nxagentDialogName, NXAGENTDIALOGNAMELENGTH, "NX"); + return 0; } -- cgit v1.2.3