[PATCH 19/20] xend: Remove 4kb stack allocation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 src/xen/xend_internal.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index 8859373..8b07a8a 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -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;
 
-- 
1.7.0.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]