--- display.c.orig Thu Jan 27 14:51:39 2000 +++ display.c Thu Jan 27 15:14:55 2000 @@ -27,7 +27,10 @@ */ #include -#include +#include +#include +#include +#include #include #include #include @@ -40,6 +43,7 @@ #include #include #include +#include #include @@ -59,8 +63,10 @@ static void write_stoc(); /* Server to Client */ static void initialize_screen(); /* Clear screen, setup windows, etc */ static void dump_handler(); +extern void cleanup_output(); extern int ignore_user; +void display_connection(input_filename, con_id) char *input_filename; int con_id; @@ -108,7 +114,6 @@ } pcap_close(pcp); - return; } char init_user=0; @@ -136,15 +141,13 @@ struct ip *ip; struct tcphdr *tcph; u_char *abuf, *abuf2; - int flags, length; + int length; static struct timeval last_time; static int offset_set=0; - struct timeval ct; fd_set fdset; struct timeval timeout; char inchar; - char outbuf[64]; /* tjk timing */ static struct timeval session_start, cur_delta; @@ -218,7 +221,6 @@ } for (;;) { - int sel_out; struct timeval t1,t2,t3; bcopy(subtract_timeval(&pkth->ts, &session_start), @@ -477,12 +479,10 @@ if (length > 46) { len = 46; - strncpy(s, p+(length-46), len); /* Get last 46 characters */ - *(s+len)=0; + strlcpy(s, p+(length-46), len); /* Get last 46 characters */ } else { len = length; - strncpy(s, p, len); - *(s+len)=0; + strlcpy(s, p, len); } mode=0; @@ -561,8 +561,7 @@ if (len == 46) { printf("\033[26;34H\033[7m%s\033[0m", new_buffer); former_buflen = 46; - strncpy(former_buffer, printable, len); - *(former_buffer+len)=0; + strlcpy(former_buffer, printable, len); } else { if ((former_buflen + len) > 46) { diff = (former_buflen + len - 46); @@ -572,17 +571,14 @@ printf("\033[26;%dH", 34+former_buflen-(diff)); printf("\033[7m%s\033[0m", new_buffer); former_buflen = 46; - strncpy(temp, former_buffer+diff, 46-diff); - *(temp+(46-diff))=0; - strcat(temp, printable, len); - *(temp+46)=0; + strlcpy(temp, former_buffer+diff, 46-diff); + strlcat(temp, printable, len); strcpy(former_buffer, temp); } else { printf("\033[26;%dH", 34+former_buflen); printf("\033[7m%s\033[0m", new_buffer); former_buflen += len; - strncat(former_buffer, printable, len); - *(former_buffer+former_buflen)=0; + strlcat(former_buffer, printable, len); } } } @@ -600,7 +596,7 @@ char *p; int length; { - char *x, *y, *beg, value; + char *x, value, *beg = NULL; int i; int redraw_status=0; enum { STATE_NOTHING, STATE_ESCAPE, STATE_BRACKET, STATE_ARGUMENTS } state; @@ -741,6 +737,7 @@ static FILE *sfp=NULL, *cfp=NULL; static char dumpbase[1024]; +void dump_connection(input_filename, con_id) char *input_filename; int con_id; @@ -754,7 +751,8 @@ printf("Enter basename for output files (server side will append '.srv', client '.cli'\n"); printf(":"); fflush(stdout); - gets(dumpbase); + fgets(dumpbase, sizeof(dumpbase), stdin); + strtok(dumpbase, "\r\n"); if ((pcp = pcap_open_offline(input_filename, ebuf)) == NULL) { fprintf(stderr, "Can't open input file: %s\n", ebuf); @@ -798,8 +796,6 @@ printf("NOTE: You may want to run:\n"); printf("tr -d '\\015'