noxxi / p5-ssl-tools

various standalone perl scripts
199 stars 78 forks source link

Use index variable for $ip #9

Closed ghost closed 9 years ago

ghost commented 9 years ago

I haven't done any perl programming in over a decade, so the code style here is probably horrible.

On my system, shift doesn't work so when testing http_upgrade I ended up in an infinite loop where it kept trying $ip[0] over and over.

I added an index variable so it can loop, and a check for the max ip numbers.

One problem I don't know how to fix is that if the array of ip addresses has an ipv6 address in it, this loop will eventually fail. Example: ./analyze-ssl.pl --starttls http_upgrade www.google.com:80

I either get one ipv4 address and one ipv6 - or I get 4 ipv4 addresses and one ipv6.

The ipv4 addresses work perfectly and it loops fine, when it reaches the ipv6 address it dies. Adding a check to see if it is ipv6 at line 206 and skipping to the next loop would be good - I just don't know how.

In any case, thanks for the great utility! I was able to very quickly verify what I wanted to know[that google does not support starttls in http sessions] and I can move on to other projects. I figured I'd send back my semi functional fix in case it helps anyone else - but since I focus on PHP development I didn't take the time to figure out how to fix the other half of the bug - sorry.

noxxi commented 9 years ago

Thanks for reporting the problem and for the patch. Based on your example I could reproduce the issue and fix it, although a bit different to your patch. See 5cad40a4

ghost commented 9 years ago

Thanks..no worries about using a different solution - my code was definitely an ugly hack - I just needed it to work and different coding styles weren't important to me but I expected you would want to rewrite the code so it fit in with your style - always easier to maintain code when it is all in one style. :)

p10n commented 9 years ago

DI Philipp Prause (mobil)

Am 11.05.2015 um 18:34 schrieb Gary A Mort notifications@github.com:

Thanks..no worries about using a different solution - my code was definitely an ugly hack - I just needed it to work and different coding styles weren't important to me but I expected you would want to rewrite the code so it fit in with your style - always easier to maintain code when it is all in one style. :)

— Reply to this email directly or view it on GitHub.