Blame SOURCES/net-snmp-5.7.2-CVE-2020-15862.patch

d2813a
diff -urNp old/agent/mibgroup/agent/extend.c new/agent/mibgroup/agent/extend.c
d2813a
--- old/agent/mibgroup/agent/extend.c	2020-11-11 12:41:46.377115142 +0100
d2813a
+++ new/agent/mibgroup/agent/extend.c	2020-11-11 12:50:28.047142105 +0100
d2813a
@@ -16,6 +16,12 @@
d2813a
 #define SHELLCOMMAND 3
d2813a
 #endif
d2813a
 
d2813a
+/*  This mib is potentially dangerous to turn on by default, since it
d2813a
+ *  allows arbitrary commands to be set by anyone with SNMP WRITE
d2813a
+ *  access to the MIB table.  If all of your users are "root" level
d2813a
+ *  users, then it may be safe to turn on. */
d2813a
+#define ENABLE_EXTEND_WRITE_ACCESS 0
d2813a
+
d2813a
 netsnmp_feature_require(extract_table_row_data)
d2813a
 netsnmp_feature_require(table_data_delete_table)
d2813a
 #ifndef NETSNMP_NO_WRITE_SUPPORT
d2813a
@@ -723,7 +729,7 @@ handle_nsExtendConfigTable(netsnmp_mib_h
d2813a
          *
d2813a
          **********/
d2813a
 
d2813a
-#ifndef NETSNMP_NO_WRITE_SUPPORT
d2813a
+#if !defined(NETSNMP_NO_WRITE_SUPPORT) && ENABLE_EXTEND_WRITE_ACCESS
d2813a
         case MODE_SET_RESERVE1:
d2813a
             /*
d2813a
              * Validate the new assignments
d2813a
@@ -1049,7 +1055,7 @@ handle_nsExtendConfigTable(netsnmp_mib_h
d2813a
                 }
d2813a
             }
d2813a
             break;
d2813a
-#endif /* !NETSNMP_NO_WRITE_SUPPORT */ 
d2813a
+#endif /* !NETSNMP_NO_WRITE_SUPPORT and ENABLE_EXTEND_WRITE_ACCESS */
d2813a
 
d2813a
         default:
d2813a
             netsnmp_set_request_error(reqinfo, request, SNMP_ERR_GENERR);
d2813a
@@ -1057,7 +1063,7 @@ handle_nsExtendConfigTable(netsnmp_mib_h
d2813a
         }
d2813a
     }
d2813a
 
d2813a
-#ifndef NETSNMP_NO_WRITE_SUPPORT
d2813a
+#if !defined(NETSNMP_NO_WRITE_SUPPORT) && ENABLE_EXTEND_WRITE_ACCESS
d2813a
     /*
d2813a
      * If we're marking a given row as active,
d2813a
      *  then we need to check that it's ready.
d2813a
@@ -1082,7 +1088,7 @@ handle_nsExtendConfigTable(netsnmp_mib_h
d2813a
             }
d2813a
         }
d2813a
     }
d2813a
-#endif /* !NETSNMP_NO_WRITE_SUPPORT */
d2813a
+#endif /* !NETSNMP_NO_WRITE_SUPPORT && ENABLE_EXTEND_WRITE_ACCESS */
d2813a
     
d2813a
     return SNMP_ERR_NOERROR;
d2813a
 }
d2813a
@@ -1571,7 +1577,7 @@ fixExec2Error(int action,
d2813a
     idx = name[name_len-1] -1;
d2813a
     exten = &compatability_entries[ idx ];
d2813a
 
d2813a
-#ifndef NETSNMP_NO_WRITE_SUPPORT
d2813a
+#if !defined(NETSNMP_NO_WRITE_SUPPORT) && ENABLE_EXTEND_WRITE_ACCESS
d2813a
     switch (action) {
d2813a
     case MODE_SET_RESERVE1:
d2813a
         if (var_val_type != ASN_INTEGER) {
d2813a
@@ -1592,7 +1598,7 @@ fixExec2Error(int action,
d2813a
     case MODE_SET_COMMIT:
d2813a
         netsnmp_cache_check_and_reload( exten->efix_entry->cache );
d2813a
     }
d2813a
-#endif /* !NETSNMP_NO_WRITE_SUPPORT */
d2813a
+#endif /* !NETSNMP_NO_WRITE_SUPPORT && ENABLE_EXTEND_WRITE_ACCESS */
d2813a
     return SNMP_ERR_NOERROR;
d2813a
 }
d2813a
 #endif /* USING_UCD_SNMP_EXTENSIBLE_MODULE */