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

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