diff options
author | Alan Coopersmith <alan.coopersmith@sun.com> | 2009-07-17 21:46:46 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@sun.com> | 2009-07-17 21:46:46 -0700 |
commit | 70b7a9a7a83b042f46abd50bbe21b0522a0dd9a5 (patch) | |
tree | b0584196e83b1738fa7510964d9ff9a5a8258272 /auth.c | |
parent | 7221da99593ee2fe1943250523965b70d59dbf56 (diff) |
malloc(strlen()); strcpy() -> strdup()
Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
Diffstat (limited to 'auth.c')
-rw-r--r-- | auth.c | 21 |
1 files changed, 9 insertions, 12 deletions
@@ -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) { |