aboutsummaryrefslogtreecommitdiff
path: root/nxcomp/src/Auth.cpp
diff options
context:
space:
mode:
authorUlrich Sibiller <uli42@gmx.de>2017-12-28 11:19:44 +0100
committerUlrich Sibiller <uli42@gmx.de>2017-12-29 02:31:27 +0100
commit6e98e35cf24016c9789be26d33d918f6e0e3c9a1 (patch)
tree96add1b357be3fdef7eb669691a59e1cf6fc06f7 /nxcomp/src/Auth.cpp
parent9e8bd2e1b6029ef04dec424fefcdf8842a0daf0f (diff)
downloadnx-libs-6e98e35cf24016c9789be26d33d918f6e0e3c9a1.tar.gz
nx-libs-6e98e35cf24016c9789be26d33d918f6e0e3c9a1.tar.bz2
nx-libs-6e98e35cf24016c9789be26d33d918f6e0e3c9a1.zip
nxcomp: drop strncpy in favour of snprintf
with very few exceptions which require careful thinking ;-)
Diffstat (limited to 'nxcomp/src/Auth.cpp')
-rw-r--r--nxcomp/src/Auth.cpp14
1 files changed, 4 insertions, 10 deletions
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");