OpenSSL 1.1.1-pre2

This commit is contained in:
Hakase
2018-04-07 17:29:40 +09:00
parent 82a44d2483
commit bbac8ca55d
17755 changed files with 221242 additions and 98415 deletions
+31 -27
View File
@@ -26,7 +26,11 @@ static int mem_buf_sync(BIO *h);
static const BIO_METHOD mem_method = {
BIO_TYPE_MEM,
"memory buffer",
/* TODO: Convert to new style write function */
bwrite_conv,
mem_write,
/* TODO: Convert to new style read function */
bread_conv,
mem_read,
mem_puts,
mem_gets,
@@ -39,7 +43,11 @@ static const BIO_METHOD mem_method = {
static const BIO_METHOD secmem_method = {
BIO_TYPE_MEM,
"secure memory buffer",
/* TODO: Convert to new style write function */
bwrite_conv,
mem_write,
/* TODO: Convert to new style read function */
bread_conv,
mem_read,
mem_puts,
mem_gets,
@@ -62,7 +70,7 @@ typedef struct bio_buf_mem_st {
const BIO_METHOD *BIO_s_mem(void)
{
return (&mem_method);
return &mem_method;
}
const BIO_METHOD *BIO_s_secmem(void)
@@ -122,42 +130,38 @@ static int mem_init(BIO *bi, unsigned long flags)
static int mem_new(BIO *bi)
{
return (mem_init(bi, 0L));
return mem_init(bi, 0L);
}
static int secmem_new(BIO *bi)
{
return (mem_init(bi, BUF_MEM_FLAG_SECURE));
return mem_init(bi, BUF_MEM_FLAG_SECURE);
}
static int mem_free(BIO *a)
{
return (mem_buf_free(a, 1));
return mem_buf_free(a, 1);
}
static int mem_buf_free(BIO *a, int free_all)
{
if (a == NULL)
return (0);
if (a->shutdown) {
if ((a->init) && (a->ptr != NULL)) {
BUF_MEM *b;
BIO_BUF_MEM *bb = (BIO_BUF_MEM *)a->ptr;
return 0;
if (bb != NULL) {
b = bb->buf;
if (a->flags & BIO_FLAGS_MEM_RDONLY)
b->data = NULL;
BUF_MEM_free(b);
if (free_all) {
OPENSSL_free(bb->readp);
OPENSSL_free(bb);
}
}
a->ptr = NULL;
if (a->shutdown && a->init && a->ptr != NULL) {
BIO_BUF_MEM *bb = (BIO_BUF_MEM *)a->ptr;
BUF_MEM *b = bb->buf;
if (a->flags & BIO_FLAGS_MEM_RDONLY)
b->data = NULL;
BUF_MEM_free(b);
if (free_all) {
OPENSSL_free(bb->readp);
OPENSSL_free(bb);
}
a->ptr = NULL;
}
return (1);
return 1;
}
/*
@@ -174,7 +178,7 @@ static int mem_buf_sync(BIO *b)
bbm->readp->data = bbm->buf->data;
}
}
return (0);
return 0;
}
static int mem_read(BIO *b, char *out, int outl)
@@ -194,7 +198,7 @@ static int mem_read(BIO *b, char *out, int outl)
if (ret != 0)
BIO_set_retry_read(b);
}
return (ret);
return ret;
}
static int mem_write(BIO *b, const char *in, int inl)
@@ -220,7 +224,7 @@ static int mem_write(BIO *b, const char *in, int inl)
*bbm->readp = *bbm->buf;
ret = inl;
end:
return (ret);
return ret;
}
static long mem_ctrl(BIO *b, int cmd, long num, void *ptr)
@@ -297,7 +301,7 @@ static long mem_ctrl(BIO *b, int cmd, long num, void *ptr)
ret = 0;
break;
}
return (ret);
return ret;
}
static int mem_gets(BIO *bp, char *buf, int size)
@@ -333,7 +337,7 @@ static int mem_gets(BIO *bp, char *buf, int size)
if (i > 0)
buf[i] = '\0';
ret = i;
return (ret);
return ret;
}
static int mem_puts(BIO *bp, const char *str)
@@ -343,5 +347,5 @@ static int mem_puts(BIO *bp, const char *str)
n = strlen(str);
ret = mem_write(bp, str, n);
/* memory semantics is that it will always work */
return (ret);
return ret;
}