Hi,

On Fri, Jun 22, 2018 at 6:21 AM, Antonio Quartulli <a...@unstable.cc> wrote:
> %lu is not supported by our tiny argv_printf implementation and will
> trigger an ASSERT() when parsing it. Even though this particular
> ASSERT() is not critical as it happens during shutdown, we still have to
> fix it.
>
> Since in this case the code is trying to use a DWORD variable as
> argument, and we know that DWORD is an unsigned long, which in turn is
> 32bit long on MS Windows (32 and 64bit version)[1][2], simply use
> the already supported %u instead of %lu.
>
> [1]https://msdn.microsoft.com/en-us/library/aa383751(VS.85).aspx
> [2]https://en.wikipedia.org/wiki/Integer_(computer_science)#Long_integer
>
> Signed-off-by: Antonio Quartulli <a...@unstable.cc>
> ---
>  src/openvpn/route.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/openvpn/route.c b/src/openvpn/route.c
> index a45a273a..209daeab 100644
> --- a/src/openvpn/route.c
> +++ b/src/openvpn/route.c
> @@ -1616,7 +1616,7 @@ add_route(struct route_ipv4 *r, const struct tuntap
*tt, unsigned int flags,
>          if (is_on_link(is_local_route, flags, rgi))
>          {
>              ai = rgi->adapter_index;
> -            argv_printf_cat(&argv, "IF %lu", ai);
> +            argv_printf_cat(&argv, "IF %u", ai);
>          }
>
>          argv_msg(D_ROUTE, &argv);

Thanks for cleaning up my mistake (commit
06ad53e067d9a8be571a27f44005fa7e8038f69e introduced this). One
purpose of that commit was to get rid of -Wformat warnings as those
are not always benign. But this will re-introduce a warning as "ai" is
unsigned long even though its the same size as unsigned.

Currently we do support building with -Werror=format (see
https://patchwork.openvpn.net/patch/234/#463), so I suggest either
cast to (unsigned)  which we know is safe here, or add "%lu" to
argv_printf_arglist().

I would prefer the latter as its easy to overlook the fact that
argv_printf_cat() can't handle %lu which is commonly used
on Windows.

Selva
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to