]> andersk Git - openssh.git/blobdiff - tildexpand.c
- (dtucker) [log.c] Bug #973: force log_init() to open syslog, since on some
[openssh.git] / tildexpand.c
index 9fd430bd40b93bfb5a7ad0ea5a5cd5eab3562940..cedb653b244bfff662cff58e31ee34442cdab11c 100644 (file)
@@ -2,14 +2,20 @@
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
  *                    All rights reserved
- * Created: Wed Jul 12 01:07:36 1995 ylo
+ *
+ * As far as I am concerned, the code I have written for this software
+ * can be used freely for any purpose.  Any derived versions of this
+ * software must be clearly marked as such, and if the derived work is
+ * incompatible with the protocol description in the RFC file, it must be
+ * called by a name other than "ssh" or "Secure Shell".
  */
 
 #include "includes.h"
-RCSID("$Id$");
+RCSID("$OpenBSD: tildexpand.c,v 1.15 2004/05/21 08:43:03 markus Exp $");
 
 #include "xmalloc.h"
-#include "ssh.h"
+#include "log.h"
+#include "misc.h"
 
 /*
  * Expands tildes in the file name.  Returns data allocated by xmalloc.
@@ -19,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];
@@ -61,6 +67,7 @@ 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.029356 seconds and 4 git commands to generate.