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

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