Skip to content

Commit b29cb77

Browse files
committed
Build fixes against OpenSSL >= 1.0.2
1 parent 143c771 commit b29cb77

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/util_uri.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#include "util.h"
3030
#include <stdio.h>
31+
#include <string.h>
3132

3233
#if defined(_WIN32) || defined(_WIN64)
3334
#define strncasecmp _strnicmp
@@ -77,7 +78,12 @@ struct util_ctx_st {
7778

7879
UTIL_CTX *UTIL_CTX_new()
7980
{
80-
return OPENSSL_zalloc(sizeof(UTIL_CTX));
81+
UTIL_CTX *ctx;
82+
83+
ctx = OPENSSL_malloc(sizeof(UTIL_CTX));
84+
if (ctx)
85+
memset(ctx, 0, sizeof(UTIL_CTX));
86+
return ctx;
8187
}
8288

8389
void UTIL_CTX_free(UTIL_CTX *ctx)
@@ -237,6 +243,24 @@ static char *dump_hex(unsigned char *val, const size_t len)
237243
return hexbuf;
238244
}
239245

246+
#if OPENSSL_VERSION_NUMBER < 0x10100000L
247+
static char *OPENSSL_strndup(const char *str, size_t s)
248+
{
249+
size_t len;
250+
char *ret;
251+
252+
if (!str || !s)
253+
return NULL;
254+
len = strnlen(str, s);
255+
ret = OPENSSL_malloc(len + 1);
256+
if (ret) {
257+
memcpy(ret, str, len);
258+
ret[len] = '\0';
259+
}
260+
return ret;
261+
}
262+
#endif
263+
240264
static char *dump_expiry(const PKCS11_CERT *cert)
241265
{
242266
BIO *bio;

0 commit comments

Comments
 (0)