• AVR Freaks

Hot!Snmp OctetString 4 byte problem

Author
eminkiran
New Member
  • Total Posts : 17
  • Reward points : 0
  • Joined: 2018/06/20 01:04:41
  • Location: 0
  • Status: offline
2018/12/14 01:17:26 (permalink)
0

Snmp OctetString 4 byte problem

Hello,
I am using Pic32mx795f512L.
I get a generic error when I send octetString value to long by 4 bytes tan over snmp. Does anyone know why?
Example I'm sending "user_1" to USER_SECURITY_NAME. If the value is greater than 4 bytes I get a general error and I can't change the value. No problem if I send the value as "user" 
 
 
 
I found this place as a result of research.
in snmp.c file TCPIP_SNMP_ProcessSetVar function  is limited to 4 bytes. When you do 16 bytes, the problem disappeared. Is this a bug?
 
// If the length of an integer is less than 0 bytes don't do anything
     if ((dataLen> 4) || (dataLen == 0))
     {
         return (0);
     }
 
 


Mplab X ide = v4.15
Compiler = xc32 v2.05
Harmony = v2_05_01
 
Best Regards
 
Emin KIRAN
post edited by eminkiran - 2018/12/17 00:17:35
#1

2 Replies Related Threads

    Carl Pickering
    New Member
    • Total Posts : 3
    • Reward points : 0
    • Joined: 2019/01/31 09:00:39
    • Location: 0
    • Status: offline
    Re: Snmp OctetString 4 byte problem 2019/02/02 03:59:09 (permalink)
    0
    It's a bug in the Microchip SNMP library. It just assumes all datatypes used in a set are between 1 and 4 bytes. They have a "solution" in Harmony2 that ignores the length check for octet strings. We can get away with this for our application but it's not really good enough. 
     
    In TCPIP_SNMP_ProcessSetVar around line 5032 it originally read:
     
    // if the length of a integer type is more than 4 or less than 0 bytes don't do anything
    if ((dataLen > 4) || (dataLen == 0))

        return (0);
    }
     
    but in Harmony2 it is:
     
    if(actualDataTypeInfo.asnType != OCTET_STRING)
    {
        // if the length of a integer type is more than 4 or less than 0 bytes don't do anything
        if ((dataLen > 4) || (dataLen == 0))
        { 
            return (0);
        }
    }
     
    I considered using the length in actualDataTypeInfo but looking at their tables I'm not convinced it would yield the right results for every tag so copied the lines from Harmony2 and can now accept longer strings.
     
    With this and the incorrectly encoded integers I really wonder how much testing has been carried out. These are schoolboy errors.
     
    #2
    Carl Pickering
    New Member
    • Total Posts : 3
    • Reward points : 0
    • Joined: 2019/01/31 09:00:39
    • Location: 0
    • Status: offline
    Re: Snmp OctetString 4 byte problem 2019/02/02 04:01:02 (permalink)
    0
    But thanks for posting the question - when I had this issue I thought I was going mad and spent a lot of hours trying to work out what I'd done wrong. When I knew somebody else had the same problem it made things easier.
    #3
    Jump to:
    © 2019 APG vNext Commercial Version 4.5