Browse code

sample-plugins: fix ASN1_STRING_to_UTF8 return value checks

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.

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>

Steffan Karger authored on 2017/07/28 19:38:22
Showing 2 changed files
... ...
@@ -143,7 +143,7 @@ session_user_set(struct session *sess, X509 *x509)
143 143
             continue;
144 144
         }
145 145
         unsigned char *buf = NULL;
146
-        if (ASN1_STRING_to_UTF8(&buf, val) <= 0)
146
+        if (ASN1_STRING_to_UTF8(&buf, val) < 0)
147 147
         {
148 148
             continue;
149 149
         }
... ...
@@ -227,7 +227,7 @@ x509_print_info(X509 *x509crt)
227 227
         {
228 228
             continue;
229 229
         }
230
-        if (ASN1_STRING_to_UTF8(&buf, val) <= 0)
230
+        if (ASN1_STRING_to_UTF8(&buf, val) < 0)
231 231
         {
232 232
             continue;
233 233
         }