Fix bugs found by clang analyzer
Этот коммит содержится в:
родитель
2e563e0fa8
Коммит
20e7ec96ae
19
libssh/kex.c
19
libssh/kex.c
@ -202,7 +202,7 @@ char **space_tokenize(const char *chain){
|
|||||||
|
|
||||||
/* find_matching gets 2 parameters : a list of available objects (available_d), separated by colons,*/
|
/* find_matching gets 2 parameters : a list of available objects (available_d), separated by colons,*/
|
||||||
/* and a list of preferred objects (preferred_d) */
|
/* and a list of preferred objects (preferred_d) */
|
||||||
/* it will return a strduped pointer on the first prefered object found in the available objects list */
|
/* it will return a strduped pointer on the first preferred object found in the available objects list */
|
||||||
|
|
||||||
char *ssh_find_matching(const char *available_d, const char *preferred_d){
|
char *ssh_find_matching(const char *available_d, const char *preferred_d){
|
||||||
char ** tok_available, **tok_preferred;
|
char ** tok_available, **tok_preferred;
|
||||||
@ -222,6 +222,7 @@ char *ssh_find_matching(const char *available_d, const char *preferred_d){
|
|||||||
if (tok_preferred == NULL) {
|
if (tok_preferred == NULL) {
|
||||||
SAFE_FREE(tok_available[0]);
|
SAFE_FREE(tok_available[0]);
|
||||||
SAFE_FREE(tok_available);
|
SAFE_FREE(tok_available);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i_pref=0; tok_preferred[i_pref] ; ++i_pref){
|
for(i_pref=0; tok_preferred[i_pref] ; ++i_pref){
|
||||||
@ -230,18 +231,18 @@ char *ssh_find_matching(const char *available_d, const char *preferred_d){
|
|||||||
/* match */
|
/* match */
|
||||||
ret=strdup(tok_available[i_avail]);
|
ret=strdup(tok_available[i_avail]);
|
||||||
/* free the tokens */
|
/* free the tokens */
|
||||||
free(tok_available[0]);
|
SAFE_FREE(tok_available[0]);
|
||||||
free(tok_preferred[0]);
|
SAFE_FREE(tok_preferred[0]);
|
||||||
free(tok_available);
|
SAFE_FREE(tok_available);
|
||||||
free(tok_preferred);
|
SAFE_FREE(tok_preferred);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(tok_available[0]);
|
SAFE_FREE(tok_available[0]);
|
||||||
free(tok_preferred[0]);
|
SAFE_FREE(tok_preferred[0]);
|
||||||
free(tok_available);
|
SAFE_FREE(tok_available);
|
||||||
free(tok_preferred);
|
SAFE_FREE(tok_preferred);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -593,12 +593,13 @@ static int pem_get_password(char *buf, int size, int rwflag, void *userdata) {
|
|||||||
|
|
||||||
/* unused flag */
|
/* unused flag */
|
||||||
(void) rwflag;
|
(void) rwflag;
|
||||||
|
if(buf==NULL)
|
||||||
ZERO_STRUCTP(buf);
|
return 0;
|
||||||
|
memset(buf,'\0',size);
|
||||||
ssh_log(session, SSH_LOG_RARE,
|
ssh_log(session, SSH_LOG_RARE,
|
||||||
"Trying to call external authentication function");
|
"Trying to call external authentication function");
|
||||||
|
|
||||||
if (session && session->callbacks->auth_function) {
|
if (session && session->callbacks && session->callbacks->auth_function) {
|
||||||
if (session->callbacks->auth_function("Passphrase for private key:", buf, size, 0, 0,
|
if (session->callbacks->auth_function("Passphrase for private key:", buf, size, 0, 0,
|
||||||
session->callbacks->userdata) < 0) {
|
session->callbacks->userdata) < 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -104,12 +104,10 @@ static void sftp_ext_free(sftp_ext ext) {
|
|||||||
sftp_session sftp_new(ssh_session session){
|
sftp_session sftp_new(ssh_session session){
|
||||||
sftp_session sftp;
|
sftp_session sftp;
|
||||||
|
|
||||||
enter_function();
|
|
||||||
|
|
||||||
if (session == NULL) {
|
if (session == NULL) {
|
||||||
leave_function();
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
enter_function();
|
||||||
|
|
||||||
sftp = malloc(sizeof(struct sftp_session_struct));
|
sftp = malloc(sizeof(struct sftp_session_struct));
|
||||||
if (sftp == NULL) {
|
if (sftp == NULL) {
|
||||||
@ -123,7 +121,7 @@ sftp_session sftp_new(ssh_session session){
|
|||||||
if (sftp->ext == NULL) {
|
if (sftp->ext == NULL) {
|
||||||
ssh_set_error_oom(session);
|
ssh_set_error_oom(session);
|
||||||
SAFE_FREE(sftp);
|
SAFE_FREE(sftp);
|
||||||
sftp_leave_function();
|
leave_function();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user