aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <mail@cynapses.org>2009-04-27 11:42:45 +0000
committerAndreas Schneider <mail@cynapses.org>2009-04-27 11:42:45 +0000
commitf32e307899f96bf67abcea7a9f70df51852d9eae (patch)
tree8d024e140bc9182a557d3329700c507ce319febf
parent83142315daf214176e7f635574ac9f7a012a2469 (diff)
downloadlibssh-f32e307899f96bf67abcea7a9f70df51852d9eae.tar.gz
libssh-f32e307899f96bf67abcea7a9f70df51852d9eae.tar.xz
libssh-f32e307899f96bf67abcea7a9f70df51852d9eae.zip
Improve sftp_reply_attr.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@624 7dcaeef0-15fb-0310-b436-a5af3365683c
-rw-r--r--libssh/sftpserver.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/libssh/sftpserver.c b/libssh/sftpserver.c
index a60d1b6a..08b214c3 100644
--- a/libssh/sftpserver.c
+++ b/libssh/sftpserver.c
@@ -275,14 +275,23 @@ int sftp_reply_handle(SFTP_CLIENT_MESSAGE *msg, STRING *handle){
return 0;
}
-int sftp_reply_attr(SFTP_CLIENT_MESSAGE *msg, SFTP_ATTRIBUTES *attr){
- BUFFER *out=buffer_new();
- int r;
- buffer_add_u32(out,msg->id);
- buffer_add_attributes(out,attr);
- r=sftp_packet_write(msg->sftp,SSH_FXP_ATTRS,out);
+int sftp_reply_attr(SFTP_CLIENT_MESSAGE *msg, SFTP_ATTRIBUTES *attr) {
+ BUFFER *out;
+
+ out = buffer_new();
+ if (out == NULL) {
+ return -1;
+ }
+
+ if (buffer_add_u32(out, msg->id) < 0 ||
+ buffer_add_attributes(out, attr) < 0 ||
+ sftp_packet_write(msg->sftp, SSH_FXP_ATTRS, out) < 0) {
buffer_free(out);
- return r<0;
+ return -1;
+ }
+ buffer_free(out);
+
+ return 0;
}
int sftp_reply_names_add(SFTP_CLIENT_MESSAGE *msg, char *file, char *longname,