summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2019-09-26 14:55:00 +0100
committerMatt Caswell <matt@openssl.org>2019-10-03 09:47:34 +0100
commit14bec2c4b4a74f7de3bdf4b3fff764d8842c27ab (patch)
tree12b850f4f0ceaa39d456eab22399a491254c6ce7
parent15de965ff04ccecb068f3ce6c643555dce9372c6 (diff)
Free a fetched digest during EVP_MD_CTX_reset() not EVP_MD_free()
Otherwise a mem leak can occur since EVP_MD_free() calls EVP_MD_CTX_reset() which then clears the contents of the ctx. Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/10013)
-rw-r--r--crypto/evp/digest.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/crypto/evp/digest.c b/crypto/evp/digest.c
index 6609e8f541..874b16b6ee 100644
--- a/crypto/evp/digest.c
+++ b/crypto/evp/digest.c
@@ -34,8 +34,9 @@ int EVP_MD_CTX_reset(EVP_MD_CTX *ctx)
EVP_PKEY_CTX_free(ctx->pctx);
#endif
- if (ctx->digest == NULL || ctx->digest->prov == NULL)
- goto legacy;
+ EVP_MD_free(ctx->fetched_digest);
+ ctx->fetched_digest = NULL;
+ ctx->reqdigest = NULL;
if (ctx->provctx != NULL) {
if (ctx->digest->freectx != NULL)
@@ -44,13 +45,7 @@ int EVP_MD_CTX_reset(EVP_MD_CTX *ctx)
EVP_MD_CTX_set_flags(ctx, EVP_MD_CTX_FLAG_CLEANED);
}
- if (ctx->pctx != NULL)
- goto legacy;
-
- return 1;
-
/* TODO(3.0): Remove legacy code below */
- legacy:
/*
* Don't assume ctx->md_data was cleaned in EVP_Digest_Final, because
@@ -67,6 +62,9 @@ int EVP_MD_CTX_reset(EVP_MD_CTX *ctx)
#if !defined(FIPS_MODE) && !defined(OPENSSL_NO_ENGINE)
ENGINE_finish(ctx->engine);
#endif
+
+ /* TODO(3.0): End of legacy code */
+
OPENSSL_cleanse(ctx, sizeof(*ctx));
return 1;
@@ -84,11 +82,6 @@ void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
EVP_MD_CTX_reset(ctx);
- EVP_MD_free(ctx->fetched_digest);
- ctx->fetched_digest = NULL;
- ctx->digest = NULL;
- ctx->reqdigest = NULL;
-
OPENSSL_free(ctx);
return;
}
lor: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
{ stdenv, fetchFromGitHub, qt4, qmake4Hook, libpulseaudio }:
let
  version = "1.1.8";
in
stdenv.mkDerivation {
  pname = "multimon-ng";
  inherit version;

  src = fetchFromGitHub {
    owner = "EliasOenal";
    repo = "multimon-ng";
    rev = version;
    sha256 = "1973xfyvzl1viz19zr83cgqlx5laxbjrca35rqabn6dlb6xb5xk8";
  };

  buildInputs = [ qt4 libpulseaudio ];

  nativeBuildInputs = [ qmake4Hook ];

  qmakeFlags = [ "multimon-ng.pro" ];

  installPhase = ''
    mkdir -p $out/bin
    cp multimon-ng $out/bin
  '';

  meta = with stdenv.lib; {
    description = "Multimon is a digital baseband audio protocol decoder";
    longDescription = ''
      multimon-ng a fork of multimon, a digital baseband audio
      protocol decoder for common signaling modes in commercial and
      amateur radio data services. It decodes the following digital
      transmission modes:

      POCSAG512 POCSAG1200 POCSAG2400 EAS UFSK1200 CLIPFSK AFSK1200
      AFSK2400 AFSK2400_2 AFSK2400_3 HAPN4800 FSK9600 DTMF ZVEI1 ZVEI2
      ZVEI3 DZVEI PZVEI EEA EIA CCIR MORSE CW
    '';
    homepage = https://github.com/EliasOenal/multimon-ng;
    license = licenses.gpl2;
    platforms = platforms.linux;
    maintainers = with maintainers; [ the-kenny ];
  };
}