mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
phyp: Remove 16kb stack allocation
Allocate on the heap instead.
This commit is contained in:
parent
97176c6350
commit
d1591ad50b
@ -115,12 +115,18 @@ phypExec(LIBSSH2_SESSION * session, char *cmd, int *exit_status,
|
|||||||
LIBSSH2_CHANNEL *channel;
|
LIBSSH2_CHANNEL *channel;
|
||||||
ConnectionData *connection_data = conn->networkPrivateData;
|
ConnectionData *connection_data = conn->networkPrivateData;
|
||||||
virBuffer tex_ret = VIR_BUFFER_INITIALIZER;
|
virBuffer tex_ret = VIR_BUFFER_INITIALIZER;
|
||||||
char buffer[0x4000] = { 0 };
|
char *buffer = NULL;
|
||||||
|
size_t buffer_size = 16384;
|
||||||
int exitcode;
|
int exitcode;
|
||||||
int bytecount = 0;
|
int bytecount = 0;
|
||||||
int sock = connection_data->sock;
|
int sock = connection_data->sock;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
|
if (VIR_ALLOC_N(buffer, buffer_size) < 0) {
|
||||||
|
virReportOOMError();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Exec non-blocking on the remove host */
|
/* Exec non-blocking on the remove host */
|
||||||
while ((channel = libssh2_channel_open_session(session)) == NULL &&
|
while ((channel = libssh2_channel_open_session(session)) == NULL &&
|
||||||
libssh2_session_last_error(session, NULL, NULL, 0) ==
|
libssh2_session_last_error(session, NULL, NULL, 0) ==
|
||||||
@ -144,7 +150,7 @@ phypExec(LIBSSH2_SESSION * session, char *cmd, int *exit_status,
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
/* loop until we block */
|
/* loop until we block */
|
||||||
do {
|
do {
|
||||||
rc = libssh2_channel_read(channel, buffer, sizeof(buffer));
|
rc = libssh2_channel_read(channel, buffer, buffer_size);
|
||||||
if (rc > 0) {
|
if (rc > 0) {
|
||||||
bytecount += rc;
|
bytecount += rc;
|
||||||
virBufferVSprintf(&tex_ret, "%s", buffer);
|
virBufferVSprintf(&tex_ret, "%s", buffer);
|
||||||
@ -179,9 +185,12 @@ phypExec(LIBSSH2_SESSION * session, char *cmd, int *exit_status,
|
|||||||
err:
|
err:
|
||||||
(*exit_status) = SSH_CMD_ERR;
|
(*exit_status) = SSH_CMD_ERR;
|
||||||
virBufferFreeAndReset(&tex_ret);
|
virBufferFreeAndReset(&tex_ret);
|
||||||
|
VIR_FREE(buffer);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
|
VIR_FREE(buffer);
|
||||||
|
|
||||||
if (virBufferError(&tex_ret)) {
|
if (virBufferError(&tex_ret)) {
|
||||||
virBufferFreeAndReset(&tex_ret);
|
virBufferFreeAndReset(&tex_ret);
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
|
Loading…
Reference in New Issue
Block a user