summaryrefslogtreecommitdiff
path: root/auth.c
diff options
context:
space:
mode:
Diffstat (limited to 'auth.c')
-rw-r--r--auth.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/auth.c b/auth.c
index 85c6f8d1d..aa6d66075 100644
--- a/auth.c
+++ b/auth.c
@@ -340,7 +340,8 @@ auth_root_allowed(char *method)
340static char * 340static char *
341expand_authorized_keys(const char *filename, struct passwd *pw) 341expand_authorized_keys(const char *filename, struct passwd *pw)
342{ 342{
343 char *file, *ret; 343 char *file, ret[MAXPATHLEN];
344 int i;
344 345
345 file = percent_expand(filename, "h", pw->pw_dir, 346 file = percent_expand(filename, "h", pw->pw_dir,
346 "u", pw->pw_name, (char *)NULL); 347 "u", pw->pw_name, (char *)NULL);
@@ -352,14 +353,11 @@ expand_authorized_keys(const char *filename, struct passwd *pw)
352 if (*file == '/') 353 if (*file == '/')
353 return (file); 354 return (file);
354 355
355 ret = xmalloc(MAXPATHLEN); 356 i = snprintf(ret, sizeof(ret), "%s/%s", pw->pw_dir, file);
356 if (strlcpy(ret, pw->pw_dir, MAXPATHLEN) >= MAXPATHLEN || 357 if (i < 0 || (size_t)i >= sizeof(ret))
357 strlcat(ret, "/", MAXPATHLEN) >= MAXPATHLEN ||
358 strlcat(ret, file, MAXPATHLEN) >= MAXPATHLEN)
359 fatal("expand_authorized_keys: path too long"); 358 fatal("expand_authorized_keys: path too long");
360
361 xfree(file); 359 xfree(file);
362 return (ret); 360 return (xstrdup(ret));
363} 361}
364 362
365char * 363char *