aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ragel/smtp_date.rl14
-rw-r--r--src/ragel/smtp_date_parser.rl13
2 files changed, 25 insertions, 2 deletions
diff --git a/src/ragel/smtp_date.rl b/src/ragel/smtp_date.rl
index df21cb3f3..125ae8a40 100644
--- a/src/ragel/smtp_date.rl
+++ b/src/ragel/smtp_date.rl
@@ -191,6 +191,18 @@
action TZ_PDT {
tz = -700;
}
+ prepush {
+ if (top >= st_storage.size) {
+ st_storage.size = (top + 1) * 2;
+ st_storage.data = realloc (st_storage.data, st_storage.size * sizeof (int));
+ g_assert (st_storage.data != NULL);
+ stack = st_storage.data;
+ }
+ }
+ ccontent = ctext | FWS | '(' @{ fcall balanced_ccontent; };
+ balanced_ccontent := ccontent* ')' @{ fret; };
+ comment = "(" (FWS? ccontent)* FWS? ")";
+ CFWS = ((FWS? comment)+ FWS?) | FWS;
digit_2 = digit{2};
digit_4 = digit{4};
day_name = "Mon" | "Tue" | "Wed" | "Thu" |
@@ -214,5 +226,5 @@
"PST" %TZ_PST | "PDT" %TZ_PDT |
[a-iA-I] | [k-zK-Z];
time = time_of_day %DT_End FWS (zone | obs_zone %Obs_Zone_End) FWS*;
- date_time = (day_of_week ",")? date time;
+ date_time = (day_of_week ",")? date time CFWS?;
}%%
diff --git a/src/ragel/smtp_date_parser.rl b/src/ragel/smtp_date_parser.rl
index d53e61148..8d99ea94d 100644
--- a/src/ragel/smtp_date_parser.rl
+++ b/src/ragel/smtp_date_parser.rl
@@ -19,13 +19,24 @@ rspamd_parse_smtp_date (const unsigned char *data, size_t len, GError **err)
const unsigned char *p = data, *pe = data + len, *eof = data + len, *tmp = data;
struct tm tm;
glong tz = 0;
- gint cs = 0;
+ gint cs = 0, *stack = NULL;;
+ gsize top = 0;
memset (&tm, 0, sizeof (tm));
+ struct _ragel_st_storage {
+ int *data;
+ gsize size;
+ } st_storage;
+ memset (&st_storage, 0, sizeof (st_storage));
+
%% write init;
%% write exec;
+ if (st_storage.data) {
+ free (st_storage.data);
+ }
+
if ( cs < %%{ write first_final; }%% ) {
g_set_error (err, g_quark_from_static_string ("smtp_date"), cs, "invalid date at offset %d (%c), state %d",
(int)(p - data), (*p > 0 && *p < 128) ? *p : '?', cs);