mirror of
https://github.com/PowerShell/openssh-portable.git
synced 2025-07-30 01:05:14 +02: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
|
20130516
|
||||||
- (djm) [contrib/ssh-copy-id] Fix bug that could cause "rm *" to be
|
- (djm) [contrib/ssh-copy-id] Fix bug that could cause "rm *" to be
|
||||||
executed if mktemp failed; bz#2105 ok dtucker@
|
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
|
20130510
|
||||||
- (dtucker) [configure.ac] Enable -Wsizeof-pointer-memaccess if the compiler
|
- (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) 2000 Markus Friedl. All rights reserved.
|
||||||
* Copyright (c) 2005,2006 Damien Miller. All rights reserved.
|
* Copyright (c) 2005,2006 Damien Miller. All rights reserved.
|
||||||
@ -517,8 +517,8 @@ freeargs(arglist *args)
|
|||||||
char *
|
char *
|
||||||
tilde_expand_filename(const char *filename, uid_t uid)
|
tilde_expand_filename(const char *filename, uid_t uid)
|
||||||
{
|
{
|
||||||
const char *path;
|
const char *path, *sep;
|
||||||
char user[128], ret[MAXPATHLEN];
|
char user[128], *ret;
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
u_int len, slash;
|
u_int len, slash;
|
||||||
|
|
||||||
@ -538,22 +538,21 @@ tilde_expand_filename(const char *filename, uid_t uid)
|
|||||||
} else if ((pw = getpwuid(uid)) == NULL) /* ~/path */
|
} else if ((pw = getpwuid(uid)) == NULL) /* ~/path */
|
||||||
fatal("tilde_expand_filename: No such uid %ld", (long)uid);
|
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 '/' */
|
/* Make sure directory has a trailing '/' */
|
||||||
len = strlen(pw->pw_dir);
|
len = strlen(pw->pw_dir);
|
||||||
if ((len == 0 || pw->pw_dir[len - 1] != '/') &&
|
if ((len == 0 || pw->pw_dir[len - 1] != '/'))
|
||||||
strlcat(ret, "/", sizeof(ret)) >= sizeof(ret))
|
sep = "/";
|
||||||
fatal("tilde_expand_filename: Path too long");
|
else
|
||||||
|
sep = "";
|
||||||
|
|
||||||
/* Skip leading '/' from specified path */
|
/* Skip leading '/' from specified path */
|
||||||
if (path != NULL)
|
if (path != NULL)
|
||||||
filename = path + 1;
|
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");
|
fatal("tilde_expand_filename: Path too long");
|
||||||
|
|
||||||
return (xstrdup(ret));
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user