net-snmp
net-snmp copied to clipboard
Net-SNMP not properly parsing output
Using net-snmp I'm fetching a certain value which always comes back as a mixture of different encoding formats. For example, one the results was 210235399110D1000030\x00. Looking through the library, I've singled-out this line as the main cause:
https://github.com/mixtli/net-snmp/blob/490fa59d1a8b46c9d26b7288b2f9d4b2a47ff70f/lib/net/snmp/varbind.rb#L34
Problem is, the struct val has different length than the string being fetched. This will cause the #read_string call to access an invalid memory address (the "\x00"), causing the misleading output above. I've corrected it by just calling:
# lib/net/snmp/varbind.rb:36
struct.val[:string].read_string
is this enough? Or is the call with the length there for some reason I'm not getting?