diff options
author | 2002-02-13 00:28:13 +0000 | |
---|---|---|
committer | 2002-02-13 00:28:13 +0000 | |
commit | 80a35c858f3926727da950c2e4d7632224bf64e3 (patch) | |
tree | 7999a0afe5188d5eb0109090a4c1a6a8f682c726 | |
parent | sync (diff) | |
download | wireguard-openbsd-80a35c858f3926727da950c2e4d7632224bf64e3.tar.xz wireguard-openbsd-80a35c858f3926727da950c2e4d7632224bf64e3.zip |
handle SSH2_FILEXFER_ATTR_SIZE in SSH2_FXP_(F)SETSTAT; ok djm@
-rw-r--r-- | usr.bin/ssh/sftp-server.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/usr.bin/ssh/sftp-server.c b/usr.bin/ssh/sftp-server.c index 2b72926dddd..b98c5ff5e38 100644 --- a/usr.bin/ssh/sftp-server.c +++ b/usr.bin/ssh/sftp-server.c @@ -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.32 2001/12/29 21:56:01 stevesk Exp $"); +RCSID("$OpenBSD: sftp-server.c,v 1.33 2002/02/13 00:28:13 markus Exp $"); #include "buffer.h" #include "bufaux.h" @@ -583,6 +583,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) @@ -618,6 +623,11 @@ process_fsetstat(void) if (fd < 0) { 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) { ret = fchmod(fd, a->perm & 0777); if (ret == -1) |