userauth_keyboard_interactive: skip code on zero length auth

This commit is contained in:
Daniel Stenberg
2011-05-25 22:39:25 +02:00
parent 6e8229a221
commit dade304c47

View File

@@ -1,6 +1,6 @@
/* Copyright (c) 2004-2007, Sara Golemon <sarag@libssh2.org> /* Copyright (c) 2004-2007, Sara Golemon <sarag@libssh2.org>
* Copyright (c) 2005 Mikhail Gusarov <dottedmag@dottedmag.net> * Copyright (c) 2005 Mikhail Gusarov <dottedmag@dottedmag.net>
* Copyright (c) 2009-2010 by Daniel Stenberg * Copyright (c) 2009-2011 by Daniel Stenberg
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, * Redistribution and use in source and binary forms,
@@ -1453,17 +1453,21 @@ userauth_keyboard_interactive(LIBSSH2_SESSION * session,
/* string name (ISO-10646 UTF-8) */ /* string name (ISO-10646 UTF-8) */
session->userauth_kybd_auth_name_len = _libssh2_ntohu32(s); session->userauth_kybd_auth_name_len = _libssh2_ntohu32(s);
s += 4; s += 4;
if(session->userauth_kybd_auth_name_len) {
session->userauth_kybd_auth_name = session->userauth_kybd_auth_name =
LIBSSH2_ALLOC(session, session->userauth_kybd_auth_name_len); LIBSSH2_ALLOC(session,
session->userauth_kybd_auth_name_len);
if (!session->userauth_kybd_auth_name) { if (!session->userauth_kybd_auth_name) {
_libssh2_error(session, LIBSSH2_ERROR_ALLOC, _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate memory for " "Unable to allocate memory for "
"keyboard-interactive 'name' request field"); "keyboard-interactive 'name' "
"request field");
goto cleanup; goto cleanup;
} }
memcpy(session->userauth_kybd_auth_name, s, memcpy(session->userauth_kybd_auth_name, s,
session->userauth_kybd_auth_name_len); session->userauth_kybd_auth_name_len);
s += session->userauth_kybd_auth_name_len; s += session->userauth_kybd_auth_name_len;
}
/* string instruction (ISO-10646 UTF-8) */ /* string instruction (ISO-10646 UTF-8) */
session->userauth_kybd_auth_instruction_len = _libssh2_ntohu32(s); session->userauth_kybd_auth_instruction_len = _libssh2_ntohu32(s);