From: Michal Privoznik Date: Tue, 14 May 2019 08:40:27 +0000 (+0200) Subject: virCommand: Make virCommandPassFDGetFDIndex fail if passed command is in error state X-Git-Tag: v5.4.0-rc1~81 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb0c3a7066db7c07a24ae10cb586739178894c64;p=thirdparty%2Flibvirt.git virCommand: Make virCommandPassFDGetFDIndex fail if passed command is in error state 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 Reviewed-by: Erik Skultety --- diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 9e99697c55..8695c98d1b 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -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;