/*
- * 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
* 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"
{
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;
}
{
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;
{
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);
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)
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);
}
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);
}
send_status(id, errno_to_portable(errno));
else {
Stat s;
-
+
link[len] = '\0';
attrib_clear(&s.attrib);
s.name = s.long_name = link;
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:
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