From 9d270f99a76e3b498468929cea4d27aebf6beeed Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 27 Apr 2009 12:00:42 +0000 Subject: Improve sftp_handle. git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@629 7dcaeef0-15fb-0310-b436-a5af3365683c --- libssh/sftpserver.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'libssh/sftpserver.c') 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){ -- cgit v1.2.3