tcpdump mailing list archives
Re: Register leak in libpcap 0.9.7
From: "Bruce Keats" <brucekeats () gmail com>
Date: Fri, 13 Jun 2008 16:26:20 -0400
That was fast! Thanks Guy. I will give it a try. Bruce On Fri, Jun 13, 2008 at 4:17 PM, Guy Harris <guy () alum mit edu> wrote:
Bruce Keats wrote:I have a program that is listening on a radio tap interface that is using libpcap. It occasionally changes the BPF something like "ether host xx:xx:xx:xx:xx:xx"....which presumably means it calls pcap_compile() more than once. Is there a fix for this issue?Yes: revision 1.291date: 2007-10-26 00:44:56 +0000; author: guy; state: Exp; lines: +13 -1 Re-initialize the table of used registers, and the current register, before compiling an expression; pcap_compile() can be called more than once, and some registers can now be allocated and not freed in the process of code generation (for example, the register allocated to hold the length of a radiotap header, which can't be freed until we're finished generating all the code).but it's not in any current releases of libpcap. I've attached a patch that should apply to 0.9.7's gencode.c. Index: gencode.c =================================================================== RCS file: /tcpdump/master/libpcap/gencode.c,v retrieving revision 1.290 retrieving revision 1.291 diff -c -r1.290 -r1.291 *** gencode.c 5 Oct 2007 01:40:14 -0000 1.290 --- gencode.c 26 Oct 2007 00:44:56 -0000 1.291 *************** *** 134,139 **** --- 134,140 ---- static void init_linktype(pcap_t *); + static void init_regs(void); static int alloc_reg(void); static void free_reg(int); *************** *** 369,374 **** --- 370,376 ---- n_errors = 0; root = NULL; bpf_pcap = p; + init_regs(); if (setjmp(top_ctx)) { lex_cleanup(); freechunks(); *************** *** 6045,6050 **** --- 6047,6062 ---- static int curreg; /* + * Initialize the table of used registers and the current register. + */ + static void + init_regs() + { + curreg = 0; + memset(regused, 0, sizeof regused); + } + + /* * Return the next free register. */ static int - This is the tcpdump-workers list. Visit https://cod.sandelman.ca/ to unsubscribe.
- This is the tcpdump-workers list. Visit https://cod.sandelman.ca/ to unsubscribe.
Current thread:
- Register leak in libpcap 0.9.7 Bruce Keats (Jun 13)
- Re: Register leak in libpcap 0.9.7 Guy Harris (Jun 13)
- Re: Register leak in libpcap 0.9.7 Bruce Keats (Jun 13)
- Re: Register leak in libpcap 0.9.7 Bruce Keats (Jun 16)
- Re: Register leak in libpcap 0.9.7 Bruce Keats (Jun 13)
- Re: Register leak in libpcap 0.9.7 Guy Harris (Jun 13)