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

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