Menu

#2810 Logical error in agent/helpers/table.c when --enable-read-only is used during configuring

linux
pending
None
2
2018-04-11
2017-11-04
No

When configuring net-snmp version 5.7.3 from the source, --enable-read-only will cause NETSNMP_NO_WRITE_SUPPORT to be #defined. Reviewing the source agent/helpers/table.c, I noticed the following segment of code will behave differently depneds on --enable-read-only is used or not:
line #478:

#ifndef NETSNMP_NO_WRITE_SUPPORT
                if (reqinfo->mode == MODE_SET_RESERVE1)
                    table_helper_cleanup(reqinfo, request,
                                         SNMP_ERR_NOTWRITABLE);
                else if (reqinfo->mode == MODE_GET)
#endif /* NETSNMP_NO_WRITE_SUPPORT */
                    table_helper_cleanup(reqinfo, request,
                                         SNMP_NOSUCHOBJECT);

In the above segment, if NETSNMP_NO_WRITE_SUPPORT is defined, function "table_helper_cleanup" is called without checking (reqinfo->mode == MODE_GET). I think the correct logic should be:

#ifndef NETSNMP_NO_WRITE_SUPPORT
                if (reqinfo->mode == MODE_SET_RESERVE1)
                    table_helper_cleanup(reqinfo, request,
                                         SNMP_ERR_NOTWRITABLE);
                else 
#endif /* NETSNMP_NO_WRITE_SUPPORT */
                 if (reqinfo->mode == MODE_GET)
                    table_helper_cleanup(reqinfo, request,
                                         SNMP_NOSUCHOBJECT);

I do not have a specific example to demonstrate the problem. I believe if you create an agentX subagent for a MIB with tables defined, you could see different behavior with get operation on table objects when net-snmp package is built with or without "--enable-read-only" configuration option,

Discussion

  • Bill Fenner

    Bill Fenner - 2018-03-24
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,5 +1,6 @@
     When configuring net-snmp version 5.7.3 from the source, --enable-read-only will cause NETSNMP_NO_WRITE_SUPPORT to be #defined. Reviewing the source agent/helpers/table.c, I noticed the following segment of code will behave differently depneds on  --enable-read-only is used or not:
     line #478:
    +~~~
     #ifndef NETSNMP_NO_WRITE_SUPPORT
                     if (reqinfo->mode == MODE_SET_RESERVE1)
                         table_helper_cleanup(reqinfo, request,
    @@ -8,7 +9,9 @@
     #endif /* NETSNMP_NO_WRITE_SUPPORT */
                         table_helper_cleanup(reqinfo, request,
                                              SNMP_NOSUCHOBJECT);
    +~~~
     In the above segment, if NETSNMP_NO_WRITE_SUPPORT is defined, function "table_helper_cleanup" is called without checking (reqinfo->mode == MODE_GET). I think the correct logic should be:
    +~~~
     #ifndef NETSNMP_NO_WRITE_SUPPORT
                     if (reqinfo->mode == MODE_SET_RESERVE1)
                         table_helper_cleanup(reqinfo, request,
    @@ -18,6 +21,7 @@
                      if (reqinfo->mode == MODE_GET)
                         table_helper_cleanup(reqinfo, request,
                                              SNMP_NOSUCHOBJECT);
    +~~~
    
    
     I do not have a specific example to demonstrate the problem. I believe if you create an agentX subagent for a MIB with tables defined, you could see different behavior with get operation on table objects when net-snmp package is built with or without "--enable-read-only" configuration option,
    
     
  • Bill Fenner

    Bill Fenner - 2018-03-24

    Just reformatted the report to be more readable.

     
  • Bill Fenner

    Bill Fenner - 2018-04-11
    • status: open --> pending
    • assigned_to: Bill Fenner
     
  • Bill Fenner

    Bill Fenner - 2018-04-11

    I've committed a patch to the V5-7-patches and master git branches. Could you please test?

     

Log in to post a comment.

MongoDB Logo MongoDB