X-Git-Url: http://andersk.mit.edu/gitweb/gssapi-openssh.git/blobdiff_plain/f5799ae11d9a6d85b68449a35cd4077ae9090357..4e1c687b22bf2e4eb8d3549081a1f468eb13e374:/openssh/sftp-server.c diff --git a/openssh/sftp-server.c b/openssh/sftp-server.c index 9db28e7..2ef9753 100644 --- a/openssh/sftp-server.c +++ b/openssh/sftp-server.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, 2002 Markus Friedl. All rights reserved. + * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -22,7 +22,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "includes.h" -RCSID("$OpenBSD: sftp-server.c,v 1.35 2002/06/06 17:30:11 markus Exp $"); +RCSID("$OpenBSD: sftp-server.c,v 1.30 2001/07/31 12:42:50 jakob Exp $"); #include "buffer.h" #include "bufaux.h" @@ -144,7 +144,7 @@ handle_init(void) { int i; - for (i = 0; i < sizeof(handles)/sizeof(Handle); i++) + for(i = 0; i < sizeof(handles)/sizeof(Handle); i++) handles[i].use = HANDLE_UNUSED; } @@ -153,7 +153,7 @@ handle_new(int use, char *name, int fd, DIR *dirp) { int i; - for (i = 0; i < sizeof(handles)/sizeof(Handle); i++) { + for(i = 0; i < sizeof(handles)/sizeof(Handle); i++) { if (handles[i].use == HANDLE_UNUSED) { handles[i].use = use; handles[i].dirp = dirp; @@ -368,7 +368,7 @@ process_init(void) { Buffer msg; - version = get_int(); + version = buffer_get_int(&iqueue); TRACE("client version %d", version); buffer_init(&msg); buffer_put_char(&msg, SSH2_FXP_VERSION); @@ -589,11 +589,6 @@ process_setstat(void) name = get_string(NULL); a = get_attrib(); TRACE("setstat id %d name %s", id, name); - if (a->flags & SSH2_FILEXFER_ATTR_SIZE) { - ret = truncate(name, a->size); - if (ret == -1) - status = errno_to_portable(errno); - } if (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) { ret = chmod(name, a->perm & 0777); if (ret == -1) @@ -631,11 +626,6 @@ process_fsetstat(void) if (fd < 0 || name == NULL) { status = SSH2_FX_FAILURE; } else { - if (a->flags & SSH2_FILEXFER_ATTR_SIZE) { - ret = ftruncate(fd, a->size); - if (ret == -1) - status = errno_to_portable(errno); - } if (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) { #ifdef HAVE_FCHMOD ret = fchmod(fd, a->perm & 0777); @@ -781,7 +771,7 @@ process_readdir(void) } if (count > 0) { send_names(id, count, stats); - for (i = 0; i < count; i++) { + for(i = 0; i < count; i++) { xfree(stats[i].name); xfree(stats[i].long_name); } @@ -907,7 +897,7 @@ process_readlink(void) send_status(id, errno_to_portable(errno)); else { Stat s; - + link[len] = '\0'; attrib_clear(&s.attrib); s.name = s.long_name = link; @@ -956,24 +946,20 @@ static void process(void) { u_int msg_len; - u_int buf_len; - u_int consumed; u_int type; u_char *cp; - buf_len = buffer_len(&iqueue); - if (buf_len < 5) + if (buffer_len(&iqueue) < 5) return; /* Incomplete message. */ - cp = buffer_ptr(&iqueue); + cp = (u_char *) buffer_ptr(&iqueue); msg_len = GET_32BIT(cp); if (msg_len > 256 * 1024) { error("bad message "); exit(11); } - if (buf_len < msg_len + 4) + if (buffer_len(&iqueue) < msg_len + 4) return; buffer_consume(&iqueue, 4); - buf_len -= 4; type = buffer_get_char(&iqueue); switch (type) { case SSH2_FXP_INIT: @@ -1040,14 +1026,6 @@ process(void) error("Unknown message %d", type); break; } - /* discard the remaining bytes from the current packet */ - if (buf_len < buffer_len(&iqueue)) - fatal("iqueue grows"); - consumed = buf_len - buffer_len(&iqueue); - if (msg_len < consumed) - fatal("msg_len %d < consumed %d", msg_len, consumed); - if (msg_len > consumed) - buffer_consume(&iqueue, msg_len - consumed); } int