Blame SOURCES/net-snmp-5.8-broken-errmsg.patch

77be88
diff -urNp a/agent/mibgroup/host/hrh_filesys.c b/agent/mibgroup/host/hrh_filesys.c
77be88
--- a/agent/mibgroup/host/hrh_filesys.c	2021-06-09 10:30:07.744455758 +0200
77be88
+++ b/agent/mibgroup/host/hrh_filesys.c	2021-06-09 10:32:50.657160232 +0200
77be88
@@ -219,6 +219,7 @@ var_hrhfilesys(struct variable *vp,
77be88
 {
77be88
     int             fsys_idx;
77be88
     static char    *string;
77be88
+    static char     empty_str[1];
77be88
 
77be88
     fsys_idx =
77be88
         header_hrhfilesys(vp, name, length, exact, var_len, write_method);
77be88
@@ -235,7 +236,7 @@ var_hrhfilesys(struct variable *vp,
77be88
         *var_len = 0;
77be88
         if (asprintf(&string, "%s", HRFS_entry->path) >= 0)
77be88
             *var_len = strlen(string);
77be88
-        return (u_char *) string;
77be88
+        return (u_char *)(string ? string : empty_str);
77be88
     case HRFSYS_RMOUNT:
77be88
         free(string);
77be88
         if (HRFS_entry->flags & NETSNMP_FS_FLAG_REMOTE) {
77be88
@@ -245,7 +246,7 @@ var_hrhfilesys(struct variable *vp,
77be88
             string = strdup("");
77be88
         }
77be88
         *var_len = string ? strlen(string) : 0;
77be88
-        return (u_char *) string;
77be88
+        return (u_char *)(string ? string : empty_str);
77be88
 
77be88
     case HRFSYS_TYPE:
77be88
         fsys_type_id[fsys_type_len - 1] = 
77be88
diff -urNp a/agent/mibgroup/ucd-snmp/disk.c b/agent/mibgroup/ucd-snmp/disk.c
77be88
--- a/agent/mibgroup/ucd-snmp/disk.c	2021-06-09 10:30:07.728455689 +0200
77be88
+++ b/agent/mibgroup/ucd-snmp/disk.c	2021-06-09 10:34:32.722597366 +0200
77be88
@@ -842,6 +842,7 @@ var_extensible_disk(struct variable *vp,
77be88
     struct dsk_entry entry;
77be88
     static long     long_ret;
77be88
     static char    *errmsg;
77be88
+    static char     empty_str[1];
77be88
 
77be88
     int i;
77be88
     for (i = 0; i < numdisks; i++){
77be88
@@ -950,7 +951,7 @@ tryAgain:
77be88
                 *var_len = strlen(errmsg);
77be88
             }
77be88
         }
77be88
-        return (u_char *) (errmsg);
77be88
+        return (u_char *)(errmsg ? errmsg : empty_str);
77be88
     }
77be88
     return NULL;
77be88
 }
77be88
diff -urNp a/agent/mibgroup/ucd-snmp/disk_hw.c b/agent/mibgroup/ucd-snmp/disk_hw.c
77be88
--- a/agent/mibgroup/ucd-snmp/disk_hw.c	2021-06-09 10:30:07.727455684 +0200
77be88
+++ b/agent/mibgroup/ucd-snmp/disk_hw.c	2021-06-09 10:35:53.420943010 +0200
77be88
@@ -314,6 +314,7 @@ var_extensible_disk(struct variable *vp,
77be88
     unsigned long long val;
77be88
     static long     long_ret;
77be88
     static char    *errmsg;
77be88
+    static char     empty_str[1];
77be88
     netsnmp_cache  *cache;
77be88
 
77be88
     /* Update the fsys H/W module */
77be88
@@ -432,7 +433,7 @@ tryAgain:
77be88
              >= 0)) {
77be88
             *var_len = strlen(errmsg);
77be88
         }
77be88
-        return (u_char *) errmsg;
77be88
+        return (u_char *)(errmsg ? errmsg : empty_str);
77be88
     }
77be88
     return NULL;
77be88
 }
77be88
diff -urNp a/agent/mibgroup/ucd-snmp/proc.c b/agent/mibgroup/ucd-snmp/proc.c
77be88
--- a/agent/mibgroup/ucd-snmp/proc.c	2021-06-09 10:30:07.725455676 +0200
77be88
+++ b/agent/mibgroup/ucd-snmp/proc.c	2021-06-09 10:37:31.143361548 +0200
77be88
@@ -267,7 +267,7 @@ var_extensible_proc(struct variable *vp,
77be88
     struct myproc  *proc;
77be88
     static long     long_ret;
77be88
     static char    *errmsg;
77be88
-
77be88
+    static char     empty_str[1];
77be88
 
77be88
     if (header_simple_table
77be88
         (vp, name, length, exact, var_len, write_method, numprocs))
77be88
@@ -330,7 +330,7 @@ var_extensible_proc(struct variable *vp,
77be88
                 }
77be88
             }
77be88
             *var_len = errmsg ? strlen(errmsg) : 0;
77be88
-            return ((u_char *) errmsg);
77be88
+            return (u_char *)(errmsg ? errmsg : empty_str);
77be88
         case ERRORFIX:
77be88
             *write_method = fixProcError;
77be88
             long_return = fixproc.result;