]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
add support for %lu in argv_printf and prevent ASSERT
authorAntonio Quartulli <a@unstable.cc>
Sat, 23 Jun 2018 02:11:47 +0000 (10:11 +0800)
committerGert Doering <gert@greenie.muc.de>
Sat, 23 Jun 2018 12:00:34 +0000 (14:00 +0200)
%lu is not supported by our tiny argv_printf implementation, therefore
it will trigger an ASSERT() when parsing it at route.c:1638.

Add support for '%lu' in argv_print() and prevent the ASSERT from being
triggered.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20180623021147.22792-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17115.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit e38d3a004195f33c5c04fe7c04db5d66c53241bc)

src/openvpn/argv.c

index 124e1c434f5066f46fee33c13ab468690878b1df..7d06951b15fa33807401d700545cc05410d80374 100644 (file)
@@ -250,6 +250,13 @@ argv_printf_arglist(struct argv *a, const char *format, va_list arglist)
                 openvpn_snprintf(numstr, sizeof(numstr), "%u", va_arg(arglist, unsigned int));
                 argv_append(a, string_alloc(numstr, NULL));
             }
+            else if (!strcmp(term, "%lu"))
+            {
+                char numstr[64];
+                openvpn_snprintf(numstr, sizeof(numstr), "%lu",
+                                 va_arg(arglist, unsigned long));
+                argv_append(a, string_alloc(numstr, NULL));
+            }
             else if (!strcmp(term, "%s/%d"))
             {
                 char numstr[64];