[PATCH 07/20] sasl: Remove stack allocated 8kb temporary buffers

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

 



Move the buffers to the heap allocated client/private data structs.
---
 daemon/libvirtd.c          |   10 ++++++----
 daemon/libvirtd.h          |    1 +
 src/remote/remote_driver.c |    8 +++++---
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 024f56f..42cbe5d 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -1766,15 +1766,17 @@ static ssize_t qemudClientReadSASL(struct qemud_client *client) {
     /* Need to read some more data off the wire */
     if (client->saslDecoded == NULL) {
         int ret;
-        char encoded[8192];
-        ssize_t encodedLen = sizeof(encoded);
-        encodedLen = qemudClientReadBuf(client, encoded, encodedLen);
+        ssize_t encodedLen;
+
+        encodedLen = qemudClientReadBuf(client, client->saslTemporary,
+                                        sizeof(client->saslTemporary));
 
         if (encodedLen <= 0)
             return encodedLen;
 
-        ret = sasl_decode(client->saslconn, encoded, encodedLen,
+        ret = sasl_decode(client->saslconn, client->saslTemporary, encodedLen,
                           &client->saslDecoded, &client->saslDecodedLength);
+
         if (ret != SASL_OK) {
             VIR_ERROR(_("failed to decode SASL data %s"),
                       sasl_errstring(ret, NULL, NULL));
diff --git a/daemon/libvirtd.h b/daemon/libvirtd.h
index 7da3cfd..d37c3fd 100644
--- a/daemon/libvirtd.h
+++ b/daemon/libvirtd.h
@@ -213,6 +213,7 @@ struct qemud_client {
     unsigned int saslEncodedLength;
     unsigned int saslEncodedOffset;
     char *saslUsername;
+    char saslTemporary[8192]; /* temorary holds data to be decoded */
 # endif
 
     /* Count of meages in 'dx' or 'tx' queue
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index bf94e70..942ff4b 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -174,6 +174,8 @@ struct private_data {
     const char *saslEncoded;
     unsigned int saslEncodedLength;
     unsigned int saslEncodedOffset;
+
+    char saslTemporary[8192]; /* temorary holds data to be decoded */
 #endif
 
     /* Buffer for incoming data packets
@@ -10063,15 +10065,15 @@ remoteIOReadMessage(struct private_data *priv) {
 #if HAVE_SASL
     if (priv->saslconn) {
         if (priv->saslDecoded == NULL) {
-            char encoded[8192];
             int ret, err;
-            ret = remoteIOReadBuffer(priv, encoded, sizeof(encoded));
+            ret = remoteIOReadBuffer(priv, priv->saslTemporary,
+                                     sizeof(priv->saslTemporary));
             if (ret < 0)
                 return -1;
             if (ret == 0)
                 return 0;
 
-            err = sasl_decode(priv->saslconn, encoded, ret,
+            err = sasl_decode(priv->saslconn, priv->saslTemporary, ret,
                               &priv->saslDecoded, &priv->saslDecodedLength);
             if (err != SASL_OK) {
                 remoteError(VIR_ERR_INTERNAL_ERROR,
-- 
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]