settings: Allow spaces in time settings before the optional unit
authorMartin Willi <martin@revosec.ch>
Mon, 7 Jul 2014 13:53:49 +0000 (15:53 +0200)
committerMartin Willi <martin@revosec.ch>
Mon, 7 Jul 2014 14:58:05 +0000 (16:58 +0200)
src/libstrongswan/settings/settings.c
src/libstrongswan/tests/suites/test_settings.c

index 4fa283a..e235e3c 100644 (file)
@@ -23,6 +23,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
+#include <ctype.h>
 
 #include "settings.h"
 #include "settings_types.h"
@@ -584,6 +585,10 @@ inline u_int32_t settings_value_as_time(char *value, u_int32_t def)
                }
                if (errno == 0)
                {
+                       while (isspace(*endptr))
+                       {
+                               endptr++;
+                       }
                        switch (*endptr)
                        {
                                case 'd':               /* time in days */
index 3348d33..b9d429a 100644 (file)
@@ -373,8 +373,8 @@ START_SETUP(setup_time_config)
                "       key0 = 5\n"
                "       key1 = 5s\n"
                "       key2 = 5m\n"
-               "       key3 = 5h\n"
-               "       key4 = 5d\n"
+               "       key3 = 5 h\n"
+               "       key4 = 5\td\n"
                "       empty = \"\"\n"
                "       none = \n"
                "       foo1 = bar\n"