thecall->msg->bufferLength = client->msg.bufferLength;
thecall->msg->bufferOffset = client->msg.bufferOffset;
+ thecall->msg->nfds = client->msg.nfds;
+ thecall->msg->fds = client->msg.fds;
+ client->msg.nfds = 0;
+ client->msg.fds = NULL;
+
thecall->mode = VIR_NET_CLIENT_MODE_COMPLETE;
return 0;
if (client->msg.header.type == VIR_NET_REPLY_WITH_FDS) {
size_t i;
- if (virNetMessageDecodeNumFDs(&client->msg) < 0)
+
+ if (client->msg.nfds == 0 &&
+ virNetMessageDecodeNumFDs(&client->msg) < 0)
return -1;
for (i = client->msg.donefds ; i < client->msg.nfds ; i++) {
}
ret = virNetClientCallDispatch(client);
- client->msg.bufferOffset = client->msg.bufferLength = 0;
- VIR_FREE(client->msg.buffer);
+ virNetMessageClear(&client->msg);
/*
* We've completed one call, but we don't want to
* spin around the loop forever if there are many
goto error;
}
for (i = 0 ; i < *ninfds ; i++)
- *infds[i] = -1;
+ (*infds)[i] = -1;
for (i = 0 ; i < *ninfds ; i++) {
- if ((*infds[i] = dup(msg->fds[i])) < 0) {
+ if (((*infds)[i] = dup(msg->fds[i])) < 0) {
virReportSystemError(errno,
_("Cannot duplicate FD %d"),
msg->fds[i]);
goto error;
}
- if (virSetInherit(*infds[i], false) < 0) {
+ if (virSetInherit((*infds)[i], false) < 0) {
virReportSystemError(errno,
_("Cannot set close-on-exec %d"),
- *infds[i]);
+ (*infds)[i]);
goto error;
}
}
virNetMessageFree(msg);
if (infds && ninfds) {
for (i = 0 ; i < *ninfds ; i++)
- VIR_FORCE_CLOSE(*infds[i]);
+ VIR_FORCE_CLOSE((*infds)[i]);
}
return -1;
}
XDR xdr;
int ret = -1;
+ if (msg->bufferLength < VIR_NET_MESSAGE_LEN_MAX) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Unable to decode header until len is received"));
+ return -1;
+ }
+
msg->bufferOffset = VIR_NET_MESSAGE_LEN_MAX;
/* Parse the header. */