]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
sample-plugins: fix ASN1_STRING_to_UTF8 return value checks
authorDavid Sommerseth <davids@openvpn.net>
Mon, 14 Aug 2017 13:19:37 +0000 (15:19 +0200)
committerDavid Sommerseth <davids@openvpn.net>
Mon, 14 Aug 2017 16:06:50 +0000 (18:06 +0200)
As we did in 2d032c7f for the ASN1_STRING_to_UTF8() calls in the core code,
we should also free(buf) if the function returns 0.

[DS: On-the-fly merge conflict fix:
     There was a conflict against the OpenSSL 0.9.6b workaround in v2.4.
     Since we no longer support anything older than OpenSSL 0.9.8 in
     release/2.4, whack that workaround and be more consistent with git
     master those two places]

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <1501238302-16714-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15161.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit c43045ca0590364552fbd060cc65ee1c50a4866a)

sample/sample-plugins/keying-material-exporter-demo/keyingmaterialexporter.c
sample/sample-plugins/log/log_v3.c

index 226eea6ac8de6e295d5ab27090aa3e2a5934818c..c4839077b26195894cb759ae1ccd4b53cebd8e3f 100644 (file)
@@ -142,9 +142,8 @@ session_user_set(struct session *sess, X509 *x509)
         {
             continue;
         }
-        /* bug in OpenSSL 0.9.6b ASN1_STRING_to_UTF8 requires this workaround */
-        unsigned char *buf = (unsigned char *)1;
-        if (ASN1_STRING_to_UTF8(&buf, val) <= 0)
+        unsigned char *buf = NULL;
+        if (ASN1_STRING_to_UTF8(&buf, val) < 0)
         {
             continue;
         }
index 8b537dd72688e6a47225dc01f71de56595c51f55..f913a19a78351235e62b655465dfe6de7baa42bb 100644 (file)
@@ -227,8 +227,7 @@ x509_print_info(X509 *x509crt)
         {
             continue;
         }
-        buf = (unsigned char *)1; /* bug in OpenSSL 0.9.6b ASN1_STRING_to_UTF8 requires this workaround */
-        if (ASN1_STRING_to_UTF8(&buf, val) <= 0)
+        if (ASN1_STRING_to_UTF8(&buf, val) < 0)
         {
             continue;
         }