Преглед на файлове

[Minor] Deny zero length in regexp search functions

pull/4887/head
Vsevolod Stakhov преди 2 месеца
родител
ревизия
05636d9af8
No account linked to committer's email address
променени са 1 файла, в които са добавени 5 реда и са изтрити 11 реда
  1. 5
    11
      src/libutil/regexp.c

+ 5
- 11
src/libutil/regexp.c Целия файл

/* /*
* Copyright 2023 Vsevolod Stakhov
* Copyright 2024 Vsevolod Stakhov
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
g_assert(text != NULL); g_assert(text != NULL);


if (len == 0) { if (len == 0) {
len = strlen(text);
/* No length, no match! */
return FALSE;
} }


if (re->match_limit > 0 && len > re->match_limit) { if (re->match_limit > 0 && len > re->match_limit) {
g_assert(text != NULL); g_assert(text != NULL);


if (len == 0) { if (len == 0) {
len = strlen(text);
/* No length, no match! */
return FALSE;
} }


if (re->match_limit > 0 && len > re->match_limit) { if (re->match_limit > 0 && len > re->match_limit) {
g_assert(re != NULL); g_assert(re != NULL);
g_assert(text != NULL); g_assert(text != NULL);


if (len == 0) {
len = strlen(text);
}

if (rspamd_regexp_search(re, text, len, &start, &end, raw, NULL)) { if (rspamd_regexp_search(re, text, len, &start, &end, raw, NULL)) {
if (start == text && end == text + len) { if (start == text && end == text + len) {
return TRUE; return TRUE;


g_assert(gl != NULL); g_assert(gl != NULL);


if (sz == 0) {
sz = strlen(gl);
}

end = gl + sz; end = gl + sz;
out = g_string_sized_new(sz + 2); out = g_string_sized_new(sz + 2);
g_string_append_c(out, '^'); g_string_append_c(out, '^');

Loading…
Отказ
Запис