mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 21:34:54 +03: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;
|
||||
ConnectionData *connection_data = conn->networkPrivateData;
|
||||
virBuffer tex_ret = VIR_BUFFER_INITIALIZER;
|
||||
char buffer[0x4000] = { 0 };
|
||||
char *buffer = NULL;
|
||||
size_t buffer_size = 16384;
|
||||
int exitcode;
|
||||
int bytecount = 0;
|
||||
int sock = connection_data->sock;
|
||||
int rc = 0;
|
||||
|
||||
if (VIR_ALLOC_N(buffer, buffer_size) < 0) {
|
||||
virReportOOMError();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Exec non-blocking on the remove host */
|
||||
while ((channel = libssh2_channel_open_session(session)) == NULL &&
|
||||
libssh2_session_last_error(session, NULL, NULL, 0) ==
|
||||
@ -144,7 +150,7 @@ phypExec(LIBSSH2_SESSION * session, char *cmd, int *exit_status,
|
||||
for (;;) {
|
||||
/* loop until we block */
|
||||
do {
|
||||
rc = libssh2_channel_read(channel, buffer, sizeof(buffer));
|
||||
rc = libssh2_channel_read(channel, buffer, buffer_size);
|
||||
if (rc > 0) {
|
||||
bytecount += rc;
|
||||
virBufferVSprintf(&tex_ret, "%s", buffer);
|
||||
@ -179,9 +185,12 @@ phypExec(LIBSSH2_SESSION * session, char *cmd, int *exit_status,
|
||||
err:
|
||||
(*exit_status) = SSH_CMD_ERR;
|
||||
virBufferFreeAndReset(&tex_ret);
|
||||
VIR_FREE(buffer);
|
||||
return NULL;
|
||||
|
||||
exit:
|
||||
VIR_FREE(buffer);
|
||||
|
||||
if (virBufferError(&tex_ret)) {
|
||||
virBufferFreeAndReset(&tex_ret);
|
||||
virReportOOMError();
|
||||
|
Loading…
Reference in New Issue
Block a user