]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
sasl: Remove stack allocated 8kb temporary buffers
authorMatthias Bolte <matthias.bolte@googlemail.com>
Sun, 3 Apr 2011 09:21:20 +0000 (11:21 +0200)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Tue, 5 Apr 2011 06:55:27 +0000 (08:55 +0200)
Move the buffers to the heap allocated client/private data structs.

daemon/libvirtd.c
daemon/libvirtd.h
src/remote/remote_driver.c

index 024f56fb923eb0638aaad6a35f987eee87e4853d..42cbe5d2515e8334259427f7e538e66c7cc5ccfd 100644 (file)
@@ -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));
index 7da3cfd293c84b3181800a575e0bdae20d442a30..d37c3fd648344b8a70ec994c000098f14496058b 100644 (file)
@@ -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
index 166968af6dff83bdee1661f9eaef0aa00b53e2d3..9310ddf66b7b9d65dccb48c09161642d89ca5095 100644 (file)
@@ -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
@@ -10065,15 +10067,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,