]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-var-expand: Fix potential crash if referring to too large regexp capture group
authorAki Tuomi <aki.tuomi@open-xchange.com>
Thu, 13 Feb 2025 07:36:02 +0000 (09:36 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Thu, 13 Feb 2025 13:02:43 +0000 (15:02 +0200)
Using sizeof() will not give number of elements here.

src/lib-var-expand/expansion-filter.c

index 8a42a6505f8f8e5b9726d21e615012d58a8073dd..b0ba1ef98a35865d4712dc7ff4f7fa85d0a5b0ee 100644 (file)
@@ -831,7 +831,7 @@ static int fn_regexp(const struct var_expand_statement *stmt,
                        /* looks like a placeholder */
                        str_append_data(dest, p0, p1 - p0);
                        unsigned int g = p1[1] - '0';
-                       if (g >= sizeof(matches) ||
+                       if (g >= N_ELEMENTS(matches) ||
                            matches[g].rm_so == -1) {
                                *error_r = "Invalid capture group";
                                ret = -1;