]> source.dussan.org Git - rspamd.git/commitdiff
Fix GString expanding.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 29 Jan 2014 18:16:08 +0000 (18:16 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 29 Jan 2014 18:16:08 +0000 (18:16 +0000)
src/client/rspamdclient.c
src/util.c

index e8f7dfe87789c0f13584bfedc2c5e804b3d74c1b..293c49214e208fd426f40c68313bc62ce5fd2a82 100644 (file)
@@ -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) {
index 3bf98a5362858f3648a85d11acaf206252325c82..2afda3546bfe115f3a97b89ebc7b6cfe279bf744 100644 (file)
@@ -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;