summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2005-06-17 12:59:34 +1000
committerDamien Miller <djm@mindrot.org>2005-06-17 12:59:34 +1000
commiteccb9de72aa29da5a3fad87a4287b32438689c1f (patch)
tree9b8ef20a7e454b984e0ad67b54b2bdc5577aa2fa /misc.c
parent677257fe07dd2b9a58817e1d42fc2c25bb618a4d (diff)
- djm@cvs.openbsd.org 2005/06/17 02:44:33
[auth-rsa.c auth.c auth1.c auth2-chall.c auth2-gss.c authfd.c authfile.c] [bufaux.c canohost.c channels.c cipher.c clientloop.c dns.c gss-serv.c] [kex.c kex.h key.c mac.c match.c misc.c packet.c packet.h scp.c] [servconf.c session.c session.h sftp-client.c sftp-server.c sftp.c] [ssh-keyscan.c ssh-rsa.c sshconnect.c sshconnect1.c sshconnect2.c sshd.c] make this -Wsign-compare clean; ok avsm@ markus@ NB. auth1.c changes not committed yet (conflicts with uncommitted sync) NB2. more work may be needed to make portable Wsign-compare clean
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/misc.c b/misc.c
index fc094f874..c5ca0ce38 100644
--- a/misc.c
+++ b/misc.c
@@ -24,7 +24,7 @@
24 */ 24 */
25 25
26#include "includes.h" 26#include "includes.h"
27RCSID("$OpenBSD: misc.c,v 1.31 2005/06/06 11:20:36 djm Exp $"); 27RCSID("$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