This is an automated email from the git hooks/post-receive script. x2go pushed a change to branch 3.6.x in repository nx-libs. from 2d44051 Merge branch 'uli42-pr/silence_nxcompshad_warnings' into 3.6.x new 604e096 Loop.cpp: Fix memset (size was 0) new 4107159 Loop.cpp: free display before leaving SetupDisplaySocket() new b593ede Loop.cpp: always close testSocketFD new f1905c8 Loop.cpp: delete structs when no longer required new c48748b ChannelEndPoint.cpp: re-scope/improve getSpec new c31c54c Loop.cpp: delete passed object prior to overwriting it new 3066195 Loop.cpp: some reformatting/simplification/FIXMEs new 14a5589 Loop.cpp: improve/fix usage of s(n)printf new 6d8fe66 Loop.cpp: create xServerAddrUNIX only if required new 2367fc7 Loop.cpp: drop ugly ifdef indentation new 6198e03 nxcomp: implement correct length handling for unix socket structs new 96879dc EncodeBuffer.cpp: add VALGRIND guard new eae64c4 ChannelEndPoint.cpp: fix another memleak new 17d0458 ChannelEndPoint.cpp: remove unneccessary code new ce29364 ChannelEndPoint.cpp: fix possible memleak in getUnixPath() new 9e8bd2e Loop.cpp: fix memleak happening with unknown tcp host new 6e98e35 nxcomp: drop strncpy in favour of snprintf new 367bec5 EncodeBuffer.cpp: add another VALGRIND guard new e13e31f Merge branch 'uli42-pr/fix_abstract' into 3.6.x The 19 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Summary of changes: nxcomp/src/Auth.cpp | 14 +--- nxcomp/src/ChannelEndPoint.cpp | 44 +++++++---- nxcomp/src/Children.cpp | 19 +++-- nxcomp/src/EncodeBuffer.cpp | 17 ++++- nxcomp/src/Loop.cpp | 170 +++++++++++++++++++++++++++-------------- nxcomp/src/Proxy.cpp | 20 ++--- 6 files changed, 175 insertions(+), 109 deletions(-) -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git
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 604e09686f1f7227cf61e67754d94006c90d29c4 Author: Ulrich Sibiller <uli42@gmx.de> Date: Wed Dec 27 12:12:20 2017 +0100 Loop.cpp: Fix memset (size was 0) (partially) fixes ArcticaProject/nx-libs#612 --- nxcomp/src/Loop.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nxcomp/src/Loop.cpp b/nxcomp/src/Loop.cpp index d458d65..a4c7a95 100644 --- a/nxcomp/src/Loop.cpp +++ b/nxcomp/src/Loop.cpp @@ -3936,7 +3936,7 @@ void SetupDisplaySocket(int &addr_family, sockaddr *&addr, unixSocketName[0] = '\0'; sockaddr_un *xServerAddrABSTRACT = new sockaddr_un; - memset(xServerAddrABSTRACT, 0, addr_length); + memset(xServerAddrABSTRACT, 0, sizeof(struct sockaddr_un)); xServerAddrABSTRACT -> sun_family = AF_UNIX; memcpy(xServerAddrABSTRACT -> sun_path, unixSocketName, len+1); addr_length = len +3; -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git
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 4107159e218c5d641306acf34abcb7596f63f7a5 Author: Ulrich Sibiller <uli42@gmx.de> Date: Wed Dec 27 12:13:43 2017 +0100 Loop.cpp: free display before leaving SetupDisplaySocket() fixes a memory leak --- nxcomp/src/Loop.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nxcomp/src/Loop.cpp b/nxcomp/src/Loop.cpp index a4c7a95..ce1f92a 100644 --- a/nxcomp/src/Loop.cpp +++ b/nxcomp/src/Loop.cpp @@ -3877,6 +3877,8 @@ void SetupDisplaySocket(int &addr_family, sockaddr *&addr, cerr << "Error" << ": Invalid display '" << display << "'.\n"; + delete [] display; + HandleCleanup(); } @@ -3949,6 +3951,7 @@ void SetupDisplaySocket(int &addr_family, sockaddr *&addr, close(testSocketFD); addr = (sockaddr *) xServerAddrABSTRACT; + delete [] display; return; } else { @@ -4000,6 +4003,7 @@ void SetupDisplaySocket(int &addr_family, sockaddr *&addr, cerr << "Error" << ": Error " << EGET() << " '" << ESTR() << "' checking '" << unixSocketDir << "'.\n"; + delete [] display; HandleCleanup(); } @@ -4048,6 +4052,7 @@ void SetupDisplaySocket(int &addr_family, sockaddr *&addr, cerr << "Error" << ": Unknown display host '" << display << "'.\n"; + delete [] display; HandleCleanup(); } -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git
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 b593edeb2b2d62434ca19418974227cc4ecaefa1 Author: Ulrich Sibiller <uli42@gmx.de> Date: Wed Dec 27 12:14:38 2017 +0100 Loop.cpp: always close testSocketFD was missing in the non-abstract code path (partially) fixes ArcticaProject/nx-libs#612 --- nxcomp/src/Loop.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nxcomp/src/Loop.cpp b/nxcomp/src/Loop.cpp index ce1f92a..cc0efa3 100644 --- a/nxcomp/src/Loop.cpp +++ b/nxcomp/src/Loop.cpp @@ -3944,12 +3944,13 @@ void SetupDisplaySocket(int &addr_family, sockaddr *&addr, addr_length = len +3; int ret = connect(testSocketFD, (struct sockaddr *) xServerAddrABSTRACT, addr_length); + close(testSocketFD); + if (ret == 0) { cerr << "Info" << ": Using abstract X11 socket in kernel namespace " << "for accessing DISPLAY=:" << xPort << ".\n"; - close(testSocketFD); addr = (sockaddr *) xServerAddrABSTRACT; delete [] display; return; -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git
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 c48748ba0929a488437d85732032aef78528093b Author: Ulrich Sibiller <uli42@gmx.de> Date: Wed Dec 27 12:18:28 2017 +0100 ChannelEndPoint.cpp: re-scope/improve getSpec --- nxcomp/src/ChannelEndPoint.cpp | 28 +++++++++++++++++++--------- nxcomp/src/Loop.cpp | 2 ++ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/nxcomp/src/ChannelEndPoint.cpp b/nxcomp/src/ChannelEndPoint.cpp index a1d9608..2abc0ee 100644 --- a/nxcomp/src/ChannelEndPoint.cpp +++ b/nxcomp/src/ChannelEndPoint.cpp @@ -113,13 +113,19 @@ ChannelEndPoint::setSpec(const char *hostName, long port) { bool ChannelEndPoint::getSpec(char **socketUri) const { - if (socketUri) *socketUri = NULL; + if (socketUri) + { + *socketUri = NULL; + } + else + { + return false; + } char *unixPath = NULL; char *hostName = NULL; long port = -1; - char *newSocketUri = NULL; int length = -1; if (getUnixPath(&unixPath)) @@ -133,17 +139,21 @@ ChannelEndPoint::getSpec(char **socketUri) const { if (length > 0) { - newSocketUri = static_cast<char *>(calloc(length + 1, sizeof(char))); - if (isUnixSocket()) - snprintf(newSocketUri, length+1, "unix:%s", unixPath); - else - snprintf(newSocketUri, length+1, "tcp:%s:%ld", hostName, port); + char *newSocketUri = static_cast<char *>(calloc(length + 1, sizeof(char))); + + if (newSocketUri) + { + if (isUnixSocket()) + snprintf(newSocketUri, length+1, "unix:%s", unixPath); + else + snprintf(newSocketUri, length+1, "tcp:%s:%ld", hostName, port); - if (socketUri) *socketUri = strdup(newSocketUri); + + SAFE_FREE(newSocketUri); + } } - SAFE_FREE(newSocketUri); SAFE_FREE(unixPath); SAFE_FREE(hostName); diff --git a/nxcomp/src/Loop.cpp b/nxcomp/src/Loop.cpp index 5b6c2b4..fa8ba9a 100644 --- a/nxcomp/src/Loop.cpp +++ b/nxcomp/src/Loop.cpp @@ -6222,6 +6222,8 @@ int WaitForRemote(ChannelEndPoint &socketAddress) pFD = ListenConnection(socketAddress, "NX"); + SAFE_FREE(socketUri); + socketAddress.getSpec(&socketUri); nxinfo << "Loop: Waiting for connection from " << hostLabel << " on socket '" << socketUri -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git
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 f1905c86470e5b76d72af12c9c77ecc719096b3f Author: Ulrich Sibiller <uli42@gmx.de> Date: Wed Dec 27 12:15:47 2017 +0100 Loop.cpp: delete structs when no longer required Fix another memleak (partially) fixes ArcticaProject/nx-libs#612 --- nxcomp/src/Loop.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nxcomp/src/Loop.cpp b/nxcomp/src/Loop.cpp index cc0efa3..5b6c2b4 100644 --- a/nxcomp/src/Loop.cpp +++ b/nxcomp/src/Loop.cpp @@ -3952,6 +3952,7 @@ void SetupDisplaySocket(int &addr_family, sockaddr *&addr, << "for accessing DISPLAY=:" << xPort << ".\n"; addr = (sockaddr *) xServerAddrABSTRACT; + delete xServerAddrUNIX; delete [] display; return; @@ -3960,6 +3961,7 @@ void SetupDisplaySocket(int &addr_family, sockaddr *&addr, cerr << "Info" << ": Falling back to file system X11 socket " << "for accessing DISPLAY=:" << xPort << ".\n"; + delete xServerAddrABSTRACT; #endif struct stat statInfo; -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git
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 3066195d79f5f24f99483d29e2489a91c9251d73 Author: Ulrich Sibiller <uli42@gmx.de> Date: Wed Dec 27 13:09:25 2017 +0100 Loop.cpp: some reformatting/simplification/FIXMEs (partially) fixes ArcticaProject/nx-libs#612 --- nxcomp/src/Loop.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/nxcomp/src/Loop.cpp b/nxcomp/src/Loop.cpp index e84896e..e922b55 100644 --- a/nxcomp/src/Loop.cpp +++ b/nxcomp/src/Loop.cpp @@ -3861,7 +3861,8 @@ void SetupDisplaySocket(int &addr_family, sockaddr *&addr, #ifdef __APPLE__ - if ((strncasecmp(display, "/tmp/launch", 11) == 0) || (strncasecmp(display, "/private/tmp/com.apple.launchd", 30) == 0)) + if ((strncasecmp(display, "/tmp/launch", 11) == 0) || + (strncasecmp(display, "/private/tmp/com.apple.launchd", 30) == 0)) { nxinfo << "Loop: Using launchd service on socket '" << display << "'.\n" << std::flush; @@ -3934,19 +3935,24 @@ void SetupDisplaySocket(int &addr_family, sockaddr *&addr, // fall back to Unix domain socket file. #ifdef __linux__ - int testSocketFD; - testSocketFD = socket(addr_family, SOCK_STREAM, PF_UNSPEC); + int testSocketFD = socket(addr_family, SOCK_STREAM, PF_UNSPEC); + // this name cannot be changed as it is defined this way by the + // local X server int len = sprintf(unixSocketName + 1, "/tmp/.X11-unix/X%d", xPort); unixSocketName[0] = '\0'; sockaddr_un *xServerAddrABSTRACT = new sockaddr_un; memset(xServerAddrABSTRACT, 0, sizeof(struct sockaddr_un)); xServerAddrABSTRACT -> sun_family = AF_UNIX; + // FIXME: ensure sun_path can hold len+1 bytes! memcpy(xServerAddrABSTRACT -> sun_path, unixSocketName, len+1); - addr_length = len +3; + // FIXME: comment why + 3? + addr_length = len + 3; - int ret = connect(testSocketFD, (struct sockaddr *) xServerAddrABSTRACT, addr_length); + int ret = connect(testSocketFD, + (struct sockaddr *) xServerAddrABSTRACT, + addr_length); close(testSocketFD); if (ret == 0) { -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git
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 c31c54c1b65080b7e68942e8b50dc88b5ce1279b Author: Ulrich Sibiller <uli42@gmx.de> Date: Wed Dec 27 12:54:30 2017 +0100 Loop.cpp: delete passed object prior to overwriting it --- nxcomp/src/Loop.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nxcomp/src/Loop.cpp b/nxcomp/src/Loop.cpp index fa8ba9a..e84896e 100644 --- a/nxcomp/src/Loop.cpp +++ b/nxcomp/src/Loop.cpp @@ -3141,6 +3141,9 @@ int InitBeforeNegotiation() // Get ready to open the local display. // + delete xServerAddr; + xServerAddr = NULL; + SetupDisplaySocket(xServerAddrFamily, xServerAddr, xServerAddrLength); } @@ -3780,13 +3783,13 @@ void SetupUnixSocket() // The following is a dumb copy-paste. The // nxcompsh library should offer a better // implementation. +// addr is assumed to have been freed outside // void SetupDisplaySocket(int &addr_family, sockaddr *&addr, unsigned int &addr_length) { addr_family = AF_INET; - addr = NULL; addr_length = 0; char *display; -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git
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 14a5589186c7cf0ececadedecd3db3125466d22a Author: Ulrich Sibiller <uli42@gmx.de> Date: Wed Dec 27 13:16:35 2017 +0100 Loop.cpp: improve/fix usage of s(n)printf --- nxcomp/src/Loop.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/nxcomp/src/Loop.cpp b/nxcomp/src/Loop.cpp index e922b55..c6dc3fe 100644 --- a/nxcomp/src/Loop.cpp +++ b/nxcomp/src/Loop.cpp @@ -3939,7 +3939,8 @@ void SetupDisplaySocket(int &addr_family, sockaddr *&addr, // this name cannot be changed as it is defined this way by the // local X server - int len = sprintf(unixSocketName + 1, "/tmp/.X11-unix/X%d", xPort); + int len = snprintf(unixSocketName + 1, DEFAULT_STRING_LENGTH - 1, + "/tmp/.X11-unix/X%d", xPort); unixSocketName[0] = '\0'; sockaddr_un *xServerAddrABSTRACT = new sockaddr_un; @@ -3977,7 +3978,7 @@ void SetupDisplaySocket(int &addr_family, sockaddr *&addr, char unixSocketDir[DEFAULT_STRING_LENGTH]; - snprintf(unixSocketDir, DEFAULT_STRING_LENGTH - 1, "/tmp/.X11-unix"); + snprintf(unixSocketDir, DEFAULT_STRING_LENGTH, "/tmp/.X11-unix"); #ifdef __APPLE__ @@ -3990,7 +3991,7 @@ void SetupDisplaySocket(int &addr_family, sockaddr *&addr, *slash = '\0'; } - snprintf(unixSocketDir, DEFAULT_STRING_LENGTH - 1, "%s", display); + snprintf(unixSocketDir, DEFAULT_STRING_LENGTH, "%s", display); } #endif @@ -4019,7 +4020,8 @@ void SetupDisplaySocket(int &addr_family, sockaddr *&addr, HandleCleanup(); } - sprintf(unixSocketName, "%s/X%d", unixSocketDir, xPort); + snprintf(unixSocketName, DEFAULT_STRING_LENGTH, "%s/X%d", + unixSocketDir, xPort); #ifdef __APPLE__ -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git
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 6d8fe661eb792ff9527d78073e361bb67c3b0ede Author: Ulrich Sibiller <uli42@gmx.de> Date: Wed Dec 27 14:43:22 2017 +0100 Loop.cpp: create xServerAddrUNIX only if required --- nxcomp/src/Loop.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/nxcomp/src/Loop.cpp b/nxcomp/src/Loop.cpp index c6dc3fe..1bf3a61 100644 --- a/nxcomp/src/Loop.cpp +++ b/nxcomp/src/Loop.cpp @@ -3912,10 +3912,7 @@ void SetupDisplaySocket(int &addr_family, sockaddr *&addr, nxinfo << "Loop: Using real X server on UNIX domain socket.\n" << std::flush; - sockaddr_un *xServerAddrUNIX = new sockaddr_un; - addr_family = AF_UNIX; - xServerAddrUNIX -> sun_family = AF_UNIX; // // The scope of this function is to fill either the sockaddr_un @@ -3962,7 +3959,6 @@ void SetupDisplaySocket(int &addr_family, sockaddr *&addr, << "for accessing DISPLAY=:" << xPort << ".\n"; addr = (sockaddr *) xServerAddrABSTRACT; - delete xServerAddrUNIX; delete [] display; return; @@ -4035,6 +4031,9 @@ void SetupDisplaySocket(int &addr_family, sockaddr *&addr, nxinfo << "Loop: Assuming X socket name '" << unixSocketName << "'.\n" << std::flush; + sockaddr_un *xServerAddrUNIX = new sockaddr_un; + + xServerAddrUNIX -> sun_family = AF_UNIX; strcpy(xServerAddrUNIX -> sun_path, unixSocketName); addr = (sockaddr *) xServerAddrUNIX; -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git
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 6198e0376f9ce8130af3294fa284659f0055610d Author: Ulrich Sibiller <uli42@gmx.de> Date: Wed Dec 27 14:53:58 2017 +0100 nxcomp: implement correct length handling for unix socket structs (partially) fixes ArcticaProject/nx-libs#612 --- nxcomp/src/Loop.cpp | 67 +++++++++++++++++++++++++++++++++++++++------------- nxcomp/src/Proxy.cpp | 18 +++++--------- 2 files changed, 57 insertions(+), 28 deletions(-) diff --git a/nxcomp/src/Loop.cpp b/nxcomp/src/Loop.cpp index d094bb7..3ee094e 100644 --- a/nxcomp/src/Loop.cpp +++ b/nxcomp/src/Loop.cpp @@ -55,6 +55,8 @@ #include "Misc.h" +#include <cstddef> + #ifdef __sun #include <strings.h> #endif @@ -3590,19 +3592,14 @@ int SetupAuthInstance() launchdAddrUnix.sun_family = AF_UNIX; - #ifdef __linux__ - const int launchdAddrNameLength = 108; - #else - /* POSIX/SUS does not specify a length. - * BSD derivatives generally support 104 bytes, other systems may be more constrained. - * If you happen to run into such systems, extend this section with the appropriate limit. - */ - const int launchdAddrNameLength = 104; - #endif + // determine the maximum number of characters that fit into struct + // sockaddr_un's sun_path member + std::size_t launchdAddrNameLength = + sizeof(struct sockaddr_un) - offsetof(struct sockaddr_un, sun_path); int success = -1; - strncpy(launchdAddrUnix.sun_path, displayHost, launchdAddrNameLength); + snprintf(launchdAddrUnix.sun_path, launchdAddrNameLength, "%s", displayHost); *(launchdAddrUnix.sun_path + launchdAddrNameLength - 1) = '\0'; @@ -3909,6 +3906,11 @@ void SetupDisplaySocket(int &addr_family, sockaddr *&addr, // UNIX domain port. // + // determine the maximum number of characters that fit into struct + // sockaddr_un's sun_path member + std::size_t maxlen_un = + sizeof(struct sockaddr_un) - offsetof(struct sockaddr_un, sun_path); + nxinfo << "Loop: Using real X server on UNIX domain socket.\n" << std::flush; @@ -3943,10 +3945,28 @@ void SetupDisplaySocket(int &addr_family, sockaddr *&addr, sockaddr_un *xServerAddrABSTRACT = new sockaddr_un; memset(xServerAddrABSTRACT, 0, sizeof(struct sockaddr_un)); xServerAddrABSTRACT -> sun_family = AF_UNIX; - // FIXME: ensure sun_path can hold len+1 bytes! - memcpy(xServerAddrABSTRACT -> sun_path, unixSocketName, len+1); - // FIXME: comment why + 3? - addr_length = len + 3; + + if (maxlen_un < (unsigned int)len + 1) + { + nxfatal << "Loop: PANIC! Abstract socket name '" << unixSocketName + 1 + << "' is too long!" << std::flush; + + delete [] display; + delete xServerAddrABSTRACT; + + HandleCleanup(); + } + + // copy including the leading '\0' + memcpy(xServerAddrABSTRACT -> sun_path, unixSocketName, len + 1); + + // man 7 unix: + // "an abstract socket address is distinguished (from a + // pathname socket) by the fact that sun_path[0] is a null byte + // ('\0'). The socket's address in this namespace is given by the + // additional bytes in sun_path that are covered by the specified + // length of the address structure." + addr_length = offsetof(struct sockaddr_un, sun_path) + len + 1; int ret = connect(testSocketFD, (struct sockaddr *) xServerAddrABSTRACT, @@ -4032,8 +4052,17 @@ void SetupDisplaySocket(int &addr_family, sockaddr *&addr, nxinfo << "Loop: Assuming X socket name '" << unixSocketName << "'.\n" << std::flush; - sockaddr_un *xServerAddrUNIX = new sockaddr_un; + if (maxlen_un < strlen(unixSocketName) + 1) + { + nxfatal << "Loop: PANIC! Socket name '" << unixSocketName + << "' is too long!" << std::flush; + delete [] display; + + HandleCleanup(); + } + + sockaddr_un *xServerAddrUNIX = new sockaddr_un; xServerAddrUNIX -> sun_family = AF_UNIX; strcpy(xServerAddrUNIX -> sun_path, unixSocketName); @@ -6539,12 +6568,18 @@ int PrepareProxyConnectionUnix(char** path, int* timeout, int* proxyFileDescript /* FIXME: Add socket file existence and permission checks */ + *proxyFileDescriptor = -1; *reason = -1; + // determine the maximum number of characters that fit into struct + // sockaddr_un's sun_path member + const std::size_t sockpathlen = + sizeof(struct sockaddr_un) - offsetof(struct sockaddr_un, sun_path); + sockaddr_un addr; addr.sun_family = AF_UNIX; - strncpy(addr.sun_path, *path, 108 - 1); + snprintf(addr.sun_path, sockpathlen, "%s", *path); *proxyFileDescriptor = socket(AF_UNIX, SOCK_STREAM, PF_UNSPEC); *reason = EGET(); diff --git a/nxcomp/src/Proxy.cpp b/nxcomp/src/Proxy.cpp index 437296f..963ae3d 100644 --- a/nxcomp/src/Proxy.cpp +++ b/nxcomp/src/Proxy.cpp @@ -30,6 +30,7 @@ #include <cstdio> #include <unistd.h> #include <cstdlib> +#include <cstddef> #include <string.h> #include <sys/types.h> #include <sys/stat.h> @@ -6294,19 +6295,12 @@ int Proxy::handleNewGenericConnectionFromProxyUnix(int channelId, T_channel_type serverAddrUnix.sun_family = AF_UNIX; - #ifdef __linux__ - const int serverAddrNameLength = 108; - #else - /* POSIX/SUS does not specify a length. - * BSD derivatives generally support 104 bytes, other systems may be more constrained. - * If you happen to run into such systems, extend this section with the appropriate limit. - */ - const int serverAddrNameLength = 104; - #endif - - strncpy(serverAddrUnix.sun_path, path, serverAddrNameLength); + // determine the maximum number of characters that fit into struct + // sockaddr_un's sun_path member + std::size_t serverAddrNameLength = + sizeof(struct sockaddr_un) - offsetof(struct sockaddr_un, sun_path); - *(serverAddrUnix.sun_path + serverAddrNameLength - 1) = '\0'; + snprintf(serverAddrUnix.sun_path, serverAddrNameLength, "%s", path); #ifdef TEST *logofs << "Proxy: Connecting to " << label << " server " -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git
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 2367fc714843fa0c19778e5a8e100c5f116255ee Author: Ulrich Sibiller <uli42@gmx.de> Date: Wed Dec 27 14:43:50 2017 +0100 Loop.cpp: drop ugly ifdef indentation --- nxcomp/src/Loop.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/nxcomp/src/Loop.cpp b/nxcomp/src/Loop.cpp index 1bf3a61..d094bb7 100644 --- a/nxcomp/src/Loop.cpp +++ b/nxcomp/src/Loop.cpp @@ -3962,13 +3962,14 @@ void SetupDisplaySocket(int &addr_family, sockaddr *&addr, delete [] display; return; - } else { + } - cerr << "Info" << ": Falling back to file system X11 socket " - << "for accessing DISPLAY=:" << xPort << ".\n"; + cerr << "Info" << ": Falling back to file system X11 socket " + << "for accessing DISPLAY=:" << xPort << ".\n"; - delete xServerAddrABSTRACT; - #endif + delete xServerAddrABSTRACT; + +#endif struct stat statInfo; @@ -4039,10 +4040,6 @@ void SetupDisplaySocket(int &addr_family, sockaddr *&addr, addr = (sockaddr *) xServerAddrUNIX; addr_length = sizeof(sockaddr_un); - #ifdef __linux__ - - } - #endif } else { -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git
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 96879dc69ed4004375bcfbf334e598ea55f19326 Author: Ulrich Sibiller <uli42@gmx.de> Date: Wed Dec 27 15:23:33 2017 +0100 EncodeBuffer.cpp: add VALGRIND guard Same as in WriteBuffer.cpp Valgrind will complain about uninitialized data, but we are only writing to the memory here. --- nxcomp/src/EncodeBuffer.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nxcomp/src/EncodeBuffer.cpp b/nxcomp/src/EncodeBuffer.cpp index e112113..6e6a30e 100644 --- a/nxcomp/src/EncodeBuffer.cpp +++ b/nxcomp/src/EncodeBuffer.cpp @@ -70,6 +70,13 @@ EncodeBuffer::EncodeBuffer() initialSize_ = ENCODE_BUFFER_DEFAULT_SIZE; thresholdSize_ = ENCODE_BUFFER_DEFAULT_SIZE << 1; maximumSize_ = ENCODE_BUFFER_DEFAULT_SIZE << 4; + + #ifdef VALGRIND + + memset(buffer_, '\0', size_); + + #endif + } EncodeBuffer::~EncodeBuffer() -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git
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 eae64c4a4282eb2b511ba11c6db51d00a3b49833 Author: Ulrich Sibiller <uli42@gmx.de> Date: Wed Dec 27 17:06:43 2017 +0100 ChannelEndPoint.cpp: fix another memleak ==7689== 50 bytes in 5 blocks are definitely lost in loss record 1 of 2 ==7689== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==7689== by 0x54074D9: strndup (strndup.c:43) ==7689== by 0x4E7D803: ChannelEndPoint::getTCPHostAndPort(char**, long*) const (ChannelEndPoint.cpp:309) ==7689== by 0x4EC9D93: ConnectToRemote(ChannelEndPoint&) [clone .constprop.144] (Loop.cpp:6660) ==7689== by 0x4ECB94E: SetupProxyConnection() (Loop.cpp:3204) ==7689== by 0x4ECE824: handleNegotiationInLoop(int&, fd_set&, fd_set&, timeval&) [clone .isra.129] (Loop.cpp:14312) ==7689== by 0x4ED0F8A: NXTransPrepare (Loop.cpp:2575) ==7689== by 0x4ED1C35: NXTransContinue (Loop.cpp:1609) ==7689== by 0x4ED1D7B: WaitCleanup() (Loop.cpp:4440) ==7689== by 0x4ED2343: NXTransProxy (Loop.cpp:1234) ==7689== by 0x400B2A: main (Main.c:111) --- nxcomp/src/ChannelEndPoint.cpp | 6 ++++-- nxcomp/src/Loop.cpp | 2 ++ nxcomp/src/Proxy.cpp | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/nxcomp/src/ChannelEndPoint.cpp b/nxcomp/src/ChannelEndPoint.cpp index 2abc0ee..de88183 100644 --- a/nxcomp/src/ChannelEndPoint.cpp +++ b/nxcomp/src/ChannelEndPoint.cpp @@ -273,8 +273,10 @@ ChannelEndPoint::getTCPHostAndPort(char **host, long *port) const { char *h = NULL; ssize_t h_len; - if (host) *host = NULL; - if (port) *port = 0; + if (host) + *host = NULL; + if (port) + *port = 0; if (getPort(&p)) { h_len = 0; diff --git a/nxcomp/src/Loop.cpp b/nxcomp/src/Loop.cpp index 3ee094e..ab7ea5a 100644 --- a/nxcomp/src/Loop.cpp +++ b/nxcomp/src/Loop.cpp @@ -6660,6 +6660,8 @@ int ConnectToRemote(ChannelEndPoint &socketAddress) << " in process with pid '" << getpid() << "'.\n" << std::flush; + SAFE_FREE(hostName); + if (socketAddress.getUnixPath(&unixPath)) result = PrepareProxyConnectionUnix(&unixPath, &connectTimeout, &pFD, &reason); else if (socketAddress.getTCPHostAndPort(&hostName, &portNum)) diff --git a/nxcomp/src/Proxy.cpp b/nxcomp/src/Proxy.cpp index 963ae3d..71ea090 100644 --- a/nxcomp/src/Proxy.cpp +++ b/nxcomp/src/Proxy.cpp @@ -6123,7 +6123,7 @@ int Proxy::handleNewSlaveConnection(int clientFd) int Proxy::handleNewGenericConnectionFromProxy(int channelId, T_channel_type type, ChannelEndPoint &endPoint, const char *label) { - char *unixPath, *host; + char *unixPath, *host = NULL; long port; if (endPoint.getUnixPath(&unixPath)) { -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git
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 17d045826ba98a55696cc56ebf6b56c811bf5392 Author: Ulrich Sibiller <uli42@gmx.de> Date: Wed Dec 27 19:15:23 2017 +0100 ChannelEndPoint.cpp: remove unneccessary code SAFE_FREE has set defaultUnixPath_ to NULL already --- nxcomp/src/ChannelEndPoint.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/nxcomp/src/ChannelEndPoint.cpp b/nxcomp/src/ChannelEndPoint.cpp index de88183..443c0f2 100644 --- a/nxcomp/src/ChannelEndPoint.cpp +++ b/nxcomp/src/ChannelEndPoint.cpp @@ -180,8 +180,6 @@ ChannelEndPoint::setDefaultUnixPath(char *path) { if (path && strlen(path)) defaultUnixPath_ = strdup(path); - else - defaultUnixPath_ = NULL; isUnix_ = getUnixPath(); } -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git
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 ce293647d5a63726c05260ca0e0f65a50e604ebb Author: Ulrich Sibiller <uli42@gmx.de> Date: Wed Dec 27 19:16:15 2017 +0100 ChannelEndPoint.cpp: fix possible memleak in getUnixPath() --- nxcomp/src/ChannelEndPoint.cpp | 8 +++++--- nxcomp/src/Loop.cpp | 1 + nxcomp/src/Proxy.cpp | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/nxcomp/src/ChannelEndPoint.cpp b/nxcomp/src/ChannelEndPoint.cpp index 443c0f2..7768df1 100644 --- a/nxcomp/src/ChannelEndPoint.cpp +++ b/nxcomp/src/ChannelEndPoint.cpp @@ -207,7 +207,10 @@ ChannelEndPoint::getPort(long *port) const { bool ChannelEndPoint::getUnixPath(char **unixPath) const { - if (unixPath) *unixPath = NULL; + if (unixPath) + *unixPath = NULL; + else + return false; long p; char *path = NULL; @@ -227,8 +230,7 @@ ChannelEndPoint::getUnixPath(char **unixPath) const { return false; } - if (unixPath) - *unixPath = strdup(path); + *unixPath = strdup(path); return true; } diff --git a/nxcomp/src/Loop.cpp b/nxcomp/src/Loop.cpp index ab7ea5a..1e77038 100644 --- a/nxcomp/src/Loop.cpp +++ b/nxcomp/src/Loop.cpp @@ -6661,6 +6661,7 @@ int ConnectToRemote(ChannelEndPoint &socketAddress) << "'.\n" << std::flush; SAFE_FREE(hostName); + SAFE_FREE(unixPath); if (socketAddress.getUnixPath(&unixPath)) result = PrepareProxyConnectionUnix(&unixPath, &connectTimeout, &pFD, &reason); diff --git a/nxcomp/src/Proxy.cpp b/nxcomp/src/Proxy.cpp index 71ea090..7f72fae 100644 --- a/nxcomp/src/Proxy.cpp +++ b/nxcomp/src/Proxy.cpp @@ -6123,7 +6123,7 @@ int Proxy::handleNewSlaveConnection(int clientFd) int Proxy::handleNewGenericConnectionFromProxy(int channelId, T_channel_type type, ChannelEndPoint &endPoint, const char *label) { - char *unixPath, *host = NULL; + char *unixPath = NULL, *host = NULL; long port; if (endPoint.getUnixPath(&unixPath)) { -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git
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 9e8bd2e1b6029ef04dec424fefcdf8842a0daf0f Author: Ulrich Sibiller <uli42@gmx.de> Date: Wed Dec 27 21:13:39 2017 +0100 Loop.cpp: fix memleak happening with unknown tcp host ==28424== 6 bytes in 1 blocks are definitely lost in loss record 1 of 7 ==28424== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==28424== by 0x541D4D9: strndup (strndup.c:43) ==28424== by 0x4E8AD4B: ChannelEndPoint::getTCPHostAndPort(char**, long*) const (ChannelEndPoint.cpp:311) ==28424== by 0x4EBE9CC: ConnectToRemote(ChannelEndPoint&) (Loop.cpp:6656) ==28424== by 0x4EB0A4C: SetupProxyConnection() (Loop.cpp:3205) ==28424== by 0x4EDC81A: handleNegotiationInLoop(int&, fd_set&, fd_set&, timeval&) (Loop.cpp:14308) ==28424== by 0x4EAE40F: NXTransPrepare (Loop.cpp:2576) ==28424== by 0x4EAA801: NXTransContinue (Loop.cpp:1610) ==28424== by 0x4EB50C9: WaitCleanup() (Loop.cpp:4436) ==28424== by 0x4EA9507: NXTransProxy (Loop.cpp:1235) ==28424== by 0x400B2A: main (Main.c:111) --- nxcomp/src/Loop.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/nxcomp/src/Loop.cpp b/nxcomp/src/Loop.cpp index 1e77038..b0b778a 100644 --- a/nxcomp/src/Loop.cpp +++ b/nxcomp/src/Loop.cpp @@ -6482,6 +6482,7 @@ int PrepareProxyConnectionTCP(char** hostName, long int* portNum, int* timeout, cerr << "Error" << ": Unknown remote host '" << *hostName << "'.\n"; + SAFE_FREE(*hostName); HandleCleanup(); } -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git
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 6e98e35cf24016c9789be26d33d918f6e0e3c9a1 Author: Ulrich Sibiller <uli42@gmx.de> Date: Thu Dec 28 11:19:44 2017 +0100 nxcomp: drop strncpy in favour of snprintf with very few exceptions which require careful thinking ;-) --- nxcomp/src/Auth.cpp | 14 ++++---------- nxcomp/src/Children.cpp | 19 +++++++++---------- nxcomp/src/Loop.cpp | 44 ++++++++++++++++++++------------------------ 3 files changed, 33 insertions(+), 44 deletions(-) diff --git a/nxcomp/src/Auth.cpp b/nxcomp/src/Auth.cpp index d398f5f..87955f6 100644 --- a/nxcomp/src/Auth.cpp +++ b/nxcomp/src/Auth.cpp @@ -212,16 +212,14 @@ int Auth::getCookie() if (environment != NULL && *environment != '\0') { - strncpy(file_, environment, DEFAULT_STRING_LIMIT - 1); + snprintf(file_, DEFAULT_STRING_LIMIT, "%s", environment); } else { - snprintf(file_, DEFAULT_STRING_LIMIT - 1, "%s/.Xauthority", + snprintf(file_, DEFAULT_STRING_LIMIT, "%s/.Xauthority", control -> HomePath); } - *(file_ + DEFAULT_STRING_LIMIT - 1) = '\0'; - #ifdef TEST *logofs << "Auth: Using X authorization file '" << file_ << "'.\n" << logofs_flush; @@ -242,18 +240,14 @@ int Auth::getCookie() #if defined(__CYGWIN32__) - snprintf(command, DEFAULT_STRING_LIMIT - 1, + snprintf(command, DEFAULT_STRING_LIMIT, "%s/bin/nxauth", control -> SystemPath); - *(command + DEFAULT_STRING_LIMIT - 1) = '\0'; - #elif defined(__APPLE__) - snprintf(command, DEFAULT_STRING_LIMIT - 1, + snprintf(command, DEFAULT_STRING_LIMIT, "%s/nxauth", control -> SystemPath); - *(command + DEFAULT_STRING_LIMIT - 1) = '\0'; - #else strcpy(command, "xauth"); diff --git a/nxcomp/src/Children.cpp b/nxcomp/src/Children.cpp index 9486f18..e586292 100644 --- a/nxcomp/src/Children.cpp +++ b/nxcomp/src/Children.cpp @@ -275,12 +275,14 @@ int NXTransDialog(const char *caption, const char *message, #ifdef __APPLE__ + // FIXME: missing length limitation! strcat(newPath, "/Applications/NX Client for OSX.app/Contents/MacOS:"); #endif #ifdef __CYGWIN32__ + // FIXME: missing length limitation! strcat(newPath, ".:"); #endif @@ -289,9 +291,8 @@ int NXTransDialog(const char *caption, const char *message, char *oldPath = getenv("PATH"); - strncpy(newPath + newLength, oldPath, DEFAULT_STRING_LIMIT - newLength - 1); - - newPath[DEFAULT_STRING_LIMIT - 1] = '\0'; + // FIXME: check if strncat would be better here + snprintf(newPath + newLength, DEFAULT_STRING_LIMIT - newLength, "%s", oldPath); #ifdef WARNING *logofs << "NXTransDialog: WARNING! Trying with path '" @@ -427,17 +428,13 @@ int NXTransClient(const char* display) #ifdef __sun - snprintf(newDisplay, DISPLAY_LENGTH_LIMIT - 1, "DISPLAY=%s", display); - - newDisplay[DISPLAY_LENGTH_LIMIT - 1] = '\0'; + snprintf(newDisplay, DISPLAY_LENGTH_LIMIT, "DISPLAY=%s", display); putenv(newDisplay); #else - strncpy(newDisplay, display, DISPLAY_LENGTH_LIMIT - 1); - - newDisplay[DISPLAY_LENGTH_LIMIT - 1] = '\0'; + snprintf(newDisplay, DISPLAY_LENGTH_LIMIT, "%s", display); setenv("DISPLAY", newDisplay, 1); @@ -467,6 +464,7 @@ int NXTransClient(const char* display) if (i == 0) { + // FIXME: code dpulication: this whole block is duplicated in NXTransDialog strcpy(command, "nxclient"); char newPath[DEFAULT_STRING_LIMIT]; @@ -489,7 +487,8 @@ int NXTransClient(const char* display) char *oldPath = getenv("PATH"); - strncpy(newPath + newLength, oldPath, DEFAULT_STRING_LIMIT - newLength - 1); + // FIXME: check if strncat would be better here + snprintf(newPath + newLength, DEFAULT_STRING_LIMIT - newLength, "%s", oldPath); newPath[DEFAULT_STRING_LIMIT - 1] = '\0'; diff --git a/nxcomp/src/Loop.cpp b/nxcomp/src/Loop.cpp index b0b778a..6b90378 100644 --- a/nxcomp/src/Loop.cpp +++ b/nxcomp/src/Loop.cpp @@ -4044,7 +4044,7 @@ void SetupDisplaySocket(int &addr_family, sockaddr *&addr, if (useLaunchdSocket == 1) { - strncpy(unixSocketName, displayHost, DEFAULT_STRING_LENGTH - 1); + snprintf(unixSocketName, DEFAULT_STRING_LENGTH, "%s", displayHost); } #endif @@ -7923,11 +7923,11 @@ int ParseEnvironmentOptions(const char *env, int force) if (strcasecmp(name, "options") == 0) { - strncpy(fileOptions, value, DEFAULT_STRING_LENGTH - 1); + snprintf(fileOptions, DEFAULT_STRING_LENGTH, "%s", value); } else if (strcasecmp(name, "display") == 0) { - strncpy(displayHost, value, DEFAULT_STRING_LENGTH - 1); + snprintf(displayHost, DEFAULT_STRING_LENGTH, "%s", value); } else if (strcasecmp(name, "link") == 0) { @@ -7983,7 +7983,7 @@ int ParseEnvironmentOptions(const char *env, int force) } else { - strncpy(sessionType, value, DEFAULT_STRING_LENGTH - 1); + snprintf(sessionType, DEFAULT_STRING_LENGTH, "%s", value); } } } @@ -8036,7 +8036,7 @@ int ParseEnvironmentOptions(const char *env, int force) return -1; } - strncpy(acceptHost, value, DEFAULT_STRING_LENGTH - 1); + snprintf(acceptHost, DEFAULT_STRING_LENGTH, "%s", value); } else if (strcasecmp(name, "connect") == 0) { @@ -8074,7 +8074,7 @@ int ParseEnvironmentOptions(const char *env, int force) } else if (strcasecmp(name, "session") == 0) { - strncpy(sessionFileName, value, DEFAULT_STRING_LENGTH - 1); + snprintf(sessionFileName, DEFAULT_STRING_LENGTH, "%s", value); } else if (strcasecmp(name, "errors") == 0) { @@ -8085,27 +8085,27 @@ int ParseEnvironmentOptions(const char *env, int force) // the same name. // - strncpy(errorsFileName, value, DEFAULT_STRING_LENGTH - 1); + snprintf(errorsFileName, DEFAULT_STRING_LENGTH, "%s", value); } else if (strcasecmp(name, "root") == 0) { - strncpy(rootDir, value, DEFAULT_STRING_LENGTH - 1); + snprintf(rootDir, DEFAULT_STRING_LENGTH, "%s", value); } else if (strcasecmp(name, "id") == 0) { - strncpy(sessionId, value, DEFAULT_STRING_LENGTH - 1); + snprintf(sessionId, DEFAULT_STRING_LENGTH, "%s", value); } else if (strcasecmp(name, "stats") == 0) { control -> EnableStatistics = 1; - strncpy(statsFileName, value, DEFAULT_STRING_LENGTH - 1); + snprintf(statsFileName, DEFAULT_STRING_LENGTH, "%s", value); } else if (strcasecmp(name, "cookie") == 0) { LowercaseArg("local", name, value); - strncpy(authCookie, value, DEFAULT_STRING_LENGTH - 1); + snprintf(authCookie, DEFAULT_STRING_LENGTH, "%s", value); } else if (strcasecmp(name, "nodelay") == 0) { @@ -8334,7 +8334,7 @@ int ParseEnvironmentOptions(const char *env, int force) } else if (strcasecmp(name, "font") == 0) { - strncpy(fontPort, value, DEFAULT_STRING_LENGTH - 1); + snprintf(fontPort, DEFAULT_STRING_LENGTH, "%s", value); } else if (strcasecmp(name, "slave") == 0) { @@ -8439,7 +8439,7 @@ int ParseEnvironmentOptions(const char *env, int force) } else if (strcasecmp(name, "product") == 0) { - strncpy(productName, value, DEFAULT_STRING_LENGTH - 1); + snprintf(productName, DEFAULT_STRING_LENGTH, "%s", value); } else if (strcasecmp(name, "rootless") == 0 || strcasecmp(name, "geometry") == 0 || @@ -8529,7 +8529,7 @@ int ParseEnvironmentOptions(const char *env, int force) if (*optionsFileName == '\0') { - strncpy(optionsFileName, value, DEFAULT_STRING_LENGTH - 1); + snprintf(optionsFileName, DEFAULT_STRING_LENGTH, "%s", value); nxinfo << "Loop: Assuming name of options file '" << optionsFileName << "'.\n" @@ -9249,7 +9249,7 @@ int ParseRemoteOptions(char *opts) } else { - strncpy(sessionType, value, DEFAULT_STRING_LENGTH - 1); + snprintf(sessionType, DEFAULT_STRING_LENGTH, "%s", value); } } @@ -12719,6 +12719,7 @@ int ParseHostOption(const char *opt, char *host, long &port) char newHost[DEFAULT_STRING_LENGTH] = { 0 }; + // opt cannot be longer than DEFAULT_STRING_LENGTH, this is checked above strncpy(newHost, opt, strlen(opt) - strlen(separator)); *(newHost + strlen(opt) - strlen(separator)) = '\0'; @@ -13491,10 +13492,8 @@ int ParseArg(const char *type, const char *name, const char *value) char *string = new char[strlen(value)]; - strncpy(string, value, strlen(value) - 1); - - *(string + (strlen(value) - 1)) = '\0'; - + // copy value but cut off the last character + snprintf(string, strlen(value), "%s", value); nxinfo << "Loop: Parsing integer option '" << name << "' from string '" << string << "' with base set to "; @@ -13512,18 +13511,15 @@ int ParseArg(const char *type, const char *name, const char *value) nxinfo_append << ".\n" << std::flush; - double result = atof(string) * base; + delete [] string; + if (result < 0 || result > (((unsigned) -1) >> 1)) { - delete [] string; - return -1; } - delete [] string; - nxinfo << "Loop: Integer option parsed to '" << (int) result << "'.\n" << std::flush; -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git
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 367bec59524ffc3d005ae8908c5edf42e9b01ca7 Author: Ulrich Sibiller <uli42@gmx.de> Date: Fri Dec 29 14:25:53 2017 +0100 EncodeBuffer.cpp: add another VALGRIND guard Fixes ArcticaProject/nx-libs#572 --- nxcomp/src/EncodeBuffer.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/nxcomp/src/EncodeBuffer.cpp b/nxcomp/src/EncodeBuffer.cpp index 6e6a30e..e6af38b 100644 --- a/nxcomp/src/EncodeBuffer.cpp +++ b/nxcomp/src/EncodeBuffer.cpp @@ -108,7 +108,15 @@ void EncodeBuffer::fullReset() size_ = initialSize_; buffer_ = new unsigned char[size_ + ENCODE_BUFFER_PREFIX_SIZE + - ENCODE_BUFFER_POSTFIX_SIZE] + ENCODE_BUFFER_PREFIX_SIZE; + ENCODE_BUFFER_POSTFIX_SIZE]; + + #ifdef VALGRIND + + memset(buffer_, '\0', size_ + ENCODE_BUFFER_PREFIX_SIZE + ENCODE_BUFFER_POSTFIX_SIZE); + + #endif + + buffer_ += ENCODE_BUFFER_PREFIX_SIZE; } end_ = buffer_ + size_; -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git
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 e13e31f752c0b204f964ee1df272a6b31ce51189 Merge: 2d44051 367bec5 Author: Mihai Moldovan <ionic@ionic.de> Date: Sat Dec 30 03:31:20 2017 +0100 Merge branch 'uli42-pr/fix_abstract' into 3.6.x Attributes GH PR #615: https://github.com/ArcticaProject/nx-libs/pull/615 Fixes: ArcticaProject/nx-libs#612 Fixes: ArcticaProject/nx-libs#572 nxcomp/src/Auth.cpp | 14 +--- nxcomp/src/ChannelEndPoint.cpp | 44 +++++++---- nxcomp/src/Children.cpp | 19 +++-- nxcomp/src/EncodeBuffer.cpp | 17 ++++- nxcomp/src/Loop.cpp | 170 +++++++++++++++++++++++++++-------------- nxcomp/src/Proxy.cpp | 20 ++--- 6 files changed, 175 insertions(+), 109 deletions(-) -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git