1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-29 01:03:57 +03:00

Add a return value to ssh_userauth_kbdint_setanswer().

git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@341 7dcaeef0-15fb-0310-b436-a5af3365683c
This commit is contained in:
Andreas Schneider
2009-04-02 09:24:46 +00:00
parent ee3b641fb1
commit ae4265d304
4 changed files with 32 additions and 17 deletions

View File

@@ -1017,23 +1017,33 @@ char *ssh_userauth_kbdint_getprompt(SSH_SESSION *session, unsigned int i,
* \param session ssh session
* \param i index number of the ith prompt
* \param answer answer to give to server
* \return 0 on success, < 0 on error.
*/
int ssh_userauth_kbdint_setanswer(SSH_SESSION *session, unsigned int i,
const char *answer) {
if (i > session->kbdint->nprompts) {
return -1;
}
void ssh_userauth_kbdint_setanswer(SSH_SESSION *session, unsigned int i, const char *answer){
if (i>session->kbdint->nprompts)
return;
if (session->kbdint->answers == NULL) {
session->kbdint->answers = malloc(sizeof(char*) * session->kbdint->nprompts);
if (session->kbdint->answers == NULL) {
session->kbdint->answers = malloc(sizeof(char*) * session->kbdint->nprompts);
if (session->kbdint->answers == NULL) {
return;
}
memset(session->kbdint->answers, 0, sizeof(char *) * session->kbdint->nprompts);
return -1;
}
if(session->kbdint->answers[i]){
burn(session->kbdint->answers[i]);
free(session->kbdint->answers[i]);
}
session->kbdint->answers[i]=strdup(answer);
memset(session->kbdint->answers, 0, sizeof(char *) * session->kbdint->nprompts);
}
if (session->kbdint->answers[i]) {
burn(session->kbdint->answers[i]);
SAFE_FREE(session->kbdint->answers[i]);
}
session->kbdint->answers[i] = strdup(answer);
if (session->kbdint->answers[i] == NULL) {
return -1;
}
return 0;
}
/** @} */