mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-07-29 13:01:13 +03:00
resolve callback crash
This commit is contained in:
@ -40,6 +40,7 @@ char *user;
|
|||||||
int sftp;
|
int sftp;
|
||||||
char *cmds[MAXCMD];
|
char *cmds[MAXCMD];
|
||||||
struct termios terminal;
|
struct termios terminal;
|
||||||
|
|
||||||
void do_sftp(ssh_session session);
|
void do_sftp(ssh_session session);
|
||||||
|
|
||||||
static int auth_callback(const char *prompt, char *buf, size_t len,
|
static int auth_callback(const char *prompt, char *buf, size_t len,
|
||||||
@ -68,6 +69,11 @@ static int auth_callback(const char *prompt, char *buf, size_t len,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct ssh_callbacks_struct cb = {
|
||||||
|
.auth_function=auth_callback,
|
||||||
|
.userdata=NULL
|
||||||
|
};
|
||||||
|
|
||||||
static void add_cmd(char *cmd){
|
static void add_cmd(char *cmd){
|
||||||
int n;
|
int n;
|
||||||
for(n=0;cmds[n] && (n<MAXCMD);n++);
|
for(n=0;cmds[n] && (n<MAXCMD);n++);
|
||||||
@ -537,17 +543,10 @@ int main(int argc, char **argv){
|
|||||||
char buf[10];
|
char buf[10];
|
||||||
unsigned char *hash = NULL;
|
unsigned char *hash = NULL;
|
||||||
int hlen;
|
int hlen;
|
||||||
ssh_callbacks cb;
|
|
||||||
|
|
||||||
session = ssh_new();
|
session = ssh_new();
|
||||||
|
|
||||||
cb = malloc(sizeof(ssh_callbacks));
|
ssh_callbacks_init(&cb);
|
||||||
|
ssh_set_callbacks(session,&cb);
|
||||||
cb->auth_function = auth_callback;
|
|
||||||
cb->userdata = NULL;
|
|
||||||
|
|
||||||
ssh_callbacks_init(cb);
|
|
||||||
ssh_set_callbacks(session, cb);
|
|
||||||
|
|
||||||
if(ssh_options_getopt(session, &argc, argv)) {
|
if(ssh_options_getopt(session, &argc, argv)) {
|
||||||
fprintf(stderr, "error parsing command line :%s\n",
|
fprintf(stderr, "error parsing command line :%s\n",
|
||||||
|
@ -79,7 +79,7 @@ typedef struct ssh_callbacks_struct * ssh_callbacks;
|
|||||||
* evolves with time.
|
* evolves with time.
|
||||||
*/
|
*/
|
||||||
#define ssh_callbacks_init(p) do {\
|
#define ssh_callbacks_init(p) do {\
|
||||||
p->size=sizeof(*p); \
|
(p)->size=sizeof(*(p)); \
|
||||||
} while(0);
|
} while(0);
|
||||||
|
|
||||||
LIBSSH_API int ssh_set_callbacks(ssh_session session, ssh_callbacks cb);
|
LIBSSH_API int ssh_set_callbacks(ssh_session session, ssh_callbacks cb);
|
||||||
|
Reference in New Issue
Block a user