From: Arne Schwabe Date: Tue, 5 Jan 2016 14:56:01 +0000 (+0100) Subject: Fix assert when comp is called with unknown algorithm, always call comp init method X-Git-Tag: v2.4_alpha1~163 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=67b3de98e3b5327a9330b499d6cff179624b8ec2;p=thirdparty%2Fopenvpn.git Fix assert when comp is called with unknown algorithm, always call comp init method Acked-by: Gert Doering Message-Id: <1452005761-5503-1-git-send-email-arne@rfc2549.org> URL: http://article.gmane.org/gmane.network.openvpn.devel/10939 Signed-off-by: Gert Doering --- diff --git a/src/openvpn/comp.c b/src/openvpn/comp.c index b420ea530..3a32c6281 100644 --- a/src/openvpn/comp.c +++ b/src/openvpn/comp.c @@ -48,7 +48,6 @@ comp_init(const struct compress_options *opt) ALLOC_OBJ_CLEAR (compctx, struct compress_context); compctx->flags = opt->flags; compctx->alg = comp_stub_alg; - (*compctx->alg.compress_init)(compctx); break; case COMP_ALGV2_UNCOMPRESSED: ALLOC_OBJ_CLEAR (compctx, struct compress_context); @@ -60,7 +59,6 @@ comp_init(const struct compress_options *opt) ALLOC_OBJ_CLEAR (compctx, struct compress_context); compctx->flags = opt->flags; compctx->alg = lzo_alg; - (*compctx->alg.compress_init)(compctx); break; #endif #ifdef ENABLE_LZ4 @@ -68,7 +66,6 @@ comp_init(const struct compress_options *opt) ALLOC_OBJ_CLEAR (compctx, struct compress_context); compctx->flags = opt->flags; compctx->alg = lz4_alg; - (*compctx->alg.compress_init)(compctx); break; case COMP_ALGV2_LZ4: ALLOC_OBJ_CLEAR (compctx, struct compress_context); @@ -77,6 +74,9 @@ comp_init(const struct compress_options *opt) break; #endif } + if (compctx) + (*compctx->alg.compress_init)(compctx); + return compctx; } diff --git a/src/openvpn/options.c b/src/openvpn/options.c index f154c62ad..b710c9cdb 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -6344,7 +6344,6 @@ add_option (struct options *options, VERIFY_PERMISSION (OPT_P_COMP); if (p[1]) { - options->comp.flags = 0; if (streq (p[1], "stub")) { options->comp.alg = COMP_ALG_STUB; @@ -6359,6 +6358,7 @@ add_option (struct options *options, else if (streq (p[1], "lzo")) { options->comp.alg = COMP_ALG_LZO; + options->comp.flags = 0; } #endif #if defined(ENABLE_LZ4) @@ -6370,6 +6370,7 @@ add_option (struct options *options, else if (streq (p[1], "lz4-v2")) { options->comp.alg = COMP_ALGV2_LZ4; + options->comp.flags = 0; } #endif else