mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 15:27:47 +00:00
xend: Remove 4kb stack allocation
This commit is contained in:
parent
3ac2a6f1b5
commit
9faf3d084c
@ -279,11 +279,17 @@ istartswith(const char *haystack, const char *needle)
|
||||
static int ATTRIBUTE_NONNULL (2)
|
||||
xend_req(int fd, char **content)
|
||||
{
|
||||
char buffer[4096];
|
||||
char *buffer;
|
||||
size_t buffer_size = 4096;
|
||||
int content_length = 0;
|
||||
int retcode = 0;
|
||||
|
||||
while (sreads(fd, buffer, sizeof(buffer)) > 0) {
|
||||
if (VIR_ALLOC_N(buffer, buffer_size) < 0) {
|
||||
virReportOOMError();
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (sreads(fd, buffer, buffer_size) > 0) {
|
||||
if (STREQ(buffer, "\r\n"))
|
||||
break;
|
||||
|
||||
@ -293,6 +299,8 @@ xend_req(int fd, char **content)
|
||||
retcode = atoi(buffer + 9);
|
||||
}
|
||||
|
||||
VIR_FREE(buffer);
|
||||
|
||||
if (content_length > 0) {
|
||||
ssize_t ret;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user