diff options
Diffstat (limited to 'misc.c')
-rw-r--r-- | misc.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -24,7 +24,7 @@ | |||
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include "includes.h" | 26 | #include "includes.h" |
27 | RCSID("$OpenBSD: misc.c,v 1.31 2005/06/06 11:20:36 djm Exp $"); | 27 | RCSID("$OpenBSD: misc.c,v 1.32 2005/06/17 02:44:32 djm Exp $"); |
28 | 28 | ||
29 | #include "misc.h" | 29 | #include "misc.h" |
30 | #include "log.h" | 30 | #include "log.h" |
@@ -386,7 +386,7 @@ tilde_expand_filename(const char *filename, uid_t uid) | |||
386 | const char *path; | 386 | const char *path; |
387 | char user[128], ret[MAXPATHLEN]; | 387 | char user[128], ret[MAXPATHLEN]; |
388 | struct passwd *pw; | 388 | struct passwd *pw; |
389 | int len; | 389 | u_int len, slash; |
390 | 390 | ||
391 | if (*filename != '~') | 391 | if (*filename != '~') |
392 | return (xstrdup(filename)); | 392 | return (xstrdup(filename)); |
@@ -394,10 +394,11 @@ tilde_expand_filename(const char *filename, uid_t uid) | |||
394 | 394 | ||
395 | path = strchr(filename, '/'); | 395 | path = strchr(filename, '/'); |
396 | if (path != NULL && path > filename) { /* ~user/path */ | 396 | if (path != NULL && path > filename) { /* ~user/path */ |
397 | if (path - filename > sizeof(user) - 1) | 397 | slash = path - filename; |
398 | if (slash > sizeof(user) - 1) | ||
398 | fatal("tilde_expand_filename: ~username too long"); | 399 | fatal("tilde_expand_filename: ~username too long"); |
399 | memcpy(user, filename, path - filename); | 400 | memcpy(user, filename, slash); |
400 | user[path - filename] = '\0'; | 401 | user[slash] = '\0'; |
401 | if ((pw = getpwnam(user)) == NULL) | 402 | if ((pw = getpwnam(user)) == NULL) |
402 | fatal("tilde_expand_filename: No such user %s", user); | 403 | fatal("tilde_expand_filename: No such user %s", user); |
403 | } else if ((pw = getpwuid(uid)) == NULL) /* ~/path */ | 404 | } else if ((pw = getpwuid(uid)) == NULL) /* ~/path */ |
@@ -435,7 +436,7 @@ percent_expand(const char *string, ...) | |||
435 | const char *key; | 436 | const char *key; |
436 | const char *repl; | 437 | const char *repl; |
437 | } keys[EXPAND_MAX_KEYS]; | 438 | } keys[EXPAND_MAX_KEYS]; |
438 | int num_keys, i, j; | 439 | u_int num_keys, i, j; |
439 | char buf[4096]; | 440 | char buf[4096]; |
440 | va_list ap; | 441 | va_list ap; |
441 | 442 | ||