chiark / gitweb /
libsystemd-network: Avoid potential NULL dereference in test-lldp
[elogind.git] / src / libsystemd-network / test-lldp.c
index e9d5d7bb60e0c72db6fd96cfe79dd39dc46c73eb..2e6bf14e8126202a80488d78d86fbc13f9d8e3b8 100644 (file)
@@ -144,6 +144,7 @@ static int lldp_parse_port_id_tlv(tlv_packet *m) {
                 assert_se(tlv_packet_read_string(m, &str, &length) >= 0);
 
                 p = malloc0(length + 1);
+                assert_se(p);
                 strncpy(p, str, length-1);
 
                 assert_se(streq(p, TEST_LLDP_PORT) == 1);
@@ -165,6 +166,7 @@ static int lldp_parse_system_name_tlv(tlv_packet *m) {
         assert_se(tlv_packet_read_string(m, &str, &length) >= 0);
 
         p = malloc0(length + 1);
+        assert_se(p);
         strncpy(p, str, length);
 
         assert_se(streq(p, TEST_LLDP_TYPE_SYSTEM_NAME) == 1);
@@ -182,6 +184,7 @@ static int lldp_parse_system_desc_tlv(tlv_packet *m) {
         assert_se(tlv_packet_read_string(m, &str, &length) >= 0);
 
         p = malloc0(length + 1);
+        assert_se(p);
         strncpy(p, str, length);
 
         assert_se(streq(p, TEST_LLDP_TYPE_SYSTEM_DESC) == 1);