btimby / py-radius

RADIUS authentication module
Other
62 stars 38 forks source link

IndexError when passwd > 16 #2

Closed diegows closed 12 years ago

diegows commented 12 years ago

The module fails when the user password is bigger than 16.

Traceback (most recent call last): File "/usr/lib/python2.7/pdb.py", line 1314, in main pdb._runscript(mainpyfile) File "/usr/lib/python2.7/pdb.py", line 1233, in _runscript self.run(statement) File "/usr/lib/python2.7/bdb.py", line 387, in run exec cmd in globals, locals File "", line 1, in File "/usr/local/bin/squid-radius-auth.py", line 3, in from radius import RADIUS, NoResponse File "/usr/local/lib/python2.7/dist-packages/radius.py", line 143, in authenticate encpass = self.radcrypt(authenticator,passwd,1) File "/usr/local/lib/python2.7/dist-packages/radius.py", line 121, in radcrypt r = r + chr( ord(md5vec[i]) ^ ord(text[i]) ) IndexError: string index out of range

btimby commented 12 years ago

I committed a fix for this issue, it is in trunk, but I have not yet built a release.

Can you confirm this is working for you?

diegows commented 12 years ago

Hi, Sorry for the delay. I was too busy. It doesn't work:

Traceback (most recent call last):
  File "radius.py", line 210, in <module>
    if r.authenticate(uname,passwd):
  File "radius.py", line 142, in authenticate
    encpass = self.radcrypt(authenticator,passwd,1)
TypeError: radcrypt() takes exactly 3 arguments (4 given)

I think that you should remove the third argument.

btimby commented 12 years ago

Diego, my bad, I had removed a parameter from the radcrypt function, but forgot to update a call to it. I just pushed a fix and created a new download (tarball).

If you don't mind trying again, I think it will work this time.

I will be looking at how to write a unit test (maybe using mock) to ensure the library works to prevent stupid mistakes like this in the future.

Thanks.

diegows commented 12 years ago

Hi, don't worry.

I've tried the latest version and works.

Thanks!

btimby commented 12 years ago

Awesome! Thanks for your patience. I am going to close this issue.