From 6e98e35cf24016c9789be26d33d918f6e0e3c9a1 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 28 Dec 2017 11:19:44 +0100 Subject: nxcomp: drop strncpy in favour of snprintf with very few exceptions which require careful thinking ;-) --- nxcomp/src/Auth.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'nxcomp/src/Auth.cpp') diff --git a/nxcomp/src/Auth.cpp b/nxcomp/src/Auth.cpp index d398f5f85..87955f6ab 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"); -- cgit v1.2.3