Nmap Development mailing list archives

Re: [NSE] bug stdnse.output_table


From: David Fifield <david () bamsoftware com>
Date: Wed, 19 Sep 2012 23:48:18 -0700

On Tue, Sep 18, 2012 at 01:31:35PM -0700, David Fifield wrote:
On Sun, Sep 16, 2012 at 10:18:29AM +0200, Patrik Karlsson wrote:
I'm having problems removing items from the output_table by assigning them
a nil value.
What happens is that some are removed others are returned as "nil" in the
output.
Not sure what's going on here, but thought I would post it here to see if
it's obvious to someone, before I dig in and try to make sense of it.
The attached script can be used to reproduce.

I see this problem too. I think the bug is that the order array is not
updated to match the reverse array. order and reverse are supposed to be
inverses of each other, e.g.,

order   {1=A,2=B,3=C,4=D}
reverse {A=1,B=2,C=3,D=4}

table.remove(order, reverse["A"]) shifts the elements of order by 1, and
reverse["A"] is subsequently deleted, but the other elements of reverse
are not shifted to match:

order   {1=B,2=C,3=D}
reverse {B=3,C=3,D=4}

I think we should ditch reverse and just do a linear search for the key
in the order array. (Or reverse can become a boolean true/false
membership cache, instead of a mapping to indices.)

I think this is fixed in r29837.

David Fifield
_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/


Current thread: