Commit 1152e47b authored by Matt Johnston's avatar Matt Johnston

message about truncated banner

parent 32a28d0d
...@@ -78,6 +78,7 @@ void recv_msg_userauth_banner() { ...@@ -78,6 +78,7 @@ void recv_msg_userauth_banner() {
char* banner = NULL; char* banner = NULL;
unsigned int bannerlen; unsigned int bannerlen;
unsigned int i, linecount; unsigned int i, linecount;
int truncated = 0;
TRACE(("enter recv_msg_userauth_banner")) TRACE(("enter recv_msg_userauth_banner"))
if (ses.authstate.authdone) { if (ses.authstate.authdone) {
...@@ -90,26 +91,29 @@ void recv_msg_userauth_banner() { ...@@ -90,26 +91,29 @@ void recv_msg_userauth_banner() {
if (bannerlen > MAX_BANNER_SIZE) { if (bannerlen > MAX_BANNER_SIZE) {
TRACE(("recv_msg_userauth_banner: bannerlen too long: %d", bannerlen)) TRACE(("recv_msg_userauth_banner: bannerlen too long: %d", bannerlen))
goto out; truncated = 1;
} } else {
cleantext(banner);
cleantext(banner);
/* Limit to 24 lines */
/* Limit to 25 lines */ linecount = 1;
linecount = 1; for (i = 0; i < bannerlen; i++) {
for (i = 0; i < bannerlen; i++) { if (banner[i] == '\n') {
if (banner[i] == '\n') { if (linecount >= MAX_BANNER_LINES) {
if (linecount >= MAX_BANNER_LINES) { banner[i] = '\0';
banner[i] = '\0'; truncated = 1;
break; break;
}
linecount++;
} }
linecount++;
} }
fprintf(stderr, "%s\n", banner);
} }
fprintf(stderr, "%s\n", banner); if (truncated) {
fprintf(stderr, "[Banner from the server is too long]\n");
}
out:
m_free(banner); m_free(banner);
TRACE(("leave recv_msg_userauth_banner")) TRACE(("leave recv_msg_userauth_banner"))
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment