Zhang,

There appears to be a register leak in function gen_arth() in gencode.c
where the register number in the first operand (a0) is overlaid by
allocating a new register without freeing the original one.

I replaced this line (line 3595 in version 1.160 gencode.c, yours may
differ):

  a0->regno = s0->s.k = alloc_reg();

With these lines:

  s0->s.k = alloc_reg();
  free_reg(a0->regno);
  a0->regno = s0->s.k;

This change allowed your test program to complete its 100 iterations by
avoiding leaking two registers from the two AND functions in each iteration.
It continued to produce the same BPF program as it did before the change so
the compiled filter program should still work properly.  I assume that this
change would also fix a similar register leak in ADD, SUB, MUL, DIV, OR,
LSH, and RSH.

I don't know much about gencode.c, so I can't vouch for whether my change
can cause problems with some other type of filter string.  Perhaps someone
who is more familiar with gencode.c could offer an expert opinion.

Don Ebright



The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it. 

-
This is the TCPDUMP workers list. It is archived at
http://www.tcpdump.org/lists/workers/index.html
To unsubscribe use mailto:[EMAIL PROTECTED]?body=unsubscribe

Reply via email to