summaryrefslogtreecommitdiffstats
path: root/libssh/socket.c
diff options
context:
space:
mode:
authorAndreas Schneider <mail@cynapses.org>2009-04-01 20:18:31 +0000
committerAndreas Schneider <mail@cynapses.org>2009-04-01 20:18:31 +0000
commitb06c167775ec3aac00ba52935c07ce4b1520721b (patch)
treee525a0580437bc7e0e9926e9228f3671e7d2d40d /libssh/socket.c
parentace6eed6c0c5e3493c58106cc0e698b92b7835f6 (diff)
downloadlibssh-b06c167775ec3aac00ba52935c07ce4b1520721b.tar.gz
libssh-b06c167775ec3aac00ba52935c07ce4b1520721b.tar.xz
libssh-b06c167775ec3aac00ba52935c07ce4b1520721b.zip
Fix memory error checking in socket functions.
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@328 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh/socket.c')
-rw-r--r--libssh/socket.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/libssh/socket.c b/libssh/socket.c
index acadbeda..03797d61 100644
--- a/libssh/socket.c
+++ b/libssh/socket.c
@@ -89,7 +89,12 @@ void ssh_socket_init(void) {
* \brief creates a new Socket object
*/
struct socket *ssh_socket_new(SSH_SESSION *session){
- struct socket *s=malloc(sizeof(struct socket));
+ struct socket *s;
+
+ s = malloc(sizeof(struct socket));
+ if (s = NULL) {
+ return NULL;
+ }
s->fd=-1;
s->last_errno=-1;
s->session=session;
@@ -351,6 +356,10 @@ int ssh_socket_wait_for_data(struct socket *s, SSH_SESSION *session, u32 len){
}
if(session->blocking){
buf=malloc(to_read);
+ if (buf == NULL) {
+ leave_function();
+ return SSH_ERROR;
+ }
r=ssh_socket_completeread(session->socket,buf,to_read);
if(r==SSH_ERROR || r ==0){
ssh_set_error(session,SSH_FATAL,