]> source.dussan.org Git - rspamd.git/commitdiff
Fix leaks and errors in rcl_parser.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 14 Oct 2013 11:26:41 +0000 (12:26 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 14 Oct 2013 11:26:41 +0000 (12:26 +0100)
src/rcl/rcl_parser.c
src/rcl/rcl_util.c

index e4a9024c77d0571e323bd8f710c6511478c156f9..d00b2d3ebeb1f6a702f53135d5bd91aea5cb1be8 100644 (file)
@@ -554,6 +554,12 @@ rspamd_cl_parse_key (struct rspamd_cl_parser *parser,
                                rspamd_cl_chunk_skipc (chunk, *p);
                                p ++;
                        }
+                       else if (rspamd_cl_lex_is_comment (p[0], p[1])) {
+                               if (!rspamd_cl_skip_comments (parser, err)) {
+                                       return FALSE;
+                               }
+                               p = chunk->pos;
+                       }
                        else {
                                /* Invalid identifier */
                                rspamd_cl_set_err (chunk, RSPAMD_CL_ESYNTAX, "key must begin with a letter", err);
@@ -661,8 +667,8 @@ rspamd_cl_parse_key (struct rspamd_cl_parser *parser,
        HASH_FIND_STR (container, nobj->key, tobj);
        if (tobj != NULL) {
                /* Just insert a new object as the next element */
-               LL_PREPEND (tobj, nobj);
                HASH_DELETE (hh, container, tobj);
+               LL_PREPEND (tobj, nobj);
        }
 
        HASH_ADD_KEYPTR (hh, container, nobj->key, strlen (nobj->key), nobj);
@@ -843,9 +849,9 @@ rspamd_cl_parse_value (struct rspamd_cl_parser *parser, struct rspamd_cl_chunk *
                        break;
                default:
                        /* Skip any spaces and comments */
-                       if (rcl_test_character (*p, RCL_CHARACTER_WHITESPACE) ||
+                       if (rcl_test_character (*p, RCL_CHARACTER_WHITESPACE_UNSAFE) ||
                                        rspamd_cl_lex_is_comment (p[0], p[1])) {
-                               while (p < chunk->end && rcl_test_character (*p, RCL_CHARACTER_WHITESPACE)) {
+                               while (p < chunk->end && rcl_test_character (*p, RCL_CHARACTER_WHITESPACE_UNSAFE)) {
                                        rspamd_cl_chunk_skipc (chunk, *p);
                                        p ++;
                                }
index 8a42e40a447d33134f57dfc030dfadce4ce26f65..a2cb444ea2e27563c7c7a616333c9d2c1bd26b98 100644 (file)
@@ -197,6 +197,8 @@ rspamd_cl_parser_free (struct rspamd_cl_parser *parser)
                g_slice_free1 (sizeof (struct rspamd_cl_stack), stack);
        }
        HASH_ITER (hh, parser->macroes, macro, mtmp) {
+               g_free (macro->name);
+               HASH_DEL (parser->macroes, macro);
                g_slice_free1 (sizeof (struct rspamd_cl_macro), macro);
        }
        LL_FOREACH_SAFE (parser->chunks, chunk, ctmp) {