diff -Naur /tmp/tmp.gtYXm14597/como.snp/src/base/query-ondemand.c /tmp/tmp.JFjyq14598/como.snp/src/base/query-ondemand.c --- /tmp/tmp.gtYXm14597/como.snp/src/base/query-ondemand.c 2005-02-11 17:11:29.885643858 +0000 +++ /tmp/tmp.JFjyq14598/como.snp/src/base/query-ondemand.c 2005-02-11 17:11:30.054644029 +0000 @@ -269,12 +269,8 @@ * invoke the print() method to print data. * Replace the final NULL with a \n if not there */ - ptr = mdl->callbacks.print(ptr); - len = strlen(ptr); - if (len > 0 && ptr[len-1] != '\n') { - ptr[len] = '\n'; - len++; - } + len = -1; + ptr = mdl->callbacks.print(ptr, &len); } if (!qrysend(client_fd, reply_fmt, 0, ptr, len)) panic("sending data to the client: %s\n", strerror(errno)); diff -Naur /tmp/tmp.gtYXm14597/como.snp/src/base/sniffer-pcap.c /tmp/tmp.JFjyq14598/como.snp/src/base/sniffer-pcap.c --- /tmp/tmp.gtYXm14597/como.snp/src/base/sniffer-pcap.c 2005-02-11 17:11:29.974643948 +0000 +++ /tmp/tmp.JFjyq14598/como.snp/src/base/sniffer-pcap.c 2005-02-11 17:11:30.056644031 +0000 @@ -178,10 +178,9 @@ return npkt; need_more: - printf("sniffer_next done in %d.\n", getpid()); len -= ofs; bcopy(buf+ofs, buf, (uint)len); return npkt; } diff -Naur /tmp/tmp.gtYXm14597/como.snp/src/include/comotypes.h /tmp/tmp.JFjyq14598/como.snp/src/include/comotypes.h --- /tmp/tmp.gtYXm14597/como.snp/src/include/comotypes.h 2005-02-11 17:11:29.906643880 +0000 +++ /tmp/tmp.JFjyq14598/como.snp/src/include/comotypes.h 2005-02-11 17:11:30.057644032 +0000 @@ -172,10 +172,11 @@ /** * print_fn() given a data buffer, returns a printable * representation of the content of the data in a static buffer. + * Returns the length in *len. * On error returns NULL * Optional */ -typedef char * (print_fn)(char *buf); +typedef char * (print_fn)(char *buf, size_t *len); /* diff -Naur /tmp/tmp.gtYXm14597/como.snp/src/modules/application.c /tmp/tmp.JFjyq14598/como.snp/src/modules/application.c --- /tmp/tmp.gtYXm14597/como.snp/src/modules/application.c 2005-02-11 17:11:29.953643927 +0000 +++ /tmp/tmp.JFjyq14598/como.snp/src/modules/application.c 2005-02-11 17:11:30.057644032 +0000 @@ -238,16 +238,16 @@ } static char * -print(char *buf) +print(char *buf, size_t *len) { FLOWDESC *x = F(buf - sizeof(rec_t)); static char s[2048]; time_t ts = (time_t) ntohl(x->ts); - sprintf(s, "Ts: %.24s App: %3s Bytes (1s): %8llu Packets (1s): %llu\n", - asctime(localtime(&ts)), app2str[ntohl(x->app)], - NTOHLL(x->bytes), NTOHLL(x->pkts)); + *len = sprintf(s, "Ts: %.24s App: %3s Bytes (1s): %8llu Packets (1s): %llu\n", + asctime(localtime(&ts)), app2str[ntohl(x->app)], + NTOHLL(x->bytes), NTOHLL(x->pkts)); return s; }; diff -Naur /tmp/tmp.gtYXm14597/como.snp/src/modules/connx.c /tmp/tmp.JFjyq14598/como.snp/src/modules/connx.c --- /tmp/tmp.gtYXm14597/como.snp/src/modules/connx.c 2005-02-11 17:11:29.954643928 +0000 +++ /tmp/tmp.JFjyq14598/como.snp/src/modules/connx.c 2005-02-11 17:11:30.058644033 +0000 @@ -208,7 +208,7 @@ static char * -print(char *buf) +print(char *buf, size_t *len) { EFLOWDESC *ex = EF(buf - sizeof(rec_t)); static char s[2048]; @@ -220,11 +220,12 @@ sprintf(src, "%s", inet_ntoa(saddr)); sprintf(dst, "%s", inet_ntoa(daddr)); - sprintf(s, "%15s %15s Src port: %5hu Dst port: %5hu Proto: %3u " - "Bytes: %8llu Packets: %8llu Start: %12llu End: %12llu", - src, dst, ntohs(N16(ex->src_port)), ntohs(N16(ex->dst_port)), - (uint) ex->proto, NTOHLL(ex->bytes), NTOHLL(ex->pkts), - NTOHLL(ex->first), NTOHLL(ex->last)); + *len = sprintf(s, "%15s %15s Src port: %5hu Dst port: %5hu Proto: %3u " + "Bytes: %8llu Packets: %8llu Start: %12llu End: %12llu", + src, dst, ntohs(N16(ex->src_port)), + ntohs(N16(ex->dst_port)), (uint) ex->proto, + NTOHLL(ex->bytes), NTOHLL(ex->pkts), NTOHLL(ex->first), + NTOHLL(ex->last)); return s; }; diff -Naur /tmp/tmp.gtYXm14597/como.snp/src/modules/counter.c /tmp/tmp.JFjyq14598/como.snp/src/modules/counter.c --- /tmp/tmp.gtYXm14597/como.snp/src/modules/counter.c 2005-02-11 17:11:29.955643929 +0000 +++ /tmp/tmp.JFjyq14598/como.snp/src/modules/counter.c 2005-02-11 17:11:30.058644033 +0000 @@ -98,15 +98,15 @@ } static char * -print(char *buf) +print(char *buf, size_t *len) { FLOWDESC *x = F(buf - sizeof(rec_t)); static char s[512]; time_t ts = (time_t)ntohl(x->ts); - sprintf(s, "Ts: %.24s Byte/s: %llu\tPkt/sec:%llu\n", - asctime(localtime(&ts)), NTOHLL(x->byts), NTOHLL(x->pkts)); + *len = sprintf(s, "Ts: %.24s Byte/s: %llu\tPkt/sec:%llu\n", + asctime(localtime(&ts)), NTOHLL(x->byts), NTOHLL(x->pkts)); return s; }; diff -Naur /tmp/tmp.gtYXm14597/como.snp/src/modules/full_cap.c /tmp/tmp.JFjyq14598/como.snp/src/modules/full_cap.c --- /tmp/tmp.gtYXm14597/como.snp/src/modules/full_cap.c 2005-02-11 17:11:29.975643949 +0000 +++ /tmp/tmp.JFjyq14598/como.snp/src/modules/full_cap.c 2005-02-11 17:11:30.058644033 +0000 @@ -29,13 +29,12 @@ { FLOWDESC *x = F(fh); struct pcap_pkthdr *phdr; - if (new_rec) x->bytes_used = 0; - phdr = (struct pcap_pkthdr *)((unsigned long *)x->bytes + x->bytes_used); + phdr = (struct pcap_pkthdr *)((unsigned long)x->bytes + x->bytes_used); phdr->ts.tv_sec = TS2SEC(pkt->ts); phdr->ts.tv_usec = TS2USEC(pkt->ts); phdr->caplen = pkt->caplen; phdr->len = pkt->len; bcopy(pkt->payload, phdr + 1, pkt->caplen); x->bytes_used += sizeof(*phdr) + pkt->caplen; @@ -60,16 +60,18 @@ static size_t load(char *buf, size_t len __unused, timestamp_t *ts __unused) { - size_t s = *(size_t *)buf; - if (s == 0) + size_t s; + + if (len < 4) return -1; - else - return s; + s = *(size_t *)buf; + return s; } static char * -print(char *buf) +print(char *buf, size_t *len) { + *len = *(size_t *)buf - 4; return buf + 4; } diff -Naur /tmp/tmp.gtYXm14597/como.snp/src/modules/protocol.c /tmp/tmp.JFjyq14598/como.snp/src/modules/protocol.c --- /tmp/tmp.gtYXm14597/como.snp/src/modules/protocol.c 2005-02-11 17:11:29.957643931 +0000 +++ /tmp/tmp.JFjyq14598/como.snp/src/modules/protocol.c 2005-02-11 17:11:30.058644033 +0000 @@ -115,16 +115,17 @@ } static char * -print(char *buf) +print(char *buf, size_t *len) { FLOWDESC *x = F(buf - sizeof(rec_t)); static char s[2048]; time_t ts = (time_t)ntohl(x->ts); - sprintf(s, "Ts: %.24s Proto: %3u Bytes (1s): %10llu Pkts (1s): %10llu\n", - asctime(localtime(&ts)), (uint) ntohl(x->proto), - NTOHLL(x->bytes), NTOHLL(x->pkts)); + *len = sprintf(s, + "Ts: %.24s Proto: %3u Bytes (1s): %10llu Pkts (1s): %10llu\n", + asctime(localtime(&ts)), (uint) ntohl(x->proto), + NTOHLL(x->bytes), NTOHLL(x->pkts)); return s; }; diff -Naur /tmp/tmp.gtYXm14597/como.snp/src/modules/topdest.c /tmp/tmp.JFjyq14598/como.snp/src/modules/topdest.c --- /tmp/tmp.gtYXm14597/como.snp/src/modules/topdest.c 2005-02-11 17:11:29.957643931 +0000 +++ /tmp/tmp.JFjyq14598/como.snp/src/modules/topdest.c 2005-02-11 17:11:30.058644033 +0000 @@ -175,7 +175,7 @@ } static char * -print(char *buf) +print(char *buf, size_t *len) { FLOWDESC *x = F(buf - sizeof(rec_t)); static char s[2048]; @@ -184,9 +184,10 @@ addr.s_addr = N32(x->dst_ip); - sprintf(s, "Ts: %.24s Dest ip: %15s Bytes (1s): %llu\tPkts (1s): %llu\n", - asctime(localtime(&ts)), inet_ntoa(addr), - NTOHLL(x->bytes), NTOHLL(x->pkts)); + *len = sprintf(s, + "Ts: %.24s Dest ip: %15s Bytes (1s): %llu\tPkts (1s): %llu\n", + asctime(localtime(&ts)), inet_ntoa(addr), + NTOHLL(x->bytes), NTOHLL(x->pkts)); return s; }; diff -Naur /tmp/tmp.gtYXm14597/como.snp/src/modules/trace.c /tmp/tmp.JFjyq14598/como.snp/src/modules/trace.c --- /tmp/tmp.gtYXm14597/como.snp/src/modules/trace.c 2005-02-11 17:11:29.958643932 +0000 +++ /tmp/tmp.JFjyq14598/como.snp/src/modules/trace.c 2005-02-11 17:11:30.059644034 +0000 @@ -185,7 +185,7 @@ #define IP_ADDR(x) (inet_ntoa(*(struct in_addr*)&(N32(x)))) static char * -print (char *buf) +print (char *buf, size_t *out_len) { static char out[OUT_BUFF_SIZ]; static char tss[TIMESTR_LEN + 1]; @@ -298,7 +298,9 @@ } else { sprintf(out + len, "[unrecognized protocol...]"); } - + + *out_len = strlen(out); + return out; } diff -Naur /tmp/tmp.gtYXm14597/como.snp/src/modules/tuple.c /tmp/tmp.JFjyq14598/como.snp/src/modules/tuple.c --- /tmp/tmp.gtYXm14597/como.snp/src/modules/tuple.c 2005-02-11 17:11:29.958643932 +0000 +++ /tmp/tmp.JFjyq14598/como.snp/src/modules/tuple.c 2005-02-11 17:11:30.059644034 +0000 @@ -136,7 +136,7 @@ } static char * -print(char *buf) +print(char *buf, size_t *len) { FLOWDESC *x = F(buf - sizeof(rec_t)); static char s[2048]; @@ -150,11 +150,11 @@ sprintf(src, "%s", inet_ntoa(saddr)); sprintf(dst, "%s", inet_ntoa(daddr)); - sprintf(s, "Time: %.24s %15s %15s sport %5u dport %5u proto: %3u " - "Bytes: %8llu Packets: %8llu", - asctime(localtime(&ts)), src, dst, - (uint) H16(x->src_port), (uint) H16(x->dst_port), - (uint) x->proto, NTOHLL(x->bytes), NTOHLL(x->pkts)); + *len = sprintf(s, "Time: %.24s %15s %15s sport %5u dport %5u proto: %3u " + "Bytes: %8llu Packets: %8llu", + asctime(localtime(&ts)), src, dst, + (uint) H16(x->src_port), (uint) H16(x->dst_port), + (uint) x->proto, NTOHLL(x->bytes), NTOHLL(x->pkts)); return s; }; diff -Naur /tmp/tmp.gtYXm14597/como.snp/src/modules/utilization.c /tmp/tmp.JFjyq14598/como.snp/src/modules/utilization.c --- /tmp/tmp.gtYXm14597/como.snp/src/modules/utilization.c 2005-02-11 17:11:29.959643933 +0000 +++ /tmp/tmp.JFjyq14598/como.snp/src/modules/utilization.c 2005-02-11 17:11:30.059644034 +0000 @@ -117,16 +117,15 @@ } static char * -print(char *buf) +print(char *buf, size_t *len) { static char s[2048]; FLOWDESC *x = F(buf - sizeof(rec_t)); time_t ts = (time_t) ntohl(x->ts); - sprintf(s, "Time: %.24s Bytes: %10u HighWaterMark: %10u", - asctime(localtime(&ts)), (uint) ntohl(x->bytes), - (uint) ntohl(x->hi_watermark)); - + *len = sprintf(s, "Time: %.24s Bytes: %10u HighWaterMark: %10u", + asctime(localtime(&ts)), (uint) ntohl(x->bytes), + (uint) ntohl(x->hi_watermark)); return s; }