]> git.proxmox.com Git - mirror_corosync-qdevice.git/commitdiff
tlv: Check dynar_cat result
authorJan Friesse <jfriesse@redhat.com>
Wed, 4 Nov 2020 16:46:38 +0000 (17:46 +0100)
committerJan Friesse <jfriesse@redhat.com>
Wed, 4 Nov 2020 16:52:04 +0000 (17:52 +0100)
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
qdevices/tlv.c

index beabd177de536a4a25fb0ee98698abb0a307a5c8..c741359b4c58838c8e5aec534d3646622a949821 100644 (file)
@@ -98,9 +98,17 @@ tlv_add(struct dynar *msg, enum tlv_opt_type opt_type, uint16_t opt_len, const v
        nopt_type = htons((uint16_t)opt_type);
        nlen = htons(opt_len);
 
-       dynar_cat(msg, &nopt_type, sizeof(nopt_type));
-       dynar_cat(msg, &nlen, sizeof(nlen));
-       dynar_cat(msg, value, opt_len);
+       if (dynar_cat(msg, &nopt_type, sizeof(nopt_type)) == -1) {
+               return (-1);
+       }
+
+       if (dynar_cat(msg, &nlen, sizeof(nlen)) == -1) {
+               return (-1);
+       }
+
+       if (dynar_cat(msg, value, opt_len) == -1) {
+               return (-1);
+       }
 
        return (0);
 }