bbusschots / hsxkpasswd

A Perl module and terminal command for generating secure memorable passwords inspired by the fabulous XKCD web comic and Steve Gibson's Password Hay Stacks. This is the library that powers www.xkpasswd.net
http://www.bartb.ie/xkpasswd
BSD 2-Clause "Simplified" License
278 stars 48 forks source link

Use of uninitialized value $word #1

Closed hortocam closed 10 years ago

hortocam commented 10 years ago

I'm testing the module and have been using substitution characters. My test script is included in the Gist below.

The module throws this error when processing:

Use of uninitialized value $word in substitution (s///) at /Users/chorton/KomodoProjects/xkpasswd.pm/xkpasswd.pm//XKPasswd.pm line 2329. Use of uninitialized value $words[4] in join or string at /Users/chorton/KomodoProjects/xkpasswd.pm/xkpasswd.pm//XKPasswd.pm line 1260.

https://gist.github.com/hortocam/d182ed5f5ee0b4d06a31#file-test_xkpasswd-pm-pl

hortocam commented 10 years ago

This is happening because the iterator in _substitute_characters() is not reduced to account for the zero-based index of the array.

I will submit a pull request with a suggested fix.