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

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