Prompted by a diff by claudio that will make some symbols in libpcap internal, I looked at this port.
The most important change replaces pcap_offline_read() with pcap_dispatch(). Debian has had this diff for a while. Another diff from Debian is a change from atoi() to strtol() to fix percent decoding which uses hex, not dec... Then there are tons of format string warnings which are problematic on LP64 where sizeof(long) != sizeof(int). Replace malloc + wrongly sized memset with calloc There were also some careless patches: an incorrectly terminated comment and strcat -> strncat conversion with wrong size and no termination... Index: Makefile =================================================================== RCS file: /cvs/ports/net/tcptrace/Makefile,v diff -u -p -r1.33 Makefile --- Makefile 27 Sep 2023 14:18:35 -0000 1.33 +++ Makefile 27 Oct 2026 05:10:33 -0000 @@ -1,10 +1,8 @@ COMMENT= TCP dump file analysis tool DISTNAME= tcptrace-6.6.7 -REVISION= 2 +REVISION= 3 CATEGORIES= net -HOMEPAGE= http://www.tcptrace.org/ -SITES= http://www.tcptrace.org/download/ # GPLv2 PERMIT_PACKAGE= Yes Index: patches/patch-etherpeek_c =================================================================== RCS file: patches/patch-etherpeek_c diff -N patches/patch-etherpeek_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-etherpeek_c 27 Oct 2026 05:10:33 -0000 @@ -0,0 +1,26 @@ +Fix format strings on LP64 archs + +Index: etherpeek.c +--- etherpeek.c.orig ++++ etherpeek.c +@@ -391,14 +391,14 @@ pread_f *is_EP(char *filename) + + fprintf(stderr, "IS_EP says version number %d \n",file_header.version); + fprintf(stderr, "IS_EP says status number %d\n",file_header.status); +- fprintf(stderr, "IS_EP says length number %ld\n",file_header2.length); +- fprintf(stderr, "IS_EP says num packets number %ld \n",file_header2.numPackets); +- fprintf(stderr, "IS_EP says time date in mac format %lu \n", (tt_uint32)file_header2.timeDate); +- fprintf(stderr, "IS_EP says time start %lu \n",file_header2.timeStart); +- fprintf(stderr, "IS_EP says time stop %lu \n",file_header2.timeStop); ++ fprintf(stderr, "IS_EP says length number %u\n",file_header2.length); ++ fprintf(stderr, "IS_EP says num packets number %u \n",file_header2.numPackets); ++ fprintf(stderr, "IS_EP says time date in mac format %u \n", (tt_uint32)file_header2.timeDate); ++ fprintf(stderr, "IS_EP says time start %u \n",file_header2.timeStart); ++ fprintf(stderr, "IS_EP says time stop %u \n",file_header2.timeStop); + fprintf(stderr, "future is: "); + for(i=0;i<7;i++) +- fprintf(stderr, " %ld ",file_header2.futureUse[i]); ++ fprintf(stderr, " %u ",file_header2.futureUse[i]); + fprintf(stderr, "\n"); + fprintf(stderr, "RLEN is %d \n",rlen); + } Index: patches/patch-mod_http_c =================================================================== RCS file: patches/patch-mod_http_c diff -N patches/patch-mod_http_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-mod_http_c 27 Oct 2026 05:10:33 -0000 @@ -0,0 +1,26 @@ +Fix format string on LP64 + +Percent encoding uses hex, not dec +https://sources.debian.org/patches/tcptrace/6.6.7-6/bug624296-url-decoding/ + +Index: mod_http.c +--- mod_http.c.orig ++++ mod_http.c +@@ -262,7 +262,7 @@ DataOffset( + off = tcb->syn-seq; + + if (debug>1) +- fprintf(stderr,"DataOffset: seq is %lu, syn is %lu, offset is %ld\n", ++ fprintf(stderr,"DataOffset: seq is %u, syn is %u, offset is %ld\n", + seq, tcb->syn, off); + + return(off); +@@ -919,7 +919,7 @@ static char * formatGetString(char * s) + if (s[i] == '%') { + ascii[0] = s[i+1]; + ascii[1] = s[i+2]; +- buf[j++] = atoi(ascii); ++ buf[j++] = strtol(ascii, NULL, 16); + i = i+3; + } else { + buf[j++] = s[i]; Index: patches/patch-output_c =================================================================== RCS file: patches/patch-output_c diff -N patches/patch-output_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-output_c 27 Oct 2026 05:10:33 -0000 @@ -0,0 +1,25 @@ +Fix malloc + wrong memset + +Index: output.c +--- output.c.orig ++++ output.c +@@ -1083,8 +1083,7 @@ PrintSVHeader( + /* Set the separator */ + if(csv || tsv) { + /* Initialize the separator buffer */ +- sp = (char *)malloc(sizeof(char *) * 2); +- memset(sp, 0, sizeof(sp)); ++ sp = (char *)calloc(2, sizeof(char *) * 2); + /* Set it */ + if(csv) + snprintf(sp, sizeof(sp), ","); +@@ -1101,8 +1100,7 @@ PrintSVHeader( + */ + if(strncmp(sv, "\\t", 2) == 0) { + /* Initialize the separator buffer and set it */ +- sp = (char *)malloc(sizeof(char *) * 2); +- memset(sp, 0, sizeof(sp)); ++ sp = (char *)calloc(2, sizeof(char *)); + snprintf(sp, sizeof(sp), "\t"); + } + else /* Just use the string the user has provided */ Index: patches/patch-snoop_c =================================================================== RCS file: patches/patch-snoop_c diff -N patches/patch-snoop_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-snoop_c 27 Oct 2026 05:10:33 -0000 @@ -0,0 +1,45 @@ +Fix format strings on LP64 + +Index: snoop.c +--- snoop.c.orig ++++ snoop.c +@@ -402,11 +402,11 @@ pread_f *is_snoop(char *filename) + + /* sanity check on snoop version */ + if (debug) { +- printf("Snoop version: %ld\n", buf.snoop_version); ++ printf("Snoop version: %u\n", buf.snoop_version); + } + if (buf.snoop_version != 2) { + printf("\ +-Warning! snoop file is version %ld.\n\ ++Warning! snoop file is version %u.\n\ + Tcptrace is only known to work with version 2\n", + buf.snoop_version); + } +@@ -416,20 +416,20 @@ Tcptrace is only known to work with version 2\n", + switch (buf.mac_type) { + case SNOOP_DL_ETHER: + if (debug) +- printf("Snoop hw type: %ld (Ethernet)\n", buf.mac_type); ++ printf("Snoop hw type: %u (Ethernet)\n", buf.mac_type); + break; + case SNOOP_DL_FDDI: + if (debug) +- printf("Snoop hw type: %ld (FDDI)\n", buf.mac_type); ++ printf("Snoop hw type: %u (FDDI)\n", buf.mac_type); + break; + case SNOOP_DL_ATM: + if (debug) +- printf("Snoop hw type: %ld (ATM)\n", buf.mac_type); ++ printf("Snoop hw type: %u (ATM)\n", buf.mac_type); + break; + default: + if (debug) +- printf("Snoop hw type: %ld (unknown)\n", buf.mac_type); +- printf("snoop hardware type %ld not understood\n", buf.mac_type); ++ printf("Snoop hw type: %u (unknown)\n", buf.mac_type); ++ printf("snoop hardware type %u not understood\n", buf.mac_type); + + exit(-1); + } Index: patches/patch-tcpdump_c =================================================================== RCS file: /cvs/ports/net/tcptrace/patches/patch-tcpdump_c,v diff -u -p -r1.4 patch-tcpdump_c --- patches/patch-tcpdump_c 11 Mar 2022 19:47:44 -0000 1.4 +++ patches/patch-tcpdump_c 27 Oct 2026 05:10:33 -0000 @@ -1,5 +1,9 @@ ---- tcpdump.c.orig Thu Oct 7 22:07:30 2004 -+++ tcpdump.c Sun May 22 22:54:01 2011 +2nd hunk: don't use private libpcap function +https://sources.debian.org/patches/tcptrace/6.6.7-6/bug545595-tcpdump-private-functions/ + +Index: tcpdump.c +--- tcpdump.c.orig ++++ tcpdump.c @@ -189,6 +189,22 @@ static int callback( memcpy((char*)ip_buf,buf+8,iplen-8); callback_plast = ip_buf+iplen-8-1; @@ -23,6 +27,15 @@ case PCAP_DLT_RAW: /* raw IP */ offset = 0; +@@ -248,7 +264,7 @@ pread_tcpdump( + int ret; + + while (1) { +- if ((ret = pcap_offline_read(pcap,1,(pcap_handler)callback,0)) != 1) { ++ if ((ret = pcap_dispatch(pcap,1,(pcap_handler)callback,0)) != 1) { + /* prob EOF */ + + if (ret == -1) { @@ -363,6 +379,9 @@ pread_f *is_tcpdump(char *filename) case PCAP_DLT_ATM_RFC1483: eth_header.ether_type = htons(ETHERTYPE_IP); Index: patches/patch-tcptrace_c =================================================================== RCS file: /cvs/ports/net/tcptrace/patches/patch-tcptrace_c,v diff -u -p -r1.3 patch-tcptrace_c --- patches/patch-tcptrace_c 11 Mar 2022 19:47:44 -0000 1.3 +++ patches/patch-tcptrace_c 27 Oct 2026 05:10:33 -0000 @@ -1,11 +1,22 @@ ---- tcptrace.c.orig Fri Oct 1 23:42:34 2004 -+++ tcptrace.c Wed Jan 7 18:30:33 2009 +Index: tcptrace.c +--- tcptrace.c.orig ++++ tcptrace.c @@ -639,7 +639,7 @@ Dump File Names\n\ char buf[256]; /* plenty large, but checked below with strncpy */ struct ext_var_op *pvop = &extended_vars[i]; strncpy(buf,pvop->var_optname,sizeof(buf)-10); - strcat(buf,"=\"STR\""); -+ strncat(buf,"=\"STR\"", sizeof(buf)); ++ strlcat(buf,"=\"STR\"", sizeof(buf)); fprintf(stderr," --%-20s %s (default: '%s')\n", buf, pvop->var_descr, +@@ -740,8 +740,7 @@ main( + /* Used with <SP>-separated-values, + * prints a '#' before each header line if --csv/--tsv is requested. + */ +- comment = (char *)malloc(sizeof(char *) * 2); +- memset(comment, 0, sizeof(comment)); ++ comment = (char *)calloc(2, sizeof(char *)); + if(csv || tsv || (sv != NULL)) + snprintf(comment, sizeof(comment), "#"); + Index: patches/patch-tcptrace_h =================================================================== RCS file: /cvs/ports/net/tcptrace/patches/patch-tcptrace_h,v diff -u -p -r1.3 patch-tcptrace_h --- patches/patch-tcptrace_h 11 Mar 2022 19:47:44 -0000 1.3 +++ patches/patch-tcptrace_h 27 Oct 2026 05:10:33 -0000 @@ -1,11 +1,12 @@ ---- tcptrace.h.orig Thu Nov 4 22:55:38 2004 -+++ tcptrace.h Wed Jan 7 18:30:33 2009 +Index: tcptrace.h +--- tcptrace.h.orig ++++ tcptrace.h @@ -773,7 +773,7 @@ int finite(double); /* note that many machines have an ether_ntoa, but the output differs, as does the prototype, so we'll include our own and change the name to avoid conflicts with local prototypes if they exist and differ */ -char *Ether_Ntoa(struct ether_addr *e); -+/* char *Ether_Ntoa(struct ether_addr *e);* / ++/* char *Ether_Ntoa(struct ether_addr *e); */ /* global routine decls */ void *MallocZ(int); Index: patches/patch-trace_c =================================================================== RCS file: patches/patch-trace_c diff -N patches/patch-trace_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-trace_c 27 Oct 2026 05:10:33 -0000 @@ -0,0 +1,53 @@ +Index: trace.c +--- trace.c.orig ++++ trace.c +@@ -875,8 +875,8 @@ FindTTP( + printf("b2a.reset_count: %d\n", ptp->b2a.reset_count); + printf("dir: %d (%s)\n", dir, dir==A2B?"A2B":"B2A"); + printf("seq: %lu \n", (u_long)ntohl(ptcp->th_seq)); +- printf("winend: %lu \n", otherdir->windowend); +- printf("syn: %lu \n", otherdir->syn); ++ printf("winend: %u \n", otherdir->windowend); ++ printf("syn: %u \n", otherdir->syn); + printf("SEQ_GREATERTHAN winend: %d\n", + SEQ_GREATERTHAN(ntohl(ptcp->th_seq),otherdir->windowend)); + printf("SEQ_LESSTHAN init syn: %d\n", +@@ -1535,7 +1535,7 @@ dotrace( + /* it changed, that shouldn't happen! */ + if (warn_printbad_syn_fin_seq) + fprintf(stderr, "\ +-%s->%s: rexmitted SYN had diff. seqnum! (was %lu, now %lu, etime: %d sec)\n", ++%s->%s: rexmitted SYN had diff. seqnum! (was %u, now %lu, etime: %d sec)\n", + thisdir->host_letter,thisdir->ptwin->host_letter, + thisdir->syn, start, + (int)(elapsed(ptp_save->first_time,current_time)/1000000)); +@@ -1554,7 +1554,7 @@ dotrace( + /* it changed, that shouldn't happen! */ + if (warn_printbad_syn_fin_seq) + fprintf(stderr, "\ +-%s->%s: rexmitted FIN had diff. seqnum! (was %lu, now %lu, etime: %d sec)\n", ++%s->%s: rexmitted FIN had diff. seqnum! (was %u, now %lu, etime: %d sec)\n", + thisdir->host_letter,thisdir->ptwin->host_letter, + thisdir->fin, fin, + (int)(elapsed(ptp_save->first_time,current_time)/1000000)); +@@ -2077,9 +2077,9 @@ dotrace( + if(ACK_SET(ptcp)) { + memset(&buf2, 0, sizeof(buf2)); + if(dir == A2B) +- snprintf(buf2, sizeof(buf2), "ack %lu ", (th_ack - b2a_first_seqnum)); ++ snprintf(buf2, sizeof(buf2), "ack %u ", (th_ack - b2a_first_seqnum)); + else if(dir == B2A) +- snprintf(buf2, sizeof(buf2), "ack %lu ", (th_ack - a2b_first_seqnum)); ++ snprintf(buf2, sizeof(buf2), "ack %u ", (th_ack - a2b_first_seqnum)); + strncat(buf1, buf2, strlen(buf2)); + } + +@@ -3152,7 +3152,7 @@ check_hw_dups( + /* count it */ + ++tcb->num_hardware_dups; + if (warn_printhwdups) { +- printf("%s->%s: saw hardware duplicate of TCP seq %lu, IP ID %u (packet %lu == %lu)\n", ++ printf("%s->%s: saw hardware duplicate of TCP seq %u, IP ID %u (packet %lu == %lu)\n", + tcb->host_letter,tcb->ptwin->host_letter, + seq, id, pnum,pshd->hwdup_packnum); + }
