"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "contrib/mod_sftp/kbdint.c" between
proftpd-1.3.6b.tar.gz and proftpd-1.3.6c.tar.gz

About: ProFTPD is a highly configurable FTP server software (with FTPS and SFTP support).

kbdint.c  (proftpd-1.3.6b):kbdint.c  (proftpd-1.3.6c)
/* /*
* ProFTPD - mod_sftp keyboard-interactive driver mgmt * ProFTPD - mod_sftp keyboard-interactive driver mgmt
* Copyright (c) 2008-2017 TJ Saunders * Copyright (c) 2008-2020 TJ Saunders
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
skipping to change at line 257 skipping to change at line 257
pr_trace_msg(trace_channel, 9, pr_trace_msg(trace_channel, 9,
"sending USER_AUTH_INFO_REQ message to client"); "sending USER_AUTH_INFO_REQ message to client");
res = sftp_ssh2_packet_write(sftp_conn->wfd, pkt); res = sftp_ssh2_packet_write(sftp_conn->wfd, pkt);
destroy_pool(pkt->pool); destroy_pool(pkt->pool);
return res; return res;
} }
static struct ssh2_packet *read_response_packet(pool *p) {
struct ssh2_packet *pkt = NULL;
/* Keep looping until we get the desired message, or we time out. */
while (pkt == NULL) {
int res;
char mesg_type;
pr_signals_handle();
pkt = sftp_ssh2_packet_create(kbdint_pool);
res = sftp_ssh2_packet_read(sftp_conn->rfd, pkt);
if (res < 0) {
int xerrno = errno;
destroy_pool(pkt->pool);
errno = xerrno;
return NULL;
}
pr_response_clear(&resp_list);
pr_response_clear(&resp_err_list);
/* Per RFC 4253, Section 11, DEBUG, DISCONNECT, IGNORE, and UNIMPLEMENTED
* messages can occur at any time, even during KEX. We have to be prepared
* for this, and Do The Right Thing(tm).
*/
mesg_type = sftp_ssh2_packet_get_mesg_type(pkt);
switch (mesg_type) {
case SFTP_SSH2_MSG_DEBUG:
sftp_ssh2_packet_handle_debug(pkt);
pkt = NULL;
break;
case SFTP_SSH2_MSG_DISCONNECT:
sftp_ssh2_packet_handle_disconnect(pkt);
pkt = NULL;
break;
case SFTP_SSH2_MSG_IGNORE:
sftp_ssh2_packet_handle_ignore(pkt);
pkt = NULL;
break;
case SFTP_SSH2_MSG_UNIMPLEMENTED:
sftp_ssh2_packet_handle_unimplemented(pkt);
pkt = NULL;
break;
case SFTP_SSH2_MSG_USER_AUTH_INFO_RESP:
pr_trace_msg(trace_channel, 13,
"received expected %s message",
sftp_ssh2_packet_get_mesg_type_desc(mesg_type));
break;
default:
(void) pr_log_writefile(sftp_logfd, MOD_SFTP_VERSION,
"expecting USER_AUTH_INFO_RESP message, received %s (%d)",
sftp_ssh2_packet_get_mesg_type_desc(mesg_type), mesg_type);
destroy_pool(pkt->pool);
errno = EPERM;
return NULL;
}
}
return pkt;
}
int sftp_kbdint_recv_response(pool *p, uint32_t expected_count, int sftp_kbdint_recv_response(pool *p, uint32_t expected_count,
uint32_t *rcvd_count, const char ***responses) { uint32_t *rcvd_count, const char ***responses) {
register unsigned int i; register unsigned int i;
unsigned char *buf; unsigned char *buf;
cmd_rec *cmd; cmd_rec *cmd;
array_header *list; array_header *list;
uint32_t buflen, resp_count; uint32_t buflen, resp_count;
struct ssh2_packet *pkt; struct ssh2_packet *pkt = NULL;
char mesg_type;
int res; int res;
pool *resp_pool = NULL; pool *resp_pool = NULL;
if (p == NULL || if (p == NULL ||
rcvd_count == NULL || rcvd_count == NULL ||
responses == NULL) { responses == NULL) {
errno = EINVAL; errno = EINVAL;
return -1; return -1;
} }
pkt = sftp_ssh2_packet_create(kbdint_pool); pkt = read_response_packet(p);
if (pkt == NULL) {
res = sftp_ssh2_packet_read(sftp_conn->rfd, pkt); return -1;
if (res < 0) {
destroy_pool(pkt->pool);
return res;
} }
pr_response_clear(&resp_list);
pr_response_clear(&resp_err_list);
/* Cache a reference to the current response pool used. */ /* Cache a reference to the current response pool used. */
resp_pool = pr_response_get_pool(); resp_pool = pr_response_get_pool();
pr_response_set_pool(pkt->pool); pr_response_set_pool(pkt->pool);
mesg_type = sftp_ssh2_packet_get_mesg_type(pkt);
if (mesg_type != SFTP_SSH2_MSG_USER_AUTH_INFO_RESP) {
(void) pr_log_writefile(sftp_logfd, MOD_SFTP_VERSION,
"expecting USER_AUTH_INFO_RESP message, received %s (%d)",
sftp_ssh2_packet_get_mesg_type_desc(mesg_type), mesg_type);
destroy_pool(pkt->pool);
pr_response_set_pool(resp_pool);
errno = EPERM;
return -1;
}
cmd = pr_cmd_alloc(pkt->pool, 2, pstrdup(pkt->pool, "USER_AUTH_INFO_RESP")); cmd = pr_cmd_alloc(pkt->pool, 2, pstrdup(pkt->pool, "USER_AUTH_INFO_RESP"));
cmd->arg = "(data)"; cmd->arg = "(data)";
pr_trace_msg(trace_channel, 9, pr_trace_msg(trace_channel, 9,
"reading USER_AUTH_INFO_RESP message from client"); "reading USER_AUTH_INFO_RESP message from client");
buf = pkt->payload; buf = pkt->payload;
buflen = pkt->payload_len; buflen = pkt->payload_len;
resp_count = sftp_msg_read_int(pkt->pool, &buf, &buflen); resp_count = sftp_msg_read_int(pkt->pool, &buf, &buflen);
 End of changes. 6 change blocks. 
23 lines changed or deleted 76 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)