Skip to contentSkip to conversation

Crash in options.c

Openvpn-devel Gisle Vanem 2 participants 4 messages Jan 2, 2017 – Jan 4, 2017

lore
Share & tools
lore
#0 lore raw

Just as an experiment, I compiled openvpn.exe using MinGW w/o 'ENABLE_CRYPTO' defined. Duh, you think. What would be the benefit of that? I ask myself the same. This code (at line 4079):

#else  /* ifdef ENABLE_CRYPTO */
    fprintf(fp, usage_message,
            title_string,
            o.ce.connect_retry_seconds,
            o.ce.local_port, o.ce.remote_port,
            TUN_MTU_DEFAULT, TAP_MTU_EXTRA_DEFAULT,
            o.verbosity);

#endif

uses a 'title_string[]' as format with no parameters specified and thus crashes as expected. So is all code outside '!defined(ENABLE_CRYPTO)' really dead code or what?

Signature · 1 line
--gv
#1 lore raw

Hi,

Quoted 11 lines · Gisle Vanem

Just as an experiment, I compiled openvpn.exe using MinGW w/o 'ENABLE_CRYPTO' defined. Duh, you think. What would be the benefit of that? I ask myself the same. This code (at line 4079):

#else  /* ifdef ENABLE_CRYPTO */
    fprintf(fp, usage_message,
            title_string,
            o.ce.connect_retry_seconds,
            o.ce.local_port, o.ce.remote_port,
            TUN_MTU_DEFAULT, TAP_MTU_EXTRA_DEFAULT,
            o.verbosity);
Quoted 5 lines

#endif

uses a 'title_string[]' as format with no parameters specified and thus crashes as expected. So is all code outside '!defined(ENABLE_CRYPTO)' really dead code or what?

Actually, "usage_message" is the format string here...

There might still be bugs here, though - as in: someone adapted the "#ifdef ENABLE_CRYPTO" part of the usage_message and forgot to change
arguments in the the #else case. While we do test builds with
--disable-crypto, I'm not sure anyone has run "openvpn --help" with such a build in the last 5 years...

gert

Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             [email protected]...
fax: +49-89-35655025                        [email protected]...
#2 lore raw
Quoted 5 lines · Gert Doering
Quoted 3 lines

uses a 'title_string[]' as format with no parameters specified and thus crashes as expected. So is all code outside '!defined(ENABLE_CRYPTO)' really dead code or what?

Actually, "usage_message" is the format string here...

Ah, my bad. Then it's a simple fix:

options.c 2017-01-02 17:15:10 renamed from options.c 2017-01-02 09:58:38 +1 -0
@@ -4080,6 +4080,7 @@
     fprintf(fp, usage_message,
             title_string,
             o.ce.connect_retry_seconds,
+            o.ce.connect_retry_seconds_max,
             o.ce.local_port, o.ce.remote_port,
             TUN_MTU_DEFAULT, TAP_MTU_EXTRA_DEFAULT,
             o.verbosity);
Quoted 5 lines

There might still be bugs here, though - as in: someone adapted the "#ifdef ENABLE_CRYPTO" part of the usage_message and forgot to change
arguments in the the #else case. While we do test builds with
--disable-crypto, I'm not sure anyone has run "openvpn --help" with such a build in the last 5 years...

Signature · 1 line
--gv
#3 lore raw

ACK, thanks. Tested, fixes the issue, tracked to the offending commit (5d429efd97).

Your patch has been applied to the master and release/2.4 branch.

Release/2.3 does not contain the offending code.

commit 49629380a7bdba25c24c9d410b79946fe29249f0 (master) commit 6650911256b2e636b4a2d754cfe60e949f213f91 (release/2.4)

Author: Gisle Vanem
Date:   Mon Jan 2 17:17:51 2017 +0100
     Crash in options.c

     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg13808.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering