]> andersk Git - gssapi-openssh.git/blobdiff - openssh/sftp-server.c
Import of OpenSSH 3.1p1
[gssapi-openssh.git] / openssh / sftp-server.c
index 2ef9753bf07d7639b344572863f3b069ed4f7eea..117e6cc15711d1acbbdf6862d2df79be7f2ecccf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2001 Markus Friedl.  All rights reserved.
+ * Copyright (c) 2000, 2001, 2002 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.30 2001/07/31 12:42:50 jakob Exp $");
+RCSID("$OpenBSD: sftp-server.c,v 1.33 2002/02/13 00:28:13 markus 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;
@@ -589,6 +589,11 @@ 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)
@@ -626,6 +631,11 @@ 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);
@@ -771,7 +781,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);
                        }
@@ -897,7 +907,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;
@@ -951,7 +961,7 @@ process(void)
 
        if (buffer_len(&iqueue) < 5)
                return;         /* Incomplete message. */
-       cp = (u_char *) buffer_ptr(&iqueue);
+       cp = buffer_ptr(&iqueue);
        msg_len = GET_32BIT(cp);
        if (msg_len > 256 * 1024) {
                error("bad message ");
This page took 0.039852 seconds and 4 git commands to generate.