Browse code

Fix assert when comp is called with unknown algorithm, always call comp init method

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>

Arne Schwabe authored on 2016/01/05 23:56:01
Showing 2 changed files
... ...
@@ -48,7 +48,6 @@ comp_init(const struct compress_options *opt)
48 48
       ALLOC_OBJ_CLEAR (compctx, struct compress_context);
49 49
       compctx->flags = opt->flags;
50 50
       compctx->alg = comp_stub_alg;
51
-      (*compctx->alg.compress_init)(compctx);
52 51
       break;
53 52
     case COMP_ALGV2_UNCOMPRESSED:
54 53
       ALLOC_OBJ_CLEAR (compctx, struct compress_context);
... ...
@@ -60,7 +59,6 @@ comp_init(const struct compress_options *opt)
60 60
       ALLOC_OBJ_CLEAR (compctx, struct compress_context);
61 61
       compctx->flags = opt->flags;
62 62
       compctx->alg = lzo_alg;
63
-      (*compctx->alg.compress_init)(compctx);
64 63
       break;
65 64
 #endif
66 65
 #ifdef ENABLE_LZ4
... ...
@@ -68,7 +66,6 @@ comp_init(const struct compress_options *opt)
68 68
       ALLOC_OBJ_CLEAR (compctx, struct compress_context);
69 69
       compctx->flags = opt->flags;
70 70
       compctx->alg = lz4_alg;
71
-      (*compctx->alg.compress_init)(compctx);
72 71
       break;
73 72
     case COMP_ALGV2_LZ4:
74 73
       ALLOC_OBJ_CLEAR (compctx, struct compress_context);
... ...
@@ -77,6 +74,9 @@ comp_init(const struct compress_options *opt)
77 77
       break;
78 78
 #endif
79 79
     }
80
+  if (compctx)
81
+    (*compctx->alg.compress_init)(compctx);
82
+
80 83
   return compctx;
81 84
 }
82 85
 
... ...
@@ -6344,7 +6344,6 @@ add_option (struct options *options,
6344 6344
       VERIFY_PERMISSION (OPT_P_COMP);
6345 6345
       if (p[1])
6346 6346
 	{
6347
-	  options->comp.flags = 0;
6348 6347
 	  if (streq (p[1], "stub"))
6349 6348
 	    {
6350 6349
 	      options->comp.alg = COMP_ALG_STUB;
... ...
@@ -6359,6 +6358,7 @@ add_option (struct options *options,
6359 6359
 	  else if (streq (p[1], "lzo"))
6360 6360
 	    {
6361 6361
 	      options->comp.alg = COMP_ALG_LZO;
6362
+	      options->comp.flags = 0;
6362 6363
 	    }
6363 6364
 #endif
6364 6365
 #if defined(ENABLE_LZ4)
... ...
@@ -6370,6 +6370,7 @@ add_option (struct options *options,
6370 6370
 	  else if (streq (p[1], "lz4-v2"))
6371 6371
 	    {
6372 6372
 	      options->comp.alg = COMP_ALGV2_LZ4;
6373
+	      options->comp.flags = 0;
6373 6374
 	    }
6374 6375
 #endif
6375 6376
 	  else