X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=chat%2Fchat.c;h=fa67fd24213e2e80d4611c438b52526831f36d11;hb=1fe5196b10fc30b1dfb8b4b0ac5bf2b6fa49c297;hp=0740229163dd8ca54f2c1be2d23bcab6ffaad6e6;hpb=a20059a09c56555f6c2006a7193de4c1676b477a;p=ppp.git diff --git a/chat/chat.c b/chat/chat.c index 0740229..fa67fd2 100644 --- a/chat/chat.c +++ b/chat/chat.c @@ -182,7 +182,7 @@ int n_aborts = 0, abort_next = 0, timeout_next = 0, echo_next = 0; int clear_abort_next = 0; char *report_string[MAX_REPORTS] ; -char report_buffer[256] ; +char report_buffer[4096] ; int n_reports = 0, report_next = 0, report_gathering = 0 ; int clear_report_next = 0; @@ -1344,10 +1344,10 @@ int get_string(register char *string) char temp[STR_LEN]; int c, printed = 0, len, minlen; register char *s = temp, *end = s + STR_LEN; - char *logged = temp; + char *s1, *logged = temp; fail_reason = (char *)0; - string = clean(string, 0); + string = s1 = clean(string, 0); len = strlen(string); minlen = (len > sizeof(fail_buffer)? len: sizeof(fail_buffer)) - 1; @@ -1357,12 +1357,14 @@ int get_string(register char *string) if (len > STR_LEN) { msgf("expect string is too long"); exit_code = 1; + free(s1); return 0; } if (len == 0) { if (verbose) msgf("got it"); + free(s1); return (1); } @@ -1410,6 +1412,7 @@ int get_string(register char *string) strftime (report_buffer, 20, "%b %d %H:%M:%S ", tm_now); strcat (report_buffer, report_string[n]); + free(report_string[n]); report_string[n] = (char *) NULL; report_gathering = 1; break; @@ -1419,8 +1422,10 @@ int get_string(register char *string) else { if (!iscntrl (c)) { int rep_len = strlen (report_buffer); - report_buffer[rep_len] = c; - report_buffer[rep_len + 1] = '\0'; + if ((rep_len + 1) < sizeof(report_buffer)) { + report_buffer[rep_len] = c; + report_buffer[rep_len + 1] = '\0'; + } } else { report_gathering = 0; @@ -1439,6 +1444,7 @@ int get_string(register char *string) alarm(0); alarmed = 0; + free(s1); return (1); } @@ -1455,6 +1461,7 @@ int get_string(register char *string) alarmed = 0; exit_code = n + 4; strcpy(fail_reason = fail_buffer, abort_string[n]); + free(s1); return (0); } } @@ -1486,6 +1493,7 @@ int get_string(register char *string) exit_code = 3; alarmed = 0; + free(s1); return (0); }