aboutsummaryrefslogtreecommitdiff
path: root/libssh/sftpserver.c
diff options
context:
space:
mode:
authorAndreas Schneider <mail@cynapses.org>2009-04-27 12:00:42 +0000
committerAndreas Schneider <mail@cynapses.org>2009-04-27 12:00:42 +0000
commit9d270f99a76e3b498468929cea4d27aebf6beeed (patch)
tree7463b49b7d9ae182873fce832620d1b097e4bddc /libssh/sftpserver.c
parent315e5aca84bc8d2269b70a9dfe8c61ca94f5fa8f (diff)
downloadlibssh-9d270f99a76e3b498468929cea4d27aebf6beeed.tar.gz
libssh-9d270f99a76e3b498468929cea4d27aebf6beeed.tar.xz
libssh-9d270f99a76e3b498468929cea4d27aebf6beeed.zip
Improve sftp_handle.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@629 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh/sftpserver.c')
-rw-r--r--libssh/sftpserver.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/libssh/sftpserver.c b/libssh/sftpserver.c
index 9384ce22..795c6756 100644
--- a/libssh/sftpserver.c
+++ b/libssh/sftpserver.c
@@ -454,15 +454,23 @@ STRING *sftp_handle_alloc(SFTP_SESSION *sftp, void *info) {
}
void *sftp_handle(SFTP_SESSION *sftp, STRING *handle){
- u32 val;
- if(!sftp->handles)
- return NULL;
- if(string_len(handle)!=sizeof(val))
- return NULL;
- memcpy(&val,handle->string,sizeof(u32));
- if(val>SFTP_HANDLES)
- return NULL;
- return sftp->handles[val];
+ u32 val;
+
+ if (sftp->handles == NULL) {
+ return NULL;
+ }
+
+ if (string_len(handle) != sizeof(u32)) {
+ return NULL;
+ }
+
+ memcpy(&val, handle->string, sizeof(u32));
+
+ if (val > SFTP_HANDLES) {
+ return NULL;
+ }
+
+ return sftp->handles[val];
}
void sftp_handle_remove(SFTP_SESSION *sftp, void *handle){