Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Returned Address Sets always contains ip *.*.*.255 #4

Open
gonzochic opened this issue Feb 3, 2019 · 2 comments · Fixed by gabstv/netscan#1 · May be fixed by #7
Open

Returned Address Sets always contains ip *.*.*.255 #4

gonzochic opened this issue Feb 3, 2019 · 2 comments · Fixed by gabstv/netscan#1 · May be fixed by #7

Comments

@gonzochic
Copy link

Hi,
if you run Scan() the result will always contain the number of open ips on the specific port but always the same IP (e.g. 10.0.1.255 or 192.168.1.255).

This is caused because you dereference a variable inside a GO Routine which was referenced inside a Range Loop.

func (s *Scanner) Scan() []AddressSet {
	...
         // here you get a reference to the specific id
	for _, ip := range s.ips {

and then

                                                
                                                 // here you use the referenced IP which is at this time the last item of the range loop
						results = append(results, AddressSet{
							IP:       copyIP(ip),
							Port:     port,
							Protocol: proto,
						})
					

To fix that, you need to copy the id first into a variable and pass it into the go routine (as you did with address).

nitper added a commit to nitper/netscan that referenced this issue Mar 6, 2019
pass copies of `ip` and `port` into the goroutine
fixes jessfraz#4
@nitper nitper linked a pull request Mar 6, 2019 that will close this issue
@gabstv
Copy link

gabstv commented May 10, 2019

The current Scan() is unusable right now. I was thinking that something was wrong on my network. Thanks for the PR!

@gonzochic
Copy link
Author

gonzochic commented May 21, 2019

@jessfraz can you merge #7. Afterwards we can close.

@gonzochic gonzochic reopened this May 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants