This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch 3.6.x in repository nx-libs.
commit 4a345786c6ee3b00882f015a7ac7d1d3215c0b9f Author: Ulrich Sibiller <ul...@gmx.de> Date: Fri Nov 24 00:25:25 2017 +0100 Dialog.c,Display.c,NXdixfonts.c: replace strncpy() by snprintf where appropriate --- nx-X11/programs/Xserver/hw/nxagent/Args.h | 2 +- nx-X11/programs/Xserver/hw/nxagent/Dialog.c | 7 ++----- nx-X11/programs/Xserver/hw/nxagent/Display.c | 12 +++++------- nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c | 5 ++--- nx-X11/programs/Xserver/hw/nxagent/Reconnect.c | 2 +- 5 files changed, 11 insertions(+), 17 deletions(-) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Args.h b/nx-X11/programs/Xserver/hw/nxagent/Args.h index d60488c..0bfc44a 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Args.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Args.h @@ -53,7 +53,7 @@ struct UserGeometry{ extern Bool nxagentUseNXTrans; extern char nxagentSessionId[]; -extern char nxagentDisplayName[]; +extern char nxagentDisplayName[1024]; extern char nxagentShadowDisplayName[]; extern char nxagentWindowName[]; extern char nxagentDialogName[]; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Dialog.c b/nx-X11/programs/Xserver/hw/nxagent/Dialog.c index df6bb1c..1e394fe 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Dialog.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Dialog.c @@ -279,16 +279,13 @@ void nxagentLaunchDialog(DialogType dialogType) if (dialogType == DIALOG_FAILED_RECONNECTION) { - strncpy(dialogDisplay, nxagentDisplayName, sizeof(dialogDisplay) - 1); + snprintf(dialogDisplay, sizeof(dialogDisplay), "%s", nxagentDisplayName); } else { - strcpy(dialogDisplay, ":"); - strncat(dialogDisplay, display, sizeof(dialogDisplay) - 1 - 1); + snprintf(dialogDisplay, sizeof(dialogDisplay), ":%s", display); } - dialogDisplay[sizeof(dialogDisplay) - 1] = '\0'; - /* * We don't want to receive SIGCHLD * before we store the child pid. diff --git a/nx-X11/programs/Xserver/hw/nxagent/Display.c b/nx-X11/programs/Xserver/hw/nxagent/Display.c index 5943e53..f523dac 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Display.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Display.c @@ -1150,9 +1150,7 @@ void nxagentOpenDisplay(int argc, char *argv[]) if (*nxagentDisplayName == '\0') { - strncpy(nxagentDisplayName, XDisplayName(NULL), sizeof(nxagentDisplayName) - 1); - - nxagentDisplayName[sizeof(nxagentDisplayName) - 1] = '\0'; + snprintf(nxagentDisplayName, sizeof(nxagentDisplayName), "%s", XDisplayName(NULL)); } nxagentCloseDisplay(); @@ -1846,7 +1844,7 @@ static FILE *nxagentLookForIconFile(char *iconName, const char *permission, { strncpy(singlePath, path, (unsigned long)(end - path)); - singlePath[(unsigned long)(end - path)] = 0; + singlePath[(unsigned long)(end - path)] = '\0'; path = end + 1; } @@ -1859,7 +1857,7 @@ static FILE *nxagentLookForIconFile(char *iconName, const char *permission, if (singlePath[strlen(singlePath)- 1] == slash[0]) { - singlePath[strlen(singlePath)- 1] = 0; + singlePath[strlen(singlePath)- 1] = '\0'; } if (strlen(singlePath) + strlen(iconName) + 1 < sizeof(singlePath)<) @@ -1907,8 +1905,8 @@ Bool nxagentMakeIcon(Display *display, Pixmap *nxIcon, Pixmap *nxMask) agentIconData=nxagentIconData; } - - snprintf(default_path, PATH_MAX-1, "/usr/NX/share/images/%s", agent_icon_name); + /* FIXME: use a compile time define here, /usr/NX is a nomachine path */ + snprintf(default_path, sizeof(default_path), "/usr/NX/share/images/%s", agent_icon_name); if ((icon_fp = fopen(default_path, "r")) == NULL) { diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c b/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c index db555d5..563dacd 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c @@ -112,7 +112,7 @@ static const char *_NXGetFontPath(const char *path) * Check the environment only once. */ - if (*_NXFontPath != '\0') + if (_NXFontPath[0] != '\0') { return _NXFontPath; } @@ -140,8 +140,7 @@ static const char *_NXGetFontPath(const char *path) _NXGetFontPathError: - strncpy(_NXFontPath, path, sizeof(_NXFontPath) - 1); - _NXFontPath[sizeof(_NXFontPath) - 1] = '\0'; + snprintf(_NXFontPath, sizeof(_NXFontPath), "%s", path); #ifdef NX_TRANS_TEST fprintf(stderr, "_NXGetFontPath: Using default font path [%s].\n", _NXFontPath); diff --git a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c index cafa219..4774579 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c @@ -139,7 +139,7 @@ char stateFile[PATH_MAX]; void setStatePath(char* path) { - strncpy(stateFile, path, PATH_MAX-1); + snprintf(stateFile, PATH_MAX, "%s", path); } void saveAgentState(char* state) -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git _______________________________________________ x2go-commits mailing list x2go-commits@lists.x2go.org https://lists.x2go.org/listinfo/x2go-commits