]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
vici: Correctly parse inactivity timeout as uint32_t
authorTobias Brunner <tobias@strongswan.org>
Wed, 6 Mar 2019 17:39:28 +0000 (18:39 +0100)
committerTobias Brunner <tobias@strongswan.org>
Fri, 8 Mar 2019 14:47:25 +0000 (15:47 +0100)
Using parse_time() directly actually overwrites the next member in the
child_cfg_create_t struct, which is start_action, which can cause
incorrect configs if inactivity is parsed after start_action.

Fixes #2954.

src/libcharon/plugins/vici/vici_config.c

index 8579819d877b6c73d10a11df1c75b16a5db1643f..f1ddde1b4e45de0e7b14947a35894abe380a805b 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 2014 Martin Willi
  * Copyright (C) 2014 revosec AG
  *
- * Copyright (C) 2015-2018 Tobias Brunner
+ * Copyright (C) 2015-2019 Tobias Brunner
  * Copyright (C) 2015-2018 Andreas Steffen
  * HSR Hochschule fuer Technik Rapperswil
  *
@@ -1127,6 +1127,22 @@ CALLBACK(parse_time, bool,
        return TRUE;
 }
 
+/**
+ * Parse a relative time (32-bit)
+ */
+CALLBACK(parse_time32, bool,
+       uint32_t *out, chunk_t v)
+{
+       uint64_t time;
+
+       if (parse_time(&time, v))
+       {
+               *out = time;
+               return TRUE;
+       }
+       return FALSE;
+}
+
 /**
  * Parse byte volume
  */
@@ -1657,7 +1673,7 @@ CALLBACK(child_kv, bool,
                { "start_action",               parse_action,           &child->cfg.start_action                        },
                { "close_action",               parse_action,           &child->cfg.close_action                        },
                { "ipcomp",                             parse_opt_ipcomp,       &child->cfg.options                                     },
-               { "inactivity",                 parse_time,                     &child->cfg.inactivity                          },
+               { "inactivity",                 parse_time32,           &child->cfg.inactivity                          },
                { "reqid",                              parse_uint32,           &child->cfg.reqid                                       },
                { "mark_in",                    parse_mark,                     &child->cfg.mark_in                                     },
                { "mark_in_sa",                 parse_opt_mark_in,      &child->cfg.options                                     },