提交 0e27b8a8 编写于 作者: M Matthias Bolte

sasl: Remove stack allocated 8kb temporary buffers

Move the buffers to the heap allocated client/private data structs.
上级 fb7f0051
...@@ -1766,15 +1766,17 @@ static ssize_t qemudClientReadSASL(struct qemud_client *client) { ...@@ -1766,15 +1766,17 @@ static ssize_t qemudClientReadSASL(struct qemud_client *client) {
/* Need to read some more data off the wire */ /* Need to read some more data off the wire */
if (client->saslDecoded == NULL) { if (client->saslDecoded == NULL) {
int ret; int ret;
char encoded[8192]; ssize_t encodedLen;
ssize_t encodedLen = sizeof(encoded);
encodedLen = qemudClientReadBuf(client, encoded, encodedLen); encodedLen = qemudClientReadBuf(client, client->saslTemporary,
sizeof(client->saslTemporary));
if (encodedLen <= 0) if (encodedLen <= 0)
return encodedLen; return encodedLen;
ret = sasl_decode(client->saslconn, encoded, encodedLen, ret = sasl_decode(client->saslconn, client->saslTemporary, encodedLen,
&client->saslDecoded, &client->saslDecodedLength); &client->saslDecoded, &client->saslDecodedLength);
if (ret != SASL_OK) { if (ret != SASL_OK) {
VIR_ERROR(_("failed to decode SASL data %s"), VIR_ERROR(_("failed to decode SASL data %s"),
sasl_errstring(ret, NULL, NULL)); sasl_errstring(ret, NULL, NULL));
......
...@@ -213,6 +213,7 @@ struct qemud_client { ...@@ -213,6 +213,7 @@ struct qemud_client {
unsigned int saslEncodedLength; unsigned int saslEncodedLength;
unsigned int saslEncodedOffset; unsigned int saslEncodedOffset;
char *saslUsername; char *saslUsername;
char saslTemporary[8192]; /* temorary holds data to be decoded */
# endif # endif
/* Count of meages in 'dx' or 'tx' queue /* Count of meages in 'dx' or 'tx' queue
......
...@@ -174,6 +174,8 @@ struct private_data { ...@@ -174,6 +174,8 @@ struct private_data {
const char *saslEncoded; const char *saslEncoded;
unsigned int saslEncodedLength; unsigned int saslEncodedLength;
unsigned int saslEncodedOffset; unsigned int saslEncodedOffset;
char saslTemporary[8192]; /* temorary holds data to be decoded */
#endif #endif
/* Buffer for incoming data packets /* Buffer for incoming data packets
...@@ -10065,15 +10067,15 @@ remoteIOReadMessage(struct private_data *priv) { ...@@ -10065,15 +10067,15 @@ remoteIOReadMessage(struct private_data *priv) {
#if HAVE_SASL #if HAVE_SASL
if (priv->saslconn) { if (priv->saslconn) {
if (priv->saslDecoded == NULL) { if (priv->saslDecoded == NULL) {
char encoded[8192];
int ret, err; int ret, err;
ret = remoteIOReadBuffer(priv, encoded, sizeof(encoded)); ret = remoteIOReadBuffer(priv, priv->saslTemporary,
sizeof(priv->saslTemporary));
if (ret < 0) if (ret < 0)
return -1; return -1;
if (ret == 0) if (ret == 0)
return 0; return 0;
err = sasl_decode(priv->saslconn, encoded, ret, err = sasl_decode(priv->saslconn, priv->saslTemporary, ret,
&priv->saslDecoded, &priv->saslDecodedLength); &priv->saslDecoded, &priv->saslDecodedLength);
if (err != SASL_OK) { if (err != SASL_OK) {
remoteError(VIR_ERR_INTERNAL_ERROR, remoteError(VIR_ERR_INTERNAL_ERROR,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册