pyrad icon indicating copy to clipboard operation
pyrad copied to clipboard

Decode raises struct.error when dictionary has a different datatyle

Open gpaterno opened this issue 13 years ago • 0 comments
trafficstars

Hi! _DecodeValue in packet.py fails with struct.error when in a dictionary is specified an invalid datatype or when the value is different from what expected.

Either _DecodeValue or DecodeAttr in tools.py should trap this with a try/except.

Here's the trace ofthe error:

File "/usr/local/lib/python2.6/dist-packages/pyrad-1.2-py2.6.egg/pyrad/server.py", line 230, in _ProcessInput self._HandleAuthPacket(pkt) File "/srv/otp/lib/otpserver.py", line 140, in _HandleAuthPacket self.HandleAuthPacket(pkt, realm) File "/srv/otp/lib/otpserver.py", line 167, in HandleAuthPacket self.logger.debug("%s: %s" % (attr, pkt[attr])) File "/usr/local/lib/python2.6/dist-packages/pyrad-1.2-py2.6.egg/pyrad/packet.py", line 178, in getitem res.append(self._DecodeValue(attr, v)) File "/usr/local/lib/python2.6/dist-packages/pyrad-1.2-py2.6.egg/pyrad/packet.py", line 109, in _DecodeValue return tools.DecodeAttr(attr.type, value) File "/usr/local/lib/python2.6/dist-packages/pyrad-1.2-py2.6.egg/pyrad/tools.py", line 69, in DecodeAttr return DecodeInteger(value) File "/usr/local/lib/python2.6/dist-packages/pyrad-1.2-py2.6.egg/pyrad/tools.py", line 43, in DecodeInteger return (struct.unpack("!I", num))[0] struct.error: unpack requires a string argument of length 4

Thank you, Giuseppe

gpaterno avatar May 30 '12 15:05 gpaterno