[PATCH 12/20] daemon: Remove 4kb stack allocation of security label

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

 



---
 daemon/remote.c |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index 1700c2d..dd85ef1 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -1607,7 +1607,7 @@ remoteDispatchDomainGetSecurityLabel(struct qemud_server *server ATTRIBUTE_UNUSE
                                      remote_domain_get_security_label_ret *ret)
 {
     virDomainPtr dom;
-    virSecurityLabel seclabel;
+    virSecurityLabelPtr seclabel;
 
     dom = get_nonnull_domain(conn, args->dom);
     if (dom == NULL) {
@@ -1615,22 +1615,30 @@ remoteDispatchDomainGetSecurityLabel(struct qemud_server *server ATTRIBUTE_UNUSE
         return -1;
     }
 
-    memset(&seclabel, 0, sizeof seclabel);
-    if (virDomainGetSecurityLabel(dom, &seclabel) == -1) {
+    if (VIR_ALLOC(seclabel) < 0) {
+        virDomainFree(dom);
+        remoteDispatchOOMError(rerr);
+        return -1;
+    }
+
+    if (virDomainGetSecurityLabel(dom, seclabel) == -1) {
         remoteDispatchConnError(rerr, conn);
         virDomainFree(dom);
+        VIR_FREE(seclabel);
         return -1;
     }
 
-    ret->label.label_len = strlen(seclabel.label) + 1;
+    ret->label.label_len = strlen(seclabel->label) + 1;
     if (VIR_ALLOC_N(ret->label.label_val, ret->label.label_len) < 0) {
         virDomainFree(dom);
+        VIR_FREE(seclabel);
         remoteDispatchOOMError(rerr);
         return -1;
     }
-    strcpy(ret->label.label_val, seclabel.label);
-    ret->enforcing = seclabel.enforcing;
+    strcpy(ret->label.label_val, seclabel->label);
+    ret->enforcing = seclabel->enforcing;
     virDomainFree(dom);
+    VIR_FREE(seclabel);
 
     return 0;
 }
-- 
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]