1
1

Add consistency check to ssh_set_callbacks

Этот коммит содержится в:
Aris Adamantiadis 2010-07-23 08:09:57 +02:00
родитель a924869096
Коммит 5aa9cf2fcf
3 изменённых файлов: 12 добавлений и 4 удалений

Просмотреть файл

@ -244,7 +244,7 @@ typedef struct ssh_packet_callbacks_struct *ssh_packet_callbacks;
*
* @param cb The callback itself.
*
* @return 0 on success, < 0 on error.
* @return SSH_OK on success, SSH_ERROR on error.
*/
LIBSSH_API int ssh_set_callbacks(ssh_session session, ssh_callbacks cb);

Просмотреть файл

@ -22,6 +22,8 @@
/* Since libssh.h includes legacy.h, it's important that libssh.h is included
* first. we don't define LEGACY_H now because we want it to be defined when
* included from libssh.h
* All function calls declared in this header are deprecated and meant to be
* removed in future.
*/
#include "libssh/libssh.h"

Просмотреть файл

@ -28,10 +28,16 @@
int ssh_set_callbacks(ssh_session session, ssh_callbacks cb) {
if (session == NULL || cb == NULL) {
return -1;
return SSH_ERROR;
}
enter_function();
if(cb->size <= 0 || cb->size > 1024 * sizeof(void *)){
ssh_set_error(session,SSH_FATAL,
"Invalid callback passed in (badly initialized)");
leave_function();
return SSH_ERROR;
}
session->callbacks = cb;
leave_function();
return 0;
}