un33k / impacket

Automatically exported from code.google.com/p/impacket
Other
8 stars 3 forks source link

polling loop never terminates in nmb.NetBIOSTCPSession.polling_read() #26

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. use nmb.py with polling_read instead of non_polling_read

What is the expected output? What do you see instead?
The code should perform selects until the time left drops to zero or data is 
available.  Instead, it waits forever or until data is available, at least in 
some circumstances.

What version of the product are you using? On what operating system?

impacket-0.9.10.746 on FreeBSD 9.1

Please provide any additional information below.

The code currently looks like this:

            try:
                ready, _, _ = select.select([self._sock.fileno() ], [ ], [ ], 0)

                print 'polling_read: time left', time_left   #  Added for debugging
                if not ready:
                    if time_left == 0:
                        raise NetBIOSTimeout

I believe the "time_left == 0" should be changed to "time_left <= 0"

Here's output with the debug message in place:

$ ./test.py
polling_read: time left 0.5  ready: []
polling_read: time left 0.475  ready: [6]
polling_read: time left 0.5  ready: [6]
polling_read: time left 0.5  ready: []
polling_read: time left 0.475  ready: []
polling_read: time left 0.45  ready: []
polling_read: time left 0.425  ready: [6]
polling_read: time left 0.5  ready: [6]
polling_read: time left 0.5  ready: []
polling_read: time left 0.475  ready: [6]
polling_read: time left 0.5  ready: [6]
polling_read: time left 0.5  ready: []
polling_read: time left 0.475  ready: []
polling_read: time left 0.45  ready: []
polling_read: time left 0.425  ready: []
polling_read: time left 0.4  ready: []
polling_read: time left 0.375  ready: []
polling_read: time left 0.35  ready: []
polling_read: time left 0.325  ready: []
polling_read: time left 0.3  ready: []
polling_read: time left 0.275  ready: []
polling_read: time left 0.25  ready: []
polling_read: time left 0.225  ready: []
polling_read: time left 0.2  ready: []
polling_read: time left 0.175  ready: []
polling_read: time left 0.15  ready: []
polling_read: time left 0.125  ready: []
polling_read: time left 0.1  ready: []
polling_read: time left 0.075  ready: []
polling_read: time left 0.05  ready: []
polling_read: time left 0.025  ready: []
polling_read: time left -1.5959455979e-16  ready: []
polling_read: time left -0.025  ready: []
polling_read: time left -0.05  ready: []
polling_read: time left -0.075  ready: []
polling_read: time left -0.1  ready: []
polling_read: time left -0.125  ready: []
  .  .  .

So the timer heads toward zero but due to float rounding it never hits exactly 
zero.  As written, the code also seems to require the timeout to be an exactly 
multiple of the CHUNK_TIME (0.025).

Original issue reported on code.google.com by akful...@gmail.com on 17 May 2013 at 7:13

GoogleCodeExporter commented 9 years ago
hey akfullfo:

Thanks for the bug report.. interesting things about floating point ;).. I've 
just applied the suggested patch 
(http://code.google.com/p/impacket/source/detail?r=763) . Please verify it 
works for you so I can close the ticket.

thanks again!
beto

Original comment by bet...@gmail.com on 17 May 2013 at 7:33

GoogleCodeExporter commented 9 years ago
Hey beto,

I just pulled the tree and the change works fine.  Thanks for an amazingly 
quick turn around.  I would have been quick to respond too, but I had a fight 
with a dual AMD mobo over the weekend.  (Bad CPU2 socket but it will be a cool 
box when it is done!)

Andy

Original comment by akful...@gmail.com on 20 May 2013 at 2:23

GoogleCodeExporter commented 9 years ago
Hey Andy:

Good to know you won that fight ;).. good luck with that...

Awesome, I'm closing this ticket..

thanks again
beto

Original comment by bet...@gmail.com on 20 May 2013 at 2:35