]> andersk Git - openssh.git/blobdiff - tildexpand.c
- stevesk@cvs.openbsd.org 2002/02/04 00:53:39
[openssh.git] / tildexpand.c
index f25f7d96b265c373fb6054db383d48867b9202ad..e89a7ade8acdf762b3f08a89208a6521a8143034 100644 (file)
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: tildexpand.c,v 1.8 2000/09/07 20:27:55 deraadt Exp $");
+RCSID("$OpenBSD: tildexpand.c,v 1.12 2001/08/11 22:51:27 jakob Exp $");
 
 #include "xmalloc.h"
-#include "ssh.h"
+#include "log.h"
+#include "tildexpand.h"
 
 /*
  * Expands tildes in the file name.  Returns data allocated by xmalloc.
@@ -24,7 +25,7 @@ char *
 tilde_expand_filename(const char *filename, uid_t my_uid)
 {
        const char *cp;
-       unsigned int userlen;
+       u_int userlen;
        char *expanded;
        struct passwd *pw;
        char user[100];
@@ -66,6 +67,6 @@ tilde_expand_filename(const char *filename, uid_t my_uid)
        if (len > MAXPATHLEN)
                fatal("Home directory too long (%d > %d", len-1, MAXPATHLEN-1);
        expanded = xmalloc(len);
-       snprintf(expanded, len, "%s/%s", pw->pw_dir, cp + 1);
+       snprintf(expanded, len, "%s%s%s", pw->pw_dir, strcmp(pw->pw_dir, "/") ? "/" : "", cp + 1);
        return expanded;
 }
This page took 0.041238 seconds and 4 git commands to generate.