sasl: Remove stack allocated 8kb temporary buffers

Move the buffers to the heap allocated client/private data structs.
This commit is contained in:
Matthias Bolte 2011-04-03 11:21:20 +02:00
parent fb7f0051a2
commit 0e27b8a856
3 changed files with 12 additions and 7 deletions

View 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));

View 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

View 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,