comparison cli-auth.c @ 1296:6959c88c8f13

message about truncated banner
author Matt Johnston <matt@ucc.asn.au>
date Wed, 04 May 2016 15:28:33 +0200
parents 750ec4ec4cbe
children 06d52bcb8094
comparison
equal deleted inserted replaced
1295:750ec4ec4cbe 1296:6959c88c8f13
76 void recv_msg_userauth_banner() { 76 void recv_msg_userauth_banner() {
77 77
78 char* banner = NULL; 78 char* banner = NULL;
79 unsigned int bannerlen; 79 unsigned int bannerlen;
80 unsigned int i, linecount; 80 unsigned int i, linecount;
81 int truncated = 0;
81 82
82 TRACE(("enter recv_msg_userauth_banner")) 83 TRACE(("enter recv_msg_userauth_banner"))
83 if (ses.authstate.authdone) { 84 if (ses.authstate.authdone) {
84 TRACE(("leave recv_msg_userauth_banner: banner after auth done")) 85 TRACE(("leave recv_msg_userauth_banner: banner after auth done"))
85 return; 86 return;
88 banner = buf_getstring(ses.payload, &bannerlen); 89 banner = buf_getstring(ses.payload, &bannerlen);
89 buf_eatstring(ses.payload); /* The language string */ 90 buf_eatstring(ses.payload); /* The language string */
90 91
91 if (bannerlen > MAX_BANNER_SIZE) { 92 if (bannerlen > MAX_BANNER_SIZE) {
92 TRACE(("recv_msg_userauth_banner: bannerlen too long: %d", bannerlen)) 93 TRACE(("recv_msg_userauth_banner: bannerlen too long: %d", bannerlen))
93 goto out; 94 truncated = 1;
94 } 95 } else {
95 96 cleantext(banner);
96 cleantext(banner); 97
97 98 /* Limit to 24 lines */
98 /* Limit to 25 lines */ 99 linecount = 1;
99 linecount = 1; 100 for (i = 0; i < bannerlen; i++) {
100 for (i = 0; i < bannerlen; i++) { 101 if (banner[i] == '\n') {
101 if (banner[i] == '\n') { 102 if (linecount >= MAX_BANNER_LINES) {
102 if (linecount >= MAX_BANNER_LINES) { 103 banner[i] = '\0';
103 banner[i] = '\0'; 104 truncated = 1;
104 break; 105 break;
105 } 106 }
106 linecount++; 107 linecount++;
107 } 108 }
108 } 109 }
109 110 fprintf(stderr, "%s\n", banner);
110 fprintf(stderr, "%s\n", banner); 111 }
111 112
112 out: 113 if (truncated) {
114 fprintf(stderr, "[Banner from the server is too long]\n");
115 }
116
113 m_free(banner); 117 m_free(banner);
114 TRACE(("leave recv_msg_userauth_banner")) 118 TRACE(("leave recv_msg_userauth_banner"))
115 } 119 }
116 120
117 /* This handles the message-specific types which 121 /* This handles the message-specific types which