]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - rdma/res.c
rdma/sys.c: fix possible out-of-bound array access
[mirror_iproute2.git] / rdma / res.c
index ef863f142eca1c8da9f63eacf1e4973ba0d60f73..6003006e98aa43ca32a481240d541f84bbf9c809 100644 (file)
@@ -148,9 +148,11 @@ const char *qp_types_to_str(uint8_t idx)
                                                     "UC", "UD", "RAW_IPV6",
                                                     "RAW_ETHERTYPE",
                                                     "UNKNOWN", "RAW_PACKET",
-                                                    "XRC_INI", "XRC_TGT" };
+                                                    "XRC_INI", "XRC_TGT",
+                                                    [0xFF] = "DRIVER",
+       };
 
-       if (idx < ARRAY_SIZE(qp_types_str))
+       if (idx < ARRAY_SIZE(qp_types_str) && qp_types_str[idx])
                return qp_types_str[idx];
        return "UNKNOWN";
 }
@@ -159,6 +161,9 @@ void print_comm(struct rd *rd, const char *str, struct nlattr **nla_line)
 {
        char tmp[18];
 
+       if (!str)
+               return;
+
        if (rd->json_output) {
                /* Don't beatify output in JSON format */
                jsonw_string_field(rd->jw, "comm", str);