]> xenbits.xensource.com Git - libvirt.git/commitdiff
virCommand: Make virCommandPassFDGetFDIndex fail if passed command is in error state
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 14 May 2019 08:40:27 +0000 (10:40 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 14 May 2019 13:58:30 +0000 (15:58 +0200)
The idea of virCommand* APIs is that a possible error that
occurred while constructing cmd line is kept in virCommand
struct. If that's the case all subsequent calls to virCommand*()
are NO-OPs or they return an error. Well,
virCommandPassFDGetFDIndex() is not honoring that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
src/util/vircommand.c

index 9e99697c55f27d1e3e3bb4d06dd4bf52a483b3a1..8695c98d1babb4ef51052a92571cbdf032c2f5dc 100644 (file)
@@ -1034,6 +1034,9 @@ virCommandPassFDGetFDIndex(virCommandPtr cmd, int fd)
 {
     size_t i = 0;
 
+    if (!cmd || cmd->has_error)
+        return -1;
+
     while (i < cmd->npassfd) {
         if (cmd->passfd[i].fd == fd)
             return i;