Browse Source

Fix crash when receiving malformed labels via streaming. (#9715)

* Fix crash when receiving malformed labels via streaming.

* Disallow empty _virtualization values in system_info.
Markos Fountoulakis 4 years ago
parent
commit
b0bfec14e2
2 changed files with 9 additions and 0 deletions
  1. 5 0
      collectors/plugins.d/pluginsd_parser.c
  2. 4 0
      daemon/system-info.sh

+ 5 - 0
collectors/plugins.d/pluginsd_parser.c

@@ -517,6 +517,11 @@ PARSER_RC pluginsd_disable(char **words, void *user, PLUGINSD_ACTION  *plugins_a
 PARSER_RC pluginsd_label(char **words, void *user, PLUGINSD_ACTION  *plugins_action)
 {
     char *store;
+
+    if (!words[1] || !words[2] || !words[3]) {
+        error("Ignoring malformed or empty LABEL command.");
+        return PARSER_RC_OK;
+    }
     if (!words[4])
         store = words[3];
     else {

+ 4 - 0
daemon/system-info.sh

@@ -30,6 +30,10 @@ if [ -z "${VIRTUALIZATION}" ]; then
                     VIRTUALIZATION="none"
             fi
     fi
+    if [ -z "${VIRTUALIZATION}" ]; then
+      # Output from the command is outside of spec
+      VIRTUALIZATION="unknown"
+    fi
 else
     # Passed from outside - probably in docker run
     VIRT_DETECTION="provided"