]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Fix assert when comp is called with unknown algorithm, always call comp init method
authorArne Schwabe <arne@rfc2549.org>
Tue, 5 Jan 2016 14:56:01 +0000 (15:56 +0100)
committerGert Doering <gert@greenie.muc.de>
Tue, 5 Jan 2016 16:51:54 +0000 (17:51 +0100)
Acked-by: Gert Doering <gert@greenie.muc.de>
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 <gert@greenie.muc.de>
src/openvpn/comp.c
src/openvpn/options.c

index b420ea530dac0a7cec6e92732baebafc8d7c66c2..3a32c62814df497591f9be9d734f09193ba248be 100644 (file)
@@ -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;
 }
 
index f154c62ad095d300c31300f350dd4cb73103b4fd..b710c9cdbdaa8e1a1c9f63a15dc8c62c02caca13 100644 (file)
@@ -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