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
Этот коммит содержится в:
родитель
ace6eed6c0
Коммит
b06c167775
@ -124,6 +124,9 @@ AGENT *agent_new(struct ssh_session *session) {
|
||||
if (agent) {
|
||||
agent->count = 0;
|
||||
agent->sock = ssh_socket_new(session);
|
||||
if (agent->sock == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return agent;
|
||||
|
@ -53,8 +53,15 @@ SSH_SESSION *ssh_new(void) {
|
||||
session->in_buffer=buffer_new();
|
||||
#ifndef _WIN32
|
||||
session->agent = agent_new(session);
|
||||
if (session->agent == NULL) {
|
||||
goto err;
|
||||
}
|
||||
#endif /* _WIN32 */
|
||||
return session;
|
||||
|
||||
err:
|
||||
ssh_cleanup(session);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ssh_cleanup(SSH_SESSION *session){
|
||||
|
@ -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,
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user