diff options
-rw-r--r-- | src/client/rspamdclient.c | 7 | ||||
-rw-r--r-- | src/util.c | 4 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/client/rspamdclient.c b/src/client/rspamdclient.c index e8f7dfe87..293c49214 100644 --- a/src/client/rspamdclient.c +++ b/src/client/rspamdclient.c @@ -151,7 +151,7 @@ rspamd_client_command (struct rspamd_client_connection *conn, { struct rspamd_client_request *req; gchar *p, *hn, *hv; - gsize remain; + gsize remain, old_len; GHashTableIter it; req = g_slice_alloc (sizeof (struct rspamd_client_request)); @@ -167,7 +167,10 @@ rspamd_client_command (struct rspamd_client_connection *conn, p = req->msg->body->str + req->msg->body->len; remain = req->msg->body->allocated_len - req->msg->body->len - 1; if (remain == 0) { - g_string_set_size (req->msg->body, req->msg->body->len * 2); + old_len = req->msg->body->len; + g_string_set_size (req->msg->body, old_len * 2); + req->msg->body->len = old_len; + continue; } remain = fread (p, 1, remain, in); if (remain > 0) { diff --git a/src/util.c b/src/util.c index 3bf98a536..2afda3546 100644 --- a/src/util.c +++ b/src/util.c @@ -2184,17 +2184,19 @@ static int rspamd_gstring_append_character (unsigned char c, size_t len, void *ud) { GString *buf = ud; + gsize old_len; if (len == 1) { g_string_append_c (buf, c); } else { if (buf->allocated_len - buf->len <= len) { + old_len = buf->len; g_string_set_size (buf, buf->len + len + 1); + buf->len = old_len; } memset (&buf->str[buf->len], c, len); buf->len += len; - buf->str[buf->len] = '\0'; } return 0; |