mirror of
git://anongit.mindrot.org/openssh.git
synced 2024-12-27 12:22:09 +00:00
- tedu@cvs.openbsd.org 2013/04/23 17:49:45
[misc.c] use xasprintf instead of a series of strlcats and strdup. ok djm
This commit is contained in:
parent
6aa3eacc5e
commit
2ca51bf140
@ -1,6 +1,10 @@
|
||||
20130516
|
||||
- (djm) [contrib/ssh-copy-id] Fix bug that could cause "rm *" to be
|
||||
executed if mktemp failed; bz#2105 ok dtucker@
|
||||
- (dtucker) OpenBSD CVS Sync
|
||||
- tedu@cvs.openbsd.org 2013/04/23 17:49:45
|
||||
[misc.c]
|
||||
use xasprintf instead of a series of strlcats and strdup. ok djm
|
||||
|
||||
20130510
|
||||
- (dtucker) [configure.ac] Enable -Wsizeof-pointer-memaccess if the compiler
|
||||
|
21
misc.c
21
misc.c
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: misc.c,v 1.86 2011/09/05 05:59:08 djm Exp $ */
|
||||
/* $OpenBSD: misc.c,v 1.87 2013/04/23 17:49:45 tedu Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2000 Markus Friedl. All rights reserved.
|
||||
* Copyright (c) 2005,2006 Damien Miller. All rights reserved.
|
||||
@ -517,8 +517,8 @@ freeargs(arglist *args)
|
||||
char *
|
||||
tilde_expand_filename(const char *filename, uid_t uid)
|
||||
{
|
||||
const char *path;
|
||||
char user[128], ret[MAXPATHLEN];
|
||||
const char *path, *sep;
|
||||
char user[128], *ret;
|
||||
struct passwd *pw;
|
||||
u_int len, slash;
|
||||
|
||||
@ -538,22 +538,21 @@ tilde_expand_filename(const char *filename, uid_t uid)
|
||||
} else if ((pw = getpwuid(uid)) == NULL) /* ~/path */
|
||||
fatal("tilde_expand_filename: No such uid %ld", (long)uid);
|
||||
|
||||
if (strlcpy(ret, pw->pw_dir, sizeof(ret)) >= sizeof(ret))
|
||||
fatal("tilde_expand_filename: Path too long");
|
||||
|
||||
/* Make sure directory has a trailing '/' */
|
||||
len = strlen(pw->pw_dir);
|
||||
if ((len == 0 || pw->pw_dir[len - 1] != '/') &&
|
||||
strlcat(ret, "/", sizeof(ret)) >= sizeof(ret))
|
||||
fatal("tilde_expand_filename: Path too long");
|
||||
if ((len == 0 || pw->pw_dir[len - 1] != '/'))
|
||||
sep = "/";
|
||||
else
|
||||
sep = "";
|
||||
|
||||
/* Skip leading '/' from specified path */
|
||||
if (path != NULL)
|
||||
filename = path + 1;
|
||||
if (strlcat(ret, filename, sizeof(ret)) >= sizeof(ret))
|
||||
|
||||
if (xasprintf(&ret, "%s%s%s", pw->pw_dir, sep, filename) >= MAXPATHLEN)
|
||||
fatal("tilde_expand_filename: Path too long");
|
||||
|
||||
return (xstrdup(ret));
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user