summaryrefslogtreecommitdiff
path: root/auth.c
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@sun.com>2009-07-17 21:46:46 -0700
committerAlan Coopersmith <alan.coopersmith@sun.com>2009-07-17 21:46:46 -0700
commit70b7a9a7a83b042f46abd50bbe21b0522a0dd9a5 (patch)
treeb0584196e83b1738fa7510964d9ff9a5a8258272 /auth.c
parent7221da99593ee2fe1943250523965b70d59dbf56 (diff)
malloc(strlen()); strcpy() -> strdup()
Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
Diffstat (limited to 'auth.c')
-rw-r--r--auth.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/auth.c b/auth.c
index e73c969..fba5ca5 100644
--- a/auth.c
+++ b/auth.c
@@ -299,21 +299,18 @@ MakeServerAuthFile (struct display *d, FILE ** file)
*file = NULL;
if (!d->authFile) {
- if (d->clientAuthFile && *d->clientAuthFile)
- len = strlen (d->clientAuthFile) + 1;
- else
- {
+ if (d->clientAuthFile && *d->clientAuthFile) {
+ d->authFile = strdup(d->clientAuthFile);
+ if (!d->authFile)
+ return FALSE;
+ } else {
CleanUpFileName (d->name, cleanname, NAMELEN - 8);
len = strlen (authDir) + strlen (authdir1) + strlen (authdir2)
+ strlen (cleanname) + 14;
- }
- d->authFile = malloc (len);
- if (!d->authFile)
- return FALSE;
- if (d->clientAuthFile && *d->clientAuthFile)
- strcpy (d->authFile, d->clientAuthFile);
- else
- {
+ d->authFile = malloc (len);
+ if (!d->authFile)
+ return FALSE;
+
snprintf (d->authFile, len, "%s/%s", authDir, authdir1);
r = stat(d->authFile, &statb);
if (r == 0) {