]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Remove VIR_STRNDUP usage with checked pointers
authorJán Tomko <jtomko@redhat.com>
Thu, 24 Oct 2019 17:34:57 +0000 (19:34 +0200)
committerJán Tomko <jtomko@redhat.com>
Thu, 12 Dec 2019 13:24:34 +0000 (14:24 +0100)
Remove the usage where sanity of the length argument is verified
by other conditions not matching the previous patches.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/libxl/xen_common.c
tools/vsh.c

index 8c07df80b6843cffd462fc064241d9e8ebd10c81..912dd8834aef4475c177e827c8ae7f3cf72f69b7 100644 (file)
@@ -815,9 +815,8 @@ xenParseSxprChar(const char *value,
             goto error;
         }
 
-        if (offset != value &&
-            VIR_STRNDUP(def->source->data.tcp.host, value, offset - value) < 0)
-            goto error;
+        if (offset != value)
+            def->source->data.tcp.host = g_strndup(value, offset - value);
 
         offset2 = strchr(offset, ',');
         offset++;
@@ -843,9 +842,9 @@ xenParseSxprChar(const char *value,
             goto error;
         }
 
-        if (offset != value &&
-            VIR_STRNDUP(def->source->data.udp.connectHost, value, offset - value) < 0)
-            goto error;
+        if (offset != value)
+            def->source->data.udp.connectHost = g_strndup(value,
+                                                          offset - value);
 
         offset2 = strchr(offset, '@');
         if (offset2 != NULL) {
@@ -860,10 +859,9 @@ xenParseSxprChar(const char *value,
                 goto error;
             }
 
-            if (offset3 > (offset2 + 1) &&
-                VIR_STRNDUP(def->source->data.udp.bindHost,
-                            offset2 + 1, offset3 - offset2 - 1) < 0)
-                goto error;
+            if (offset3 > (offset2 + 1))
+                def->source->data.udp.bindHost = g_strndup(offset2 + 1,
+                                                           offset3 - offset2 - 1);
 
             def->source->data.udp.bindService = g_strdup(offset3 + 1);
         } else {
index dd2c039b47b2102527490fa94b20db233cee2178..5ccda5ab4462520f92dc3ea4de513c39dbe7dca9 100644 (file)
@@ -348,9 +348,8 @@ vshCmddefCheckInternals(vshControl *ctl,
                          cmd->name);
                 return -1; /* alias options are tracked by the original name */
             }
-            if ((p = strchr(name, '=')) &&
-                VIR_STRNDUP(name, name, p - name) < 0)
-                return -1;
+            if ((p = strchr(name, '=')))
+                name = g_strndup(name, p - name);
             for (j = i + 1; cmd->opts[j].name; j++) {
                 if (STREQ(name, cmd->opts[j].name) &&
                     cmd->opts[j].type != VSH_OT_ALIAS)