# HG changeset patch # User Matt Johnston # Date 1462368513 -7200 # Node ID 6959c88c8f130e3b22e7705421947908d41dd767 # Parent 750ec4ec4cbed4cf5e2f3c7b9de95c90d9ebd68d message about truncated banner diff -r 750ec4ec4cbe -r 6959c88c8f13 cli-auth.c --- a/cli-auth.c Wed May 04 15:33:40 2016 +0200 +++ b/cli-auth.c Wed May 04 15:28:33 2016 +0200 @@ -78,6 +78,7 @@ char* banner = NULL; unsigned int bannerlen; unsigned int i, linecount; + int truncated = 0; TRACE(("enter recv_msg_userauth_banner")) if (ses.authstate.authdone) { @@ -90,26 +91,29 @@ if (bannerlen > MAX_BANNER_SIZE) { TRACE(("recv_msg_userauth_banner: bannerlen too long: %d", bannerlen)) - goto out; + truncated = 1; + } else { + cleantext(banner); + + /* Limit to 24 lines */ + linecount = 1; + for (i = 0; i < bannerlen; i++) { + if (banner[i] == '\n') { + if (linecount >= MAX_BANNER_LINES) { + banner[i] = '\0'; + truncated = 1; + break; + } + linecount++; + } + } + fprintf(stderr, "%s\n", banner); } - cleantext(banner); - - /* Limit to 25 lines */ - linecount = 1; - for (i = 0; i < bannerlen; i++) { - if (banner[i] == '\n') { - if (linecount >= MAX_BANNER_LINES) { - banner[i] = '\0'; - break; - } - linecount++; - } + if (truncated) { + fprintf(stderr, "[Banner from the server is too long]\n"); } - fprintf(stderr, "%s\n", banner); - -out: m_free(banner); TRACE(("leave recv_msg_userauth_banner")) }