int i;
if (strncmp(arg, "pass:", 5) == 0)
- return BUF_strdup(arg + 5);
+ return OPENSSL_strdup(arg + 5);
if (strncmp(arg, "env:", 4) == 0) {
tmp = getenv(arg + 4);
if (!tmp) {
BIO_printf(bio_err, "Can't read environment variable %s\n", arg + 4);
return NULL;
}
- return BUF_strdup(tmp);
+ return OPENSSL_strdup(tmp);
}
if (!keepbio || !pwdbio) {
if (strncmp(arg, "file:", 5) == 0) {
tmp = strchr(tpass, '\n');
if (tmp)
*tmp = 0;
- return BUF_strdup(tpass);
+ return OPENSSL_strdup(tpass);
}
static CONF *app_load_config_(BIO *in, const char *filename)
}
if (suffix == NULL)
- BUF_strlcpy(buf[0], serialfile, BSIZE);
+ OPENSSL_strlcpy(buf[0], serialfile, BSIZE);
else {
#ifndef OPENSSL_SYS_VMS
j = BIO_snprintf(buf[0], sizeof buf[0], "%s.%s", serialfile, suffix);
{
int rv;
char *stmp, *vtmp = NULL;
- stmp = BUF_strdup(value);
+ stmp = OPENSSL_strdup(value);
if (!stmp)
return -1;
vtmp = strchr(stmp, ':');
strcpy(buf[2], outdir);
#ifndef OPENSSL_SYS_VMS
- BUF_strlcat(buf[2], "/", sizeof(buf[2]));
+ OPENSSL_strlcat(buf[2], "/", sizeof(buf[2]));
#endif
n = (char *)&(buf[2][strlen(buf[2])]);
}
if (BN_is_zero(serial))
- row[DB_serial] = BUF_strdup("00");
+ row[DB_serial] = OPENSSL_strdup("00");
else
row[DB_serial] = BN_bn2hex(serial);
if (row[DB_serial] == NULL) {
goto end;
/* We now just add it to the database */
- row[DB_type] = app_malloc(2, "row db type");
-
+ row[DB_type] = OPENSSL_strdup("V");
tm = X509_get_notAfter(ret);
row[DB_exp_date] = app_malloc(tm->length + 1, "row expdate");
memcpy(row[DB_exp_date], tm->data, tm->length);
row[DB_exp_date][tm->length] = '\0';
-
row[DB_rev_date] = NULL;
-
- /* row[DB_serial] done already */
- row[DB_file] = app_malloc(8, "row file");
+ row[DB_file] = OPENSSL_strdup("unknown");
row[DB_name] = X509_NAME_oneline(X509_get_subject_name(ret), NULL, 0);
if ((row[DB_type] == NULL) || (row[DB_exp_date] == NULL) ||
BIO_printf(bio_err, "Memory allocation failure\n");
goto end;
}
- BUF_strlcpy(row[DB_file], "unknown", 8);
- row[DB_type][0] = 'V';
- row[DB_type][1] = '\0';
irow = app_malloc(sizeof(*irow) * (DB_NUMBER + 1), "row space");
for (i = 0; i < DB_NUMBER; i++) {
if (!bn)
goto end;
if (BN_is_zero(bn))
- row[DB_serial] = BUF_strdup("00");
+ row[DB_serial] = OPENSSL_strdup("00");
else
row[DB_serial] = BN_bn2hex(bn);
BN_free(bn);
row[DB_serial], row[DB_name]);
/* We now just add it to the database */
- row[DB_type] = app_malloc(2, "row type");
-
+ row[DB_type] = OPENSSL_strdup("V");
tm = X509_get_notAfter(x509);
row[DB_exp_date] = app_malloc(tm->length + 1, "row exp_data");
memcpy(row[DB_exp_date], tm->data, tm->length);
row[DB_exp_date][tm->length] = '\0';
-
row[DB_rev_date] = NULL;
-
- /* row[DB_serial] done already */
- row[DB_file] = app_malloc(8, "row filename");
-
- /* row[DB_name] done already */
-
- BUF_strlcpy(row[DB_file], "unknown", 8);
- row[DB_type][0] = 'V';
- row[DB_type][1] = '\0';
+ row[DB_file] = OPENSSL_strdup("unknown");
irow = app_malloc(sizeof(*irow) * (DB_NUMBER + 1), "row ptr");
for (i = 0; i < DB_NUMBER; i++) {
i += strlen(other) + 1;
str = app_malloc(i, "revocation reason");
- BUF_strlcpy(str, (char *)revtm->data, i);
+ OPENSSL_strlcpy(str, (char *)revtm->data, i);
if (reason) {
- BUF_strlcat(str, ",", i);
- BUF_strlcat(str, reason, i);
+ OPENSSL_strlcat(str, ",", i);
+ OPENSSL_strlcat(str, reason, i);
}
if (other) {
- BUF_strlcat(str, ",", i);
- BUF_strlcat(str, other, i);
+ OPENSSL_strlcat(str, ",", i);
+ OPENSSL_strlcat(str, other, i);
}
ASN1_UTCTIME_free(revtm);
return str;
ASN1_OBJECT *hold = NULL;
ASN1_GENERALIZEDTIME *comp_time = NULL;
- tmp = BUF_strdup(str);
+ tmp = OPENSSL_strdup(str);
if (!tmp) {
BIO_printf(bio_err, "memory allocation failure\n");
goto end;
secret_keyid = NULL;
}
if (pwri_pass) {
- pwri_tmp = (unsigned char *)BUF_strdup((char *)pwri_pass);
+ pwri_tmp = (unsigned char *)OPENSSL_strdup((char *)pwri_pass);
if (!pwri_tmp)
goto end;
if (!CMS_add0_recipient_password(cms,
return 0;
if (**buf != '\0')
- BUF_strlcat(*buf, ", ", *size);
- BUF_strlcat(*buf, s, *size);
+ OPENSSL_strlcat(*buf, ", ", *size);
+ OPENSSL_strlcat(*buf, s, *size);
return 1;
}
OPENSSL_assert(bn); /* FIXME: should report an error at this
* point and abort */
if (BN_is_zero(bn))
- itmp = BUF_strdup("00");
+ itmp = OPENSSL_strdup("00");
else
itmp = BN_bn2hex(bn);
row[DB_serial] = itmp;
char *p;
if ((t = getenv("OPENSSL_CONF")) != NULL)
- return BUF_strdup(t);
+ return OPENSSL_strdup(t);
t = X509_get_default_cert_area();
len = strlen(t) + 1 + strlen(OPENSSL_CONF) + 1;
out_buf[0] = '$';
out_buf[1] = 0;
assert(strlen(magic) <= 4); /* "1" or "apr1" */
- strncat(out_buf, magic, 4);
- strncat(out_buf, "$", 1);
- strncat(out_buf, salt, 8);
+ OPENSSL_strlcat(out_buf, magic, sizeof out_buf);
+ OPENSSL_strlcat(out_buf, "$", sizeof out_buf);
+ OPENSSL_strlcat(out_buf, salt, sizeof out_buf);
assert(strlen(out_buf) <= 6 + 8); /* "$apr1$..salt.." */
salt_out = out_buf + 2 + strlen(magic);
salt_len = strlen(salt_out);
goto export_end;
}
if (!twopass)
- BUF_strlcpy(macpass, pass, sizeof macpass);
+ OPENSSL_strlcpy(macpass, pass, sizeof macpass);
p12 = PKCS12_create(cpass, name, key, ucert, certs,
key_pbe, cert_pbe, iter, -1, keytype);
}
if (!twopass)
- BUF_strlcpy(macpass, pass, sizeof macpass);
+ OPENSSL_strlcpy(macpass, pass, sizeof macpass);
if ((options & INFO) && p12->mac)
BIO_printf(bio_err, "MAC Iteration %ld\n",
ep = app_malloc(sizeof(*ep), "collision bucket");
*ep = nilhentry;
ep->old_id = ~0;
- ep->filename = BUF_strdup(filename);
+ ep->filename = OPENSSL_strdup(filename);
if (bp->last_entry)
bp->last_entry->next = ep;
if (bp->first_entry == NULL)
while (*argv)
errs += do_dir(*argv++, h);
} else if ((env = getenv("SSL_CERT_DIR")) != NULL) {
- m = BUF_strdup(env);
+ m = OPENSSL_strdup(env);
for (e = strtok(m, ":"); e != NULL; e = strtok(NULL, ":"))
errs += do_dir(e, h);
OPENSSL_free(m);
BIO_printf(bio_err, "%s [%s]:", text, def);
(void)BIO_flush(bio_err);
if (value != NULL) {
- BUF_strlcpy(buf, value, sizeof buf);
- BUF_strlcat(buf, "\n", sizeof buf);
+ OPENSSL_strlcpy(buf, value, sizeof buf);
+ OPENSSL_strlcat(buf, "\n", sizeof buf);
BIO_printf(bio_err, "%s\n", value);
} else {
buf[0] = '\0';
else if (buf[0] == '\n') {
if ((def == NULL) || (def[0] == '\0'))
return (1);
- BUF_strlcpy(buf, def, sizeof buf);
- BUF_strlcat(buf, "\n", sizeof buf);
+ OPENSSL_strlcpy(buf, def, sizeof buf);
+ OPENSSL_strlcat(buf, "\n", sizeof buf);
} else if ((buf[0] == '.') && (buf[1] == '\n'))
return (1);
BIO_printf(bio_err, "%s [%s]:", text, def);
(void)BIO_flush(bio_err);
if (value != NULL) {
- BUF_strlcpy(buf, value, sizeof buf);
- BUF_strlcat(buf, "\n", sizeof buf);
+ OPENSSL_strlcpy(buf, value, sizeof buf);
+ OPENSSL_strlcat(buf, "\n", sizeof buf);
BIO_printf(bio_err, "%s\n", value);
} else {
buf[0] = '\0';
else if (buf[0] == '\n') {
if ((def == NULL) || (def[0] == '\0'))
return (1);
- BUF_strlcpy(buf, def, sizeof buf);
- BUF_strlcat(buf, "\n", sizeof buf);
+ OPENSSL_strlcpy(buf, def, sizeof buf);
+ OPENSSL_strlcat(buf, "\n", sizeof buf);
} else if ((buf[0] == '.') && (buf[1] == '\n'))
return (1);
return NULL;
}
EVP_PKEY_asn1_get0_info(NULL, NULL, NULL, NULL, &anam, ameth);
- *palgnam = BUF_strdup(anam);
+ *palgnam = OPENSSL_strdup(anam);
#ifndef OPENSSL_NO_ENGINE
if (tmpeng)
ENGINE_finish(tmpeng);
return 0;
}
- sess->id = BUF_memdup(SSL_SESSION_get_id(session, NULL), sess->idlen);
+ sess->id = OPENSSL_memdup(SSL_SESSION_get_id(session, NULL), sess->idlen);
sess->der = app_malloc(sess->derlen, "get session buffer");
if (!sess->id) {
BIO_printf(bio_err, "Out of memory adding to external cache\n");
/* return(0); */
} else {
*host = app_malloc(strlen(h1->h_name) + 1, "copy hostname");
- BUF_strlcpy(*host, h1->h_name, strlen(h1->h_name) + 1);
+ OPENSSL_strlcpy(*host, h1->h_name, strlen(h1->h_name) + 1);
h2 = gethostbyname(*host);
if (h2 == NULL) {
errors++;
goto end;
}
- row[DB_srpid] = BUF_strdup(user);
- row[DB_srptype] = BUF_strdup("v");
- row[DB_srpgN] = BUF_strdup(gNid);
+ row[DB_srpid] = OPENSSL_strdup(user);
+ row[DB_srptype] = OPENSSL_strdup("v");
+ row[DB_srpgN] = OPENSSL_strdup(gNid);
if ((row[DB_srpid] == NULL)
|| (row[DB_srpgN] == NULL)
|| (row[DB_srpverifier] == NULL)
|| (row[DB_srpsalt] == NULL)
|| (userinfo
- && ((row[DB_srpinfo] = BUF_strdup(userinfo)) == NULL))
+ && ((row[DB_srpinfo] = OPENSSL_strdup(userinfo)) == NULL))
|| !update_index(db, row)) {
OPENSSL_free(row[DB_srpid]);
OPENSSL_free(row[DB_srpgN]);
}
row[DB_srptype][0] = 'v';
- row[DB_srpgN] = BUF_strdup(gNid);
+ row[DB_srpgN] = OPENSSL_strdup(gNid);
if (row[DB_srpid] == NULL
|| row[DB_srpgN] == NULL
|| row[DB_srpverifier] == NULL
|| row[DB_srpsalt] == NULL
|| (userinfo
- && ((row[DB_srpinfo] = BUF_strdup(userinfo))
+ && ((row[DB_srpinfo] = OPENSSL_strdup(userinfo))
== NULL)))
goto end;
: (strlen(serialfile))) + 1;
buf = app_malloc(len, "serial# buffer");
if (serialfile == NULL) {
- BUF_strlcpy(buf, CAfile, len);
+ OPENSSL_strlcpy(buf, CAfile, len);
for (p = buf; *p; p++)
if (*p == '.') {
*p = '\0';
break;
}
- BUF_strlcat(buf, POSTFIX, len);
+ OPENSSL_strlcat(buf, POSTFIX, len);
} else
- BUF_strlcpy(buf, serialfile, len);
+ OPENSSL_strlcpy(buf, serialfile, len);
serial = load_serial(buf, create, NULL);
if (serial == NULL)
o_init.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
o_init.o: ../include/openssl/safestack.h ../include/openssl/stack.h
o_init.o: ../include/openssl/symhacks.h o_init.c
-o_str.o: ../e_os.h ../include/internal/o_str.h ../include/openssl/e_os2.h
-o_str.o: ../include/openssl/opensslconf.h o_str.c
+o_str.o: ../e_os.h ../include/internal/o_str.h ../include/openssl/bio.h
+o_str.o: ../include/openssl/buffer.h ../include/openssl/crypto.h
+o_str.o: ../include/openssl/e_os2.h ../include/openssl/err.h
+o_str.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
+o_str.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
+o_str.o: ../include/openssl/safestack.h ../include/openssl/stack.h
+o_str.o: ../include/openssl/symhacks.h include/internal/cryptlib.h o_str.c
o_time.o: ../include/openssl/crypto.h ../include/openssl/e_os2.h
o_time.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
o_time.o: ../include/openssl/ossl_typ.h ../include/openssl/safestack.h
str = (char *)ret->data;
/* Work out the century and prepend */
if (t->data[0] >= '5')
- BUF_strlcpy(str, "19", newlen);
+ OPENSSL_strlcpy(str, "19", newlen);
else
- BUF_strlcpy(str, "20", newlen);
+ OPENSSL_strlcpy(str, "20", newlen);
- BUF_strlcat(str, (char *)t->data, newlen);
+ OPENSSL_strlcat(str, (char *)t->data, newlen);
return ret;
}
ameth->pkey_flags = flags | ASN1_PKEY_DYNAMIC;
if (info) {
- ameth->info = BUF_strdup(info);
+ ameth->info = OPENSSL_strdup(info);
if (!ameth->info)
goto err;
}
if (pem_str) {
- ameth->pem_str = BUF_strdup(pem_str);
+ ameth->pem_str = OPENSSL_strdup(pem_str);
if (!ameth->pem_str)
goto err;
}
int c;
if (name) {
- if ((tmpname = BUF_strdup(name)) == NULL)
+ if ((tmpname = OPENSSL_strdup(name)) == NULL)
return NULL;
for (p = tmpname; *p; p++) {
c = (unsigned char)*p;
}
}
if (value) {
- if ((tmpval = BUF_strdup(value)) == NULL)
+ if ((tmpval = OPENSSL_strdup(value)) == NULL)
goto err;
for (p = tmpval; *p; p++) {
c = (unsigned char)*p;
int c;
MIME_PARAM *mparam = NULL;
if (name) {
- tmpname = BUF_strdup(name);
+ tmpname = OPENSSL_strdup(name);
if (!tmpname)
goto err;
for (p = tmpname; *p; p++) {
}
}
if (value) {
- tmpval = BUF_strdup(value);
+ tmpval = OPENSSL_strdup(value);
if (!tmpval)
goto err;
}
if ((rows * dump_width) < len)
rows++;
for (i = 0; i < rows; i++) {
- BUF_strlcpy(buf, str, sizeof buf);
+ OPENSSL_strlcpy(buf, str, sizeof buf);
BIO_snprintf(tmp, sizeof tmp, "%04x - ", i * dump_width);
- BUF_strlcat(buf, tmp, sizeof buf);
+ OPENSSL_strlcat(buf, tmp, sizeof buf);
for (j = 0; j < dump_width; j++) {
if (((i * dump_width) + j) >= len) {
- BUF_strlcat(buf, " ", sizeof buf);
+ OPENSSL_strlcat(buf, " ", sizeof buf);
} else {
ch = ((unsigned char)*(s + i * dump_width + j)) & 0xff;
BIO_snprintf(tmp, sizeof tmp, "%02x%c", ch,
j == 7 ? '-' : ' ');
- BUF_strlcat(buf, tmp, sizeof buf);
+ OPENSSL_strlcat(buf, tmp, sizeof buf);
}
}
- BUF_strlcat(buf, " ", sizeof buf);
+ OPENSSL_strlcat(buf, " ", sizeof buf);
for (j = 0; j < dump_width; j++) {
if (((i * dump_width) + j) >= len)
break;
? os_toebcdic[ch]
: '.');
#endif
- BUF_strlcat(buf, tmp, sizeof buf);
+ OPENSSL_strlcat(buf, tmp, sizeof buf);
}
- BUF_strlcat(buf, "\n", sizeof buf);
+ OPENSSL_strlcat(buf, "\n", sizeof buf);
/*
* if this is the last call then update the ddt_dump thing so that we
* will move the selection point in the debug window
if (BIO_sock_init() != 1)
return ((int)INVALID_SOCKET);
- if ((str = BUF_strdup(host)) == NULL)
+ if ((str = OPENSSL_strdup(host)) == NULL)
return ((int)INVALID_SOCKET);
h = p = NULL;
if (num == 0) {
b->init = 1;
OPENSSL_free(data->param_addr);
- data->param_addr = BUF_strdup(ptr);
+ data->param_addr = OPENSSL_strdup(ptr);
} else if (num == 1) {
data->accept_nbio = (ptr != NULL);
} else if (num == 2) {
break;
}
OPENSSL_free(c->param_port);
- c->param_port = BUF_strdup(p);
+ c->param_port = OPENSSL_strdup(p);
}
}
b->init = 1;
if (num == 0) {
OPENSSL_free(data->param_hostname);
- data->param_hostname = BUF_strdup(ptr);
+ data->param_hostname = OPENSSL_strdup(ptr);
} else if (num == 1) {
OPENSSL_free(data->param_port);
- data->param_port = BUF_strdup(ptr);
+ data->param_port = OPENSSL_strdup(ptr);
} else if (num == 2) {
char buf[16];
unsigned char *p = ptr;
BIO_snprintf(buf, sizeof buf, "%d.%d.%d.%d",
p[0], p[1], p[2], p[3]);
OPENSSL_free(data->param_hostname);
- data->param_hostname = BUF_strdup(buf);
+ data->param_hostname = OPENSSL_strdup(buf);
memcpy(&(data->ip[0]), ptr, 4);
} else if (num == 3) {
char buf[DECIMAL_SIZE(int) + 1];
BIO_snprintf(buf, sizeof buf, "%d", *(int *)ptr);
OPENSSL_free(data->param_port);
- data->param_port = BUF_strdup(buf);
+ data->param_port = OPENSSL_strdup(buf);
data->port = *(int *)ptr;
}
}
b->shutdown = (int)num & BIO_CLOSE;
if (num & BIO_FP_APPEND) {
if (num & BIO_FP_READ)
- BUF_strlcpy(p, "a+", sizeof p);
+ OPENSSL_strlcpy(p, "a+", sizeof p);
else
- BUF_strlcpy(p, "a", sizeof p);
+ OPENSSL_strlcpy(p, "a", sizeof p);
} else if ((num & BIO_FP_READ) && (num & BIO_FP_WRITE))
- BUF_strlcpy(p, "r+", sizeof p);
+ OPENSSL_strlcpy(p, "r+", sizeof p);
else if (num & BIO_FP_WRITE)
- BUF_strlcpy(p, "w", sizeof p);
+ OPENSSL_strlcpy(p, "w", sizeof p);
else if (num & BIO_FP_READ)
- BUF_strlcpy(p, "r", sizeof p);
+ OPENSSL_strlcpy(p, "r", sizeof p);
else {
BIOerr(BIO_F_FILE_CTRL, BIO_R_BAD_FOPEN_MODE);
ret = 0;
GENERAL=Makefile
LIB=$(TOP)/libcrypto.a
-LIBSRC= buffer.c buf_str.c buf_err.c
-LIBOBJ= buffer.o buf_str.o buf_err.o
+LIBSRC= buffer.c buf_err.c
+LIBOBJ= buffer.o buf_err.o
SRC= $(LIBSRC)
buf_err.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
buf_err.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
buf_err.o: buf_err.c
-buf_str.o: ../../e_os.h ../../include/openssl/bio.h
-buf_str.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
-buf_str.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
-buf_str.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
-buf_str.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
-buf_str.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
-buf_str.o: ../../include/openssl/symhacks.h ../include/internal/cryptlib.h
-buf_str.o: buf_str.c
buffer.o: ../../e_os.h ../../include/openssl/bio.h
buffer.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
buffer.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
# define ERR_REASON(reason) ERR_PACK(ERR_LIB_BUF,0,reason)
static ERR_STRING_DATA BUF_str_functs[] = {
- {ERR_FUNC(BUF_F_BUF_MEMDUP), "BUF_memdup"},
{ERR_FUNC(BUF_F_BUF_MEM_GROW), "BUF_MEM_grow"},
{ERR_FUNC(BUF_F_BUF_MEM_GROW_CLEAN), "BUF_MEM_grow_clean"},
{ERR_FUNC(BUF_F_BUF_MEM_NEW), "BUF_MEM_new"},
- {ERR_FUNC(BUF_F_BUF_STRDUP), "BUF_strdup"},
- {ERR_FUNC(BUF_F_BUF_STRNDUP), "BUF_strndup"},
{0, NULL}
};
+++ /dev/null
-/* crypto/buffer/buffer.c */
-/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
- * All rights reserved.
- *
- * This package is an SSL implementation written
- * by Eric Young (eay@cryptsoft.com).
- * The implementation was written so as to conform with Netscapes SSL.
- *
- * This library is free for commercial and non-commercial use as long as
- * the following conditions are aheared to. The following conditions
- * apply to all code found in this distribution, be it the RC4, RSA,
- * lhash, DES, etc., code; not just the SSL code. The SSL documentation
- * included with this distribution is covered by the same copyright terms
- * except that the holder is Tim Hudson (tjh@cryptsoft.com).
- *
- * Copyright remains Eric Young's, and as such any Copyright notices in
- * the code are not to be removed.
- * If this package is used in a product, Eric Young should be given attribution
- * as the author of the parts of the library used.
- * This can be in the form of a textual message at program startup or
- * in documentation (online or textual) provided with the package.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * "This product includes cryptographic software written by
- * Eric Young (eay@cryptsoft.com)"
- * The word 'cryptographic' can be left out if the rouines from the library
- * being used are not cryptographic related :-).
- * 4. If you include any Windows specific code (or a derivative thereof) from
- * the apps directory (application code) you must include an acknowledgement:
- * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
- *
- * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * The licence and distribution terms for any publically available version or
- * derivative of this code cannot be changed. i.e. this code cannot simply be
- * copied and put under another distribution licence
- * [including the GNU Public Licence.]
- */
-
-#include <stdio.h>
-#include <limits.h>
-#include "internal/cryptlib.h"
-#include <openssl/buffer.h>
-
-size_t BUF_strnlen(const char *str, size_t maxlen)
-{
- const char *p;
-
- for (p = str; maxlen-- != 0 && *p != '\0'; ++p) ;
-
- return p - str;
-}
-
-char *BUF_strdup(const char *str)
-{
- if (str == NULL)
- return NULL;
- return BUF_strndup(str, strlen(str));
-}
-
-char *BUF_strndup(const char *str, size_t siz)
-{
- char *ret;
-
- if (str == NULL)
- return NULL;
-
- siz = BUF_strnlen(str, siz);
-
- if (siz >= INT_MAX)
- return NULL;
-
- ret = OPENSSL_malloc(siz + 1);
- if (ret == NULL) {
- BUFerr(BUF_F_BUF_STRNDUP, ERR_R_MALLOC_FAILURE);
- return NULL;
- }
-
- memcpy(ret, str, siz);
- ret[siz] = '\0';
-
- return (ret);
-}
-
-void *BUF_memdup(const void *data, size_t siz)
-{
- void *ret;
-
- if (data == NULL || siz >= INT_MAX)
- return NULL;
-
- ret = OPENSSL_malloc(siz);
- if (ret == NULL) {
- BUFerr(BUF_F_BUF_MEMDUP, ERR_R_MALLOC_FAILURE);
- return NULL;
- }
- return memcpy(ret, data, siz);
-}
-
-size_t BUF_strlcpy(char *dst, const char *src, size_t size)
-{
- size_t l = 0;
- for (; size > 1 && *src; size--) {
- *dst++ = *src++;
- l++;
- }
- if (size)
- *dst = '\0';
- return l + strlen(src);
-}
-
-size_t BUF_strlcat(char *dst, const char *src, size_t size)
-{
- size_t l = 0;
- for (; size > 0 && *dst; size--, dst++)
- l++;
- return l + BUF_strlcpy(dst, src, size);
-}
goto err;
}
- section = BUF_strdup("default");
+ section = OPENSSL_strdup("default");
if (section == NULL) {
CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
goto err;
CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE);
goto err;
}
- BUF_strlcpy(v->name, pname, strlen(pname) + 1);
+ OPENSSL_strlcpy(v->name, pname, strlen(pname) + 1);
if (!str_copy(conf, psection, &(v->value), start))
goto err;
return NULL;
tmod->dso = dso;
- tmod->name = BUF_strdup(name);
+ tmod->name = OPENSSL_strdup(name);
tmod->init = ifunc;
tmod->finish = ffunc;
goto err;
imod->pmod = pmod;
- imod->name = BUF_strdup(name);
- imod->value = BUF_strdup(value);
+ imod->name = OPENSSL_strdup(name);
+ imod->value = OPENSSL_strdup(value);
imod->usr_data = NULL;
if (!imod->name || !imod->value)
file = getenv("OPENSSL_CONF");
if (file)
- return BUF_strdup(file);
+ return OPENSSL_strdup(file);
len = strlen(X509_get_default_cert_area());
#ifndef OPENSSL_SYS_VMS
if (file == NULL)
return NULL;
- BUF_strlcpy(file, X509_get_default_cert_area(), len + 1);
+ OPENSSL_strlcpy(file, X509_get_default_cert_area(), len + 1);
#ifndef OPENSSL_SYS_VMS
- BUF_strlcat(file, "/", len + 1);
+ OPENSSL_strlcat(file, "/", len + 1);
#endif
- BUF_strlcat(file, OPENSSL_CONF, len + 1);
+ OPENSSL_strlcat(file, OPENSSL_CONF, len + 1);
return file;
}
{ERR_FUNC(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX), "CRYPTO_get_ex_new_index"},
{ERR_FUNC(CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID), "CRYPTO_get_new_dynlockid"},
{ERR_FUNC(CRYPTO_F_CRYPTO_GET_NEW_LOCKID), "CRYPTO_get_new_lockid"},
+ {ERR_FUNC(CRYPTO_F_CRYPTO_MEMDUP), "CRYPTO_memdup"},
{ERR_FUNC(CRYPTO_F_CRYPTO_NEW_EX_DATA), "CRYPTO_new_ex_data"},
{ERR_FUNC(CRYPTO_F_CRYPTO_SET_EX_DATA), "CRYPTO_set_ex_data"},
{ERR_FUNC(CRYPTO_F_DEF_ADD_INDEX), "DEF_ADD_INDEX"},
to->seed = NULL;
to->seedlen = 0;
if (from->seed) {
- to->seed = BUF_memdup(from->seed, from->seedlen);
+ to->seed = OPENSSL_memdup(from->seed, from->seedlen);
if (!to->seed)
return 0;
to->seedlen = from->seedlen;
if (ukm) {
dukmlen = ASN1_STRING_length(ukm);
- dukm = BUF_memdup(ASN1_STRING_data(ukm), dukmlen);
+ dukm = OPENSSL_memdup(ASN1_STRING_data(ukm), dukmlen);
if (!dukm)
goto err;
}
if (ukm) {
dukmlen = ASN1_STRING_length(ukm);
- dukm = BUF_memdup(ASN1_STRING_data(ukm), dukmlen);
+ dukm = OPENSSL_memdup(ASN1_STRING_data(ukm), dukmlen);
if (!dukm)
goto err;
}
return 0;
dctx->kdf_md = sctx->kdf_md;
if (dctx->kdf_ukm) {
- dctx->kdf_ukm = BUF_memdup(sctx->kdf_ukm, sctx->kdf_ukmlen);
+ dctx->kdf_ukm = OPENSSL_memdup(sctx->kdf_ukm, sctx->kdf_ukmlen);
dctx->kdf_ukmlen = sctx->kdf_ukmlen;
}
dctx->kdf_outlen = sctx->kdf_outlen;
DSOerr(DSO_F_DSO_SET_FILENAME, ERR_R_MALLOC_FAILURE);
return (0);
}
- BUF_strlcpy(copied, filename, strlen(filename) + 1);
+ OPENSSL_strlcpy(copied, filename, strlen(filename) + 1);
OPENSSL_free(dso->filename);
dso->filename = copied;
return (1);
DSOerr(DSO_F_DSO_CONVERT_FILENAME, ERR_R_MALLOC_FAILURE);
return (NULL);
}
- BUF_strlcpy(result, filename, strlen(filename) + 1);
+ OPENSSL_strlcpy(result, filename, strlen(filename) + 1);
}
return (result);
}
dctx->kdf_md = sctx->kdf_md;
dctx->kdf_outlen = sctx->kdf_outlen;
if (sctx->kdf_ukm) {
- dctx->kdf_ukm = BUF_memdup(sctx->kdf_ukm, sctx->kdf_ukmlen);
+ dctx->kdf_ukm = OPENSSL_memdup(sctx->kdf_ukm, sctx->kdf_ukmlen);
if (!dctx->kdf_ukm)
return 0;
} else
p = NULL;
OPENSSL_free(ctx->DYNAMIC_LIBNAME);
if (p)
- ctx->DYNAMIC_LIBNAME = BUF_strdup(p);
+ ctx->DYNAMIC_LIBNAME = OPENSSL_strdup(p);
else
ctx->DYNAMIC_LIBNAME = NULL;
return (ctx->DYNAMIC_LIBNAME ? 1 : 0);
p = NULL;
OPENSSL_free(ctx->engine_id);
if (p)
- ctx->engine_id = BUF_strdup(p);
+ ctx->engine_id = OPENSSL_strdup(p);
else
ctx->engine_id = NULL;
return (ctx->engine_id ? 1 : 0);
return 0;
}
{
- char *tmp_str = BUF_strdup(p);
+ char *tmp_str = OPENSSL_strdup(p);
if (!tmp_str) {
ENGINEerr(ENGINE_F_DYNAMIC_CTRL, ERR_R_MALLOC_FAILURE);
return 0;
}
str = p;
}
- BUF_strlcat(str, a, (size_t)s + 1);
+ OPENSSL_strlcat(str, a, (size_t)s + 1);
}
}
ERR_set_error_data(str, ERR_TXT_MALLOCED | ERR_TXT_STRING);
case EVP_CTRL_COPY:
if (actx) {
if ((((EVP_CIPHER_CTX *)ptr)->cipher_data =
- BUF_memdup(actx,sizeof(*actx) + Poly1305_ctx_size()))
+ OPENSSL_memdup(actx,sizeof(*actx) + Poly1305_ctx_size()))
== NULL) {
EVPerr(EVP_F_CHACHA20_POLY1305_CTRL, EVP_R_COPY_ERROR);
return 0;
char obj_tmp[80];
EVPerr(EVP_F_EVP_PBE_CIPHERINIT, EVP_R_UNKNOWN_PBE_ALGORITHM);
if (!pbe_obj)
- BUF_strlcpy(obj_tmp, "NULL", sizeof obj_tmp);
+ OPENSSL_strlcpy(obj_tmp, "NULL", sizeof obj_tmp);
else
i2t_ASN1_OBJECT(obj_tmp, sizeof obj_tmp, pbe_obj);
ERR_add_error_data(2, "TYPE=", obj_tmp);
CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID, ERR_R_MALLOC_FAILURE);
return (0);
}
- if ((str = BUF_strdup(name)) == NULL) {
+ if ((str = OPENSSL_strdup(name)) == NULL) {
CRYPTOerr(CRYPTO_F_CRYPTO_GET_NEW_LOCKID, ERR_R_MALLOC_FAILURE);
return (0);
}
return ret;
}
-char *CRYPTO_strdup(const char *str, const char *file, int line)
-{
- char *ret = CRYPTO_malloc(strlen(str) + 1, file, line);
-
- if (ret != NULL)
- strcpy(ret, str);
- return ret;
-}
-
void *CRYPTO_realloc(void *str, int num, const char *file, int line)
{
void *ret = NULL;
memcpy(buf + buf_len, amip->info, 128 - buf_len - 3);
buf_len = 128 - 3;
} else {
- BUF_strlcpy(buf + buf_len, amip->info, sizeof buf - buf_len);
+ OPENSSL_strlcpy(buf + buf_len, amip->info, sizeof buf - buf_len);
buf_len = strlen(buf);
}
BIO_snprintf(buf + buf_len, sizeof buf - buf_len, "\"\n");
*/
#include <ctype.h>
+#include <limits.h>
#include <e_os.h>
+#include <openssl/crypto.h>
+#include "internal/cryptlib.h"
#include "internal/o_str.h"
#if !defined(OPENSSL_IMPLEMENTS_strncasecmp) && \
return ret;
}
+
+char *CRYPTO_strdup(const char *str, const char* file, int line)
+{
+ char *ret;
+
+ if (str == NULL)
+ return NULL;
+ ret = CRYPTO_malloc(strlen(str) + 1, file, line);
+ if (ret != NULL)
+ strcpy(ret, str);
+ return ret;
+}
+
+char *CRYPTO_strndup(const char *str, size_t s, const char* file, int line)
+{
+ const char *cp;
+ size_t maxlen;
+ char *ret;
+
+ if (str == NULL)
+ return NULL;
+
+ /* Get length. */
+ for (cp = str, maxlen = s; maxlen-- != 0 && *cp != '\0'; ++cp)
+ continue;
+ maxlen = cp - str;
+
+ ret = CRYPTO_malloc(maxlen + 1, file, line);
+ if (ret) {
+ memcpy(ret, str, maxlen);
+ ret[maxlen] = '\0';
+ }
+ return ret;
+}
+
+void *CRYPTO_memdup(const void *data, size_t siz, const char* file, int line)
+{
+ void *ret;
+
+ if (data == NULL || siz >= INT_MAX)
+ return NULL;
+
+ ret = CRYPTO_malloc(siz, file, line);
+ if (ret == NULL) {
+ CRYPTOerr(CRYPTO_F_CRYPTO_MEMDUP, ERR_R_MALLOC_FAILURE);
+ return NULL;
+ }
+ return memcpy(ret, data, siz);
+}
+
+size_t OPENSSL_strnlen(const char *str, size_t maxlen)
+{
+ const char *p;
+
+ for (p = str; maxlen-- != 0 && *p != '\0'; ++p) ;
+
+ return p - str;
+}
+
+size_t OPENSSL_strlcpy(char *dst, const char *src, size_t size)
+{
+ size_t l = 0;
+ for (; size > 1 && *src; size--) {
+ *dst++ = *src++;
+ l++;
+ }
+ if (size)
+ *dst = '\0';
+ return l + strlen(src);
+}
+
+size_t OPENSSL_strlcat(char *dst, const char *src, size_t size)
+{
+ size_t l = 0;
+ for (; size > 0 && *dst; size--, dst++)
+ l++;
+ return l + OPENSSL_strlcpy(dst, src, size);
+}
s = OBJ_nid2sn(nid);
if (s) {
if (buf)
- BUF_strlcpy(buf, s, buf_len);
+ OPENSSL_strlcpy(buf, s, buf_len);
n = strlen(s);
return n;
}
*buf = '\0';
buf_len--;
}
- BUF_strlcpy(buf, bndec, buf_len);
+ OPENSSL_strlcpy(buf, bndec, buf_len);
if (i > buf_len) {
buf += buf_len;
buf_len = 0;
BIO_snprintf(tbuf, sizeof tbuf, ".%lu", l);
i = strlen(tbuf);
if (buf && (buf_len > 0)) {
- BUF_strlcpy(buf, tbuf, buf_len);
+ OPENSSL_strlcpy(buf, tbuf, buf_len);
if (i > buf_len) {
buf += buf_len;
buf_len = 0;
*ppath = NULL;
/* dup the buffer since we are going to mess with it */
- buf = BUF_strdup(url);
+ buf = OPENSSL_strdup(url);
if (!buf)
goto mem_err;
p = strchr(p, '/');
if (!p)
- *ppath = BUF_strdup("/");
+ *ppath = OPENSSL_strdup("/");
else {
- *ppath = BUF_strdup(p);
+ *ppath = OPENSSL_strdup(p);
/* Set start of path to 0 so hostname is valid */
*p = '\0';
}
port = p + 1;
}
- *pport = BUF_strdup(port);
+ *pport = OPENSSL_strdup(port);
if (!*pport)
goto mem_err;
- *phost = BUF_strdup(host);
+ *phost = OPENSSL_strdup(host);
if (!*phost)
goto mem_err;
else
str = "BAD-TYPE";
- BUF_strlcat(buf, "Proc-Type: 4,", PEM_BUFSIZE);
- BUF_strlcat(buf, str, PEM_BUFSIZE);
- BUF_strlcat(buf, "\n", PEM_BUFSIZE);
+ OPENSSL_strlcat(buf, "Proc-Type: 4,", PEM_BUFSIZE);
+ OPENSSL_strlcat(buf, str, PEM_BUFSIZE);
+ OPENSSL_strlcat(buf, "\n", PEM_BUFSIZE);
}
void PEM_dek_info(char *buf, const char *type, int len, char *str)
long i;
int j;
- BUF_strlcat(buf, "DEK-Info: ", PEM_BUFSIZE);
- BUF_strlcat(buf, type, PEM_BUFSIZE);
- BUF_strlcat(buf, ",", PEM_BUFSIZE);
+ OPENSSL_strlcat(buf, "DEK-Info: ", PEM_BUFSIZE);
+ OPENSSL_strlcat(buf, type, PEM_BUFSIZE);
+ OPENSSL_strlcat(buf, ",", PEM_BUFSIZE);
j = strlen(buf);
if (j + (len * 2) + 1 > PEM_BUFSIZE)
return;
md_rand.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
md_rand.o: ../../include/openssl/sha.h ../../include/openssl/stack.h
md_rand.o: ../../include/openssl/symhacks.h md_rand.c rand_lcl.h
-rand_egd.o: ../../include/openssl/buffer.h ../../include/openssl/e_os2.h
+rand_egd.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
rand_egd.o: ../../include/openssl/opensslconf.h
-rand_egd.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
+rand_egd.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
+rand_egd.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
+rand_egd.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
rand_egd.o: rand_egd.c
rand_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
rand_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
*
*/
+#include <openssl/crypto.h>
#include <openssl/e_os2.h>
#include <openssl/rand.h>
-#include <openssl/buffer.h>
/*-
* Query the EGD <URL: http://www.lothar.com/tech/crypto/>.
addr.sun_family = AF_UNIX;
if (strlen(path) >= sizeof(addr.sun_path))
return (-1);
- BUF_strlcpy(addr.sun_path, path, sizeof addr.sun_path);
+ OPENSSL_strlcpy(addr.sun_path, path, sizeof addr.sun_path);
len = offsetof(struct sockaddr_un, sun_path) + strlen(path);
fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd == -1)
if (OPENSSL_issetugid() == 0)
s = getenv("RANDFILE");
if (s != NULL && *s && strlen(s) + 1 < size) {
- if (BUF_strlcpy(buf, s, size) >= size)
+ if (OPENSSL_strlcpy(buf, s, size) >= size)
return NULL;
} else {
if (OPENSSL_issetugid() == 0)
}
#endif
if (s && *s && strlen(s) + strlen(RFILE) + 2 < size) {
- BUF_strlcpy(buf, s, size);
+ OPENSSL_strlcpy(buf, s, size);
#ifndef OPENSSL_SYS_VMS
- BUF_strlcat(buf, "/", size);
+ OPENSSL_strlcat(buf, "/", size);
#endif
- BUF_strlcat(buf, RFILE, size);
+ OPENSSL_strlcat(buf, RFILE, size);
} else
buf[0] = '\0'; /* no file name */
}
*/
if (!buf[0])
- if (BUF_strlcpy(buf, "/dev/arandom", size) >= size) {
+ if (OPENSSL_strlcpy(buf, "/dev/arandom", size) >= size) {
return (NULL);
}
if (stat(buf, &sb) == -1)
- if (BUF_strlcpy(buf, "/dev/arandom", size) >= size) {
+ if (OPENSSL_strlcpy(buf, "/dev/arandom", size) >= size) {
return (NULL);
}
#endif
dctx->mgf1md = sctx->mgf1md;
if (sctx->oaep_label) {
OPENSSL_free(dctx->oaep_label);
- dctx->oaep_label = BUF_memdup(sctx->oaep_label, sctx->oaep_labellen);
+ dctx->oaep_label = OPENSSL_memdup(sctx->oaep_label, sctx->oaep_labellen);
if (!dctx->oaep_label)
return 0;
dctx->oaep_labellen = sctx->oaep_labellen;
static int SRP_user_pwd_set_ids(SRP_user_pwd *vinfo, const char *id,
const char *info)
{
- if (id != NULL && NULL == (vinfo->id = BUF_strdup(id)))
+ if (id != NULL && NULL == (vinfo->id = OPENSSL_strdup(id)))
return 0;
- return (info == NULL || NULL != (vinfo->info = BUF_strdup(info)));
+ return (info == NULL || NULL != (vinfo->info = OPENSSL_strdup(info)));
}
static int SRP_user_pwd_set_sv(SRP_user_pwd *vinfo, const char *s,
vb->default_g = NULL;
vb->default_N = NULL;
vb->seed_key = NULL;
- if ((seed_key != NULL) && (vb->seed_key = BUF_strdup(seed_key)) == NULL) {
+ if ((seed_key != NULL) && (vb->seed_key = OPENSSL_strdup(seed_key)) == NULL) {
sk_SRP_user_pwd_free(vb->users_pwd);
sk_SRP_gN_cache_free(vb->gN_cache);
OPENSSL_free(vb);
if (newgN == NULL)
return NULL;
- if ((newgN->b64_bn = BUF_strdup(ch)) == NULL)
+ if ((newgN->b64_bn = OPENSSL_strdup(ch)) == NULL)
goto err;
len = t_fromb64(tmp, ch);
if ((gN = OPENSSL_malloc(sizeof(*gN))) == NULL)
goto err;
- if ((gN->id = BUF_strdup(pp[DB_srpid])) == NULL
+ if ((gN->id = OPENSSL_strdup(pp[DB_srpid])) == NULL
|| (gN->N = SRP_gN_place_bn(vb->gN_cache, pp[DB_srpverifier]))
== NULL
|| (gN->g = SRP_gN_place_bn(vb->gN_cache, pp[DB_srpsalt]))
return 0;
}
if (!ATTR_IS_SET(attrs, code)) {
- if ((attrs->values[code].cstring = BUF_strndup(cstr, cstr_size)))
+ if ((attrs->values[code].cstring = OPENSSL_strndup(cstr, cstr_size)))
return 1;
STOREerr(STORE_F_STORE_ATTR_INFO_SET_CSTR, ERR_R_MALLOC_FAILURE);
return 0;
}
if (!ATTR_IS_SET(attrs, code)) {
if ((attrs->values[code].sha1string =
- (unsigned char *)BUF_memdup(sha1str, sha1str_size)))
+ (unsigned char *)OPENSSL_memdup(sha1str, sha1str_size)))
return 1;
STOREerr(STORE_F_STORE_ATTR_INFO_SET_SHA1STR, ERR_R_MALLOC_FAILURE);
return 0;
STORE_METHOD *store_method = OPENSSL_zalloc(sizeof(*store_method));
if (store_method != NULL)
- store_method->name = BUF_strdup(name);
+ store_method->name = OPENSSL_strdup(name);
return store_method;
}
char *prompt_copy = NULL;
if (prompt) {
- prompt_copy = BUF_strdup(prompt);
+ prompt_copy = OPENSSL_strdup(prompt);
if (prompt_copy == NULL) {
UIerr(UI_F_UI_DUP_INPUT_STRING, ERR_R_MALLOC_FAILURE);
return 0;
char *prompt_copy = NULL;
if (prompt) {
- prompt_copy = BUF_strdup(prompt);
+ prompt_copy = OPENSSL_strdup(prompt);
if (prompt_copy == NULL) {
UIerr(UI_F_UI_DUP_VERIFY_STRING, ERR_R_MALLOC_FAILURE);
return -1;
char *cancel_chars_copy = NULL;
if (prompt) {
- prompt_copy = BUF_strdup(prompt);
+ prompt_copy = OPENSSL_strdup(prompt);
if (prompt_copy == NULL) {
UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE);
goto err;
}
if (action_desc) {
- action_desc_copy = BUF_strdup(action_desc);
+ action_desc_copy = OPENSSL_strdup(action_desc);
if (action_desc_copy == NULL) {
UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE);
goto err;
}
if (ok_chars) {
- ok_chars_copy = BUF_strdup(ok_chars);
+ ok_chars_copy = OPENSSL_strdup(ok_chars);
if (ok_chars_copy == NULL) {
UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE);
goto err;
}
if (cancel_chars) {
- cancel_chars_copy = BUF_strdup(cancel_chars);
+ cancel_chars_copy = OPENSSL_strdup(cancel_chars);
if (cancel_chars_copy == NULL) {
UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE);
goto err;
char *text_copy = NULL;
if (text) {
- text_copy = BUF_strdup(text);
+ text_copy = OPENSSL_strdup(text);
if (text_copy == NULL) {
UIerr(UI_F_UI_DUP_INFO_STRING, ERR_R_MALLOC_FAILURE);
return -1;
char *text_copy = NULL;
if (text) {
- text_copy = BUF_strdup(text);
+ text_copy = OPENSSL_strdup(text);
if (text_copy == NULL) {
UIerr(UI_F_UI_DUP_ERROR_STRING, ERR_R_MALLOC_FAILURE);
return -1;
prompt = OPENSSL_malloc(len + 1);
if (prompt == NULL)
return NULL;
- BUF_strlcpy(prompt, prompt1, len + 1);
- BUF_strlcat(prompt, object_desc, len + 1);
+ OPENSSL_strlcpy(prompt, prompt1, len + 1);
+ OPENSSL_strlcat(prompt, object_desc, len + 1);
if (object_name) {
- BUF_strlcat(prompt, prompt2, len + 1);
- BUF_strlcat(prompt, object_name, len + 1);
+ OPENSSL_strlcat(prompt, prompt2, len + 1);
+ OPENSSL_strlcat(prompt, object_name, len + 1);
}
- BUF_strlcat(prompt, prompt3, len + 1);
+ OPENSSL_strlcat(prompt, prompt3, len + 1);
}
return prompt;
}
UI_METHOD *ui_method = OPENSSL_zalloc(sizeof(*ui_method));
if (ui_method != NULL)
- ui_method->name = BUF_strdup(name);
+ ui_method->name = OPENSSL_strdup(name);
return ui_method;
}
return -1;
}
- BUF_strlcpy(uis->result_buf, result,
+ OPENSSL_strlcpy(uis->result_buf, result,
uis->_.string_data.result_maxsize + 1);
break;
case UIT_BOOLEAN:
if (trtmp->flags & X509_TRUST_DYNAMIC_NAME)
OPENSSL_free(trtmp->name);
/* dup supplied name */
- if ((trtmp->name = BUF_strdup(name)) == NULL) {
+ if ((trtmp->name = OPENSSL_strdup(name)) == NULL) {
X509err(X509_F_X509_TRUST_ADD, ERR_R_MALLOC_FAILURE);
return 0;
}
if (name == NULL || namelen == 0)
return 1;
- copy = BUF_strndup(name, namelen);
+ copy = OPENSSL_strndup(name, namelen);
if (copy == NULL)
return 0;
void *tmp;
if (src) {
if (srclen == 0) {
- tmp = BUF_strdup(src);
+ tmp = OPENSSL_strdup(src);
srclen = strlen(src);
} else
- tmp = BUF_memdup(src, srclen);
+ tmp = OPENSSL_memdup(src, srclen);
if (!tmp)
return 0;
} else {
int X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name)
{
OPENSSL_free(param->name);
- param->name = BUF_strdup(name);
+ param->name = OPENSSL_strdup(name);
if (param->name)
return 1;
return 0;
length = length_from_afi(afi);
/*
- * Handle SAFI, if any, and BUF_strdup() so we can null-terminate
+ * Handle SAFI, if any, and OPENSSL_strdup() so we can null-terminate
* the other input values.
*/
if (safi != NULL) {
goto err;
}
t += strspn(t, " \t");
- s = BUF_strdup(t);
+ s = OPENSSL_strdup(t);
} else {
- s = BUF_strdup(val->value);
+ s = OPENSSL_strdup(val->value);
}
if (s == NULL) {
X509V3err(X509V3_F_V2I_IPADDRBLOCKS, ERR_R_MALLOC_FAILURE);
goto err;
}
} else {
- char *s = BUF_strdup(val->value);
+ char *s = OPENSSL_strdup(val->value);
if (s == NULL) {
X509V3err(X509V3_F_V2I_ASIDENTIFIERS, ERR_R_MALLOC_FAILURE);
goto err;
strval = ASN1_ENUMERATED_get(e);
for (enam = method->usr_data; enam->lname; enam++) {
if (strval == enam->bitnum)
- return BUF_strdup(enam->lname);
+ return OPENSSL_strdup(enam->lname);
}
return i2s_ASN1_ENUMERATED(method, e);
}
ERR_R_MALLOC_FAILURE);
return NULL;
}
- BUF_strlcpy(ntmp, objtmp, nlen);
- BUF_strlcat(ntmp, " - ", nlen);
- BUF_strlcat(ntmp, vtmp->name, nlen);
+ OPENSSL_strlcpy(ntmp, objtmp, nlen);
+ OPENSSL_strlcat(ntmp, " - ", nlen);
+ OPENSSL_strlcat(ntmp, vtmp->name, nlen);
OPENSSL_free(vtmp->name);
vtmp->name = ntmp;
OPENSSL_free(ptmp->sname);
}
/* dup supplied name */
- ptmp->name = BUF_strdup(name);
- ptmp->sname = BUF_strdup(sname);
+ ptmp->name = OPENSSL_strdup(name);
+ ptmp->sname = OPENSSL_strdup(sname);
if (!ptmp->name || !ptmp->sname) {
X509V3err(X509V3_F_X509_PURPOSE_ADD, ERR_R_MALLOC_FAILURE);
return 0;
CONF_VALUE *vtmp = NULL;
char *tname = NULL, *tvalue = NULL;
- if (name && (tname = BUF_strdup(name)) == NULL)
+ if (name && (tname = OPENSSL_strdup(name)) == NULL)
goto err;
- if (value && (tvalue = BUF_strdup(value)) == NULL)
+ if (value && (tvalue = OPENSSL_strdup(value)) == NULL)
goto err;
if ((vtmp = OPENSSL_malloc(sizeof(*vtmp))) == NULL)
goto err;
char *linebuf;
int state;
/* We are going to modify the line so copy it first */
- linebuf = BUF_strdup(line);
+ linebuf = OPENSSL_strdup(line);
if (linebuf == NULL) {
X509V3err(X509V3_F_X509V3_PARSE_LIST, ERR_R_MALLOC_FAILURE);
goto err;
/* Don't add duplicates */
if (sk_OPENSSL_STRING_find(*sk, (char *)email->data) != -1)
return 1;
- emtmp = BUF_strdup((char *)email->data);
+ emtmp = OPENSSL_strdup((char *)email->data);
if (emtmp == NULL || !sk_OPENSSL_STRING_push(*sk, emtmp)) {
X509_email_free(*sk);
*sk = NULL;
else if (a->length == (int)blen && !memcmp(a->data, b, blen))
rv = 1;
if (rv > 0 && peername)
- *peername = BUF_strndup((char *)a->data, a->length);
+ *peername = OPENSSL_strndup((char *)a->data, a->length);
} else {
int astrlen;
unsigned char *astr;
}
rv = equal(astr, astrlen, (unsigned char *)b, blen, flags);
if (rv > 0 && peername)
- *peername = BUF_strndup((char *)astr, astrlen);
+ *peername = OPENSSL_strndup((char *)astr, astrlen);
OPENSSL_free(astr);
}
return rv;
p = strchr(ipasc, '/');
if (!p)
return NULL;
- iptmp = BUF_strdup(ipasc);
+ iptmp = OPENSSL_strdup(ipasc);
if (!iptmp)
return NULL;
p = iptmp + (p - ipasc);
BUF_MEM_new, BUF_MEM_new_ex, BUF_MEM_free, BUF_MEM_grow - simple
character array structure
-BUF_strdup, BUF_strndup, BUF_memdup, BUF_strlcpy, BUF_strlcat -
standard C library equivalents
=head1 SYNOPSIS
int BUF_MEM_grow(BUF_MEM *str, int len);
- char *BUF_strdup(const char *str);
-
- char *BUF_strndup(const char *str, size_t siz);
-
- void *BUF_memdup(const void *data, size_t siz);
-
- size_t BUF_strlcpy(char *dst, const char *src, size_t size);
-
- size_t BUF_strlcat(char *dst, const char *src, size_t size);
-
- size_t BUF_strnlen(const char *str, size_t maxlen);
-
=head1 DESCRIPTION
The buffer library handles simple character arrays. Buffers are used for
B<len>. Any data already in the buffer is preserved if it increases in
size.
-BUF_strdup(), BUF_strndup(), BUF_memdup(), BUF_strlcpy(),
-BUF_strlcat() and BUF_strnlen are equivalents of the standard C
-library functions. The dup() functions use OPENSSL_malloc() underneath
-and so should be used in preference to the standard library for memory
-leak checking or replacing the malloc() function.
-
-Memory allocated from these functions should be freed up using the
-OPENSSL_free() function.
-
-BUF_strndup makes the explicit guarantee that it will never read past
-the first B<siz> bytes of B<str>.
-
=head1 RETURN VALUES
BUF_MEM_new() returns the buffer or NULL on error.
tmp = getenv(gost_envnames[param]);
if (tmp) {
OPENSSL_free(gost_params[param]);
- gost_params[param] = BUF_strdup(tmp);
+ gost_params[param] = OPENSSL_strdup(tmp);
return gost_params[param];
}
return NULL;
if (!tmp)
tmp = value;
OPENSSL_free(gost_params[param]);
- gost_params[param] = BUF_strdup(tmp);
+ gost_params[param] = OPENSSL_strdup(tmp);
return 1;
}
case CAPI_CMD_STORE_NAME:
OPENSSL_free(ctx->storename);
- ctx->storename = BUF_strdup(p);
+ ctx->storename = OPENSSL_strdup(p);
CAPI_trace(ctx, "Setting store name to %s\n", p);
break;
break;
case CAPI_CMD_DEBUG_FILE:
- ctx->debug_file = BUF_strdup(p);
+ ctx->debug_file = OPENSSL_strdup(p);
CAPI_trace(ctx, "Setting debug file to %s\n", ctx->debug_file);
break;
CryptReleaseContext(hprov, 0);
}
OPENSSL_free(ctx->cspname);
- ctx->cspname = BUF_strdup(pname);
+ ctx->cspname = OPENSSL_strdup(pname);
ctx->csptype = type;
return 1;
}
static long set_HWCRHK_LIBNAME(const char *name)
{
free_HWCRHK_LIBNAME();
- return (((HWCRHK_LIBNAME = BUF_strdup(name)) != NULL) ? 1 : 0);
+ return (((HWCRHK_LIBNAME = OPENSSL_strdup(name)) != NULL) ? 1 : 0);
}
static const char *n_hwcrhk_Init = "HWCryptoHook_Init";
static long set_UBSEC_LIBNAME(const char *name)
{
free_UBSEC_LIBNAME();
- return (((UBSEC_LIBNAME = BUF_strdup(name)) != NULL) ? 1 : 0);
+ return (((UBSEC_LIBNAME = OPENSSL_strdup(name)) != NULL) ? 1 : 0);
}
static const char *UBSEC_F1 = "ubsec_bytes_to_bits";
# define HEADER_BUFFER_H
# include <openssl/ossl_typ.h>
+# ifndef HEADER_CRYPTO_H
+# include <openssl/crypto.h>
+# endif
+
#ifdef __cplusplus
extern "C" {
# include <sys/types.h>
# endif
-/* Already declared in ossl_typ.h */
-/* typedef struct buf_mem_st BUF_MEM; */
-
+/*
+ * These names are outdated as of OpenSSL 1.1; a future release
+ * will move them to be deprecated.
+ */
+# define BUF_strdup(s) OPENSSL_strdup(s)
+# define BUF_strndup(s, size) OPENSSL_strndup(s, size)
+# define BUF_memdup(data, size) OPENSSL_memdup(data, size)
+# define BUF_strlcpy(dst, src, size) OPENSSL_strlcpy(dst, src, size)
+# define BUF_strlcat(dst, src, size) OPENSSL_strlcat(dst, src, size)
+# define BUF_strnlen(str, maxlen) OPENSSL_strnlen(str, maxlen)
+
struct buf_mem_st {
size_t length; /* current number of bytes */
char *data;
void BUF_MEM_free(BUF_MEM *a);
size_t BUF_MEM_grow(BUF_MEM *str, size_t len);
size_t BUF_MEM_grow_clean(BUF_MEM *str, size_t len);
-size_t BUF_strnlen(const char *str, size_t maxlen);
-char *BUF_strdup(const char *str);
-
-/*
- * Like strndup, but in addition, explicitly guarantees to never read past the
- * first |siz| bytes of |str|.
- */
-char *BUF_strndup(const char *str, size_t siz);
-
-void *BUF_memdup(const void *data, size_t siz);
void BUF_reverse(unsigned char *out, unsigned char *in, size_t siz);
-/* safe string functions */
-size_t BUF_strlcpy(char *dst, const char *src, size_t siz);
-size_t BUF_strlcat(char *dst, const char *src, size_t siz);
-
/* BEGIN ERROR CODES */
/*
* The following lines are auto generated by the script mkerr.pl. Any changes
/* Error codes for the BUF functions. */
/* Function codes. */
-# define BUF_F_BUF_MEMDUP 103
# define BUF_F_BUF_MEM_GROW 100
# define BUF_F_BUF_MEM_GROW_CLEAN 105
# define BUF_F_BUF_MEM_NEW 101
-# define BUF_F_BUF_STRDUP 102
-# define BUF_F_BUF_STRNDUP 104
/* Reason codes. */
# define MemCheck_off() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE)
# define is_MemCheck_on() CRYPTO_is_mem_check_on()
-# define OPENSSL_malloc(num) CRYPTO_malloc((int)num,__FILE__,__LINE__)
-# define OPENSSL_zalloc(num) CRYPTO_zalloc((int)num,__FILE__,__LINE__)
-# define OPENSSL_strdup(str) CRYPTO_strdup((str),__FILE__,__LINE__)
+# define OPENSSL_malloc(num) CRYPTO_malloc((int)num, __FILE__, __LINE__)
+# define OPENSSL_zalloc(num) CRYPTO_zalloc((int)num, __FILE__, __LINE__)
+# define OPENSSL_memdup(str, s) CRYPTO_memdup((str), s, __FILE__, __LINE__)
+# define OPENSSL_strdup(str) CRYPTO_strdup((str), __FILE__, __LINE__)
+# define OPENSSL_strndup(str, s) CRYPTO_strndup((str), (s), __FILE__, __LINE__)
# define OPENSSL_realloc(addr,num) \
- CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__)
+ CRYPTO_realloc((char *)addr, (int)num, __FILE__, __LINE__)
# define OPENSSL_realloc_clean(addr,old_num,num) \
- CRYPTO_realloc_clean(addr,old_num,num,__FILE__,__LINE__)
+ CRYPTO_realloc_clean(addr, old_num, num, __FILE__, __LINE__)
# define OPENSSL_remalloc(addr,num) \
- CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__)
+ CRYPTO_remalloc((char **)addr, (int)num, __FILE__, __LINE__)
# define OPENSSL_clear_free(addr, num) CRYPTO_clear_free(addr, num)
# define OPENSSL_free(addr) CRYPTO_free(addr)
+size_t OPENSSL_strlcpy(char *dst, const char *src, size_t siz);
+size_t OPENSSL_strlcpy(char *dst, const char *src, size_t siz);
+size_t OPENSSL_strlcat(char *dst, const char *src, size_t siz);
+size_t OPENSSL_strnlen(const char *str, size_t maxlen);
+
# define OPENSSL_MALLOC_MAX_NELEMS(type) (((1U<<(sizeof(int)*8-1))-1)/sizeof(type))
unsigned long OpenSSL_version_num(void);
void *CRYPTO_malloc(int num, const char *file, int line);
void *CRYPTO_zalloc(int num, const char *file, int line);
+void *CRYPTO_memdup(const void *str, size_t siz, const char *file, int line);
char *CRYPTO_strdup(const char *str, const char *file, int line);
+char *CRYPTO_strndup(const char *str, size_t s, const char *file, int line);
void CRYPTO_free(void *ptr);
void CRYPTO_clear_free(void *ptr, size_t num);
void *CRYPTO_realloc(void *addr, int num, const char *file, int line);
# define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX 100
# define CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID 103
# define CRYPTO_F_CRYPTO_GET_NEW_LOCKID 101
+# define CRYPTO_F_CRYPTO_MEMDUP 115
# define CRYPTO_F_CRYPTO_NEW_EX_DATA 112
# define CRYPTO_F_CRYPTO_SET_EX_DATA 102
# define CRYPTO_F_DEF_ADD_INDEX 104
if (length == 0)
return 1;
- *data = BUF_memdup(pkt->curr, length);
-
+ *data = OPENSSL_memdup(pkt->curr, length);
if (*data == NULL)
return 0;
OPENSSL_free(*data);
/* This will succeed on an empty packet, unless pkt->curr == NULL. */
- *data = BUF_strndup((const char*)pkt->curr, PACKET_remaining(pkt));
+ *data = OPENSSL_strndup((const char*)pkt->curr, PACKET_remaining(pkt));
return (*data != NULL);
}
#ifndef OPENSSL_NO_SRP
static char *srp_password_from_info_cb(SSL *s, void *arg)
{
- return BUF_strdup(s->srp_ctx.info);
+ return OPENSSL_strdup(s->srp_ctx.info);
}
#endif
SSLerr(SSL_F_SSL3_CTRL, SSL_R_SSL3_EXT_INVALID_SERVERNAME);
return 0;
}
- if ((s->tlsext_hostname = BUF_strdup((char *)parg)) == NULL) {
+ if ((s->tlsext_hostname = OPENSSL_strdup((char *)parg)) == NULL) {
SSLerr(SSL_F_SSL3_CTRL, ERR_R_INTERNAL_ERROR);
return 0;
}
SSLerr(SSL_F_SSL3_CTX_CTRL, SSL_R_INVALID_SRP_USERNAME);
return 0;
}
- if ((ctx->srp_ctx.login = BUF_strdup((char *)parg)) == NULL) {
+ if ((ctx->srp_ctx.login = OPENSSL_strdup((char *)parg)) == NULL) {
SSLerr(SSL_F_SSL3_CTX_CTRL, ERR_R_INTERNAL_ERROR);
return 0;
}
/* Utility functions for d2i_SSL_SESSION */
-/* BUF_strndup an OCTET STRING */
+/* OPENSSL_strndup an OCTET STRING */
static int ssl_session_strndup(char **pdst, ASN1_OCTET_STRING *src)
{
*pdst = NULL;
if (src == NULL)
return 1;
- *pdst = BUF_strndup((char *)src->data, src->length);
+ *pdst = OPENSSL_strndup((char *)src->data, src->length);
if (*pdst == NULL)
return 0;
return 1;
goto err;
#ifndef OPENSSL_NO_PSK
if (cert->psk_identity_hint) {
- ret->psk_identity_hint = BUF_strdup(cert->psk_identity_hint);
+ ret->psk_identity_hint = OPENSSL_strdup(cert->psk_identity_hint);
if (ret->psk_identity_hint == NULL)
goto err;
}
if (rv > 0 && c && cctx->flags & SSL_CONF_FLAG_REQUIRE_PRIVATE) {
char **pfilename = &cctx->cert_filename[c->key - c->pkeys];
OPENSSL_free(*pfilename);
- *pfilename = BUF_strdup(value);
+ *pfilename = OPENSSL_strdup(value);
if (!*pfilename)
rv = 0;
}
{
char *tmp = NULL;
if (pre) {
- tmp = BUF_strdup(pre);
+ tmp = OPENSSL_strdup(pre);
if (tmp == NULL)
return 0;
}
# ifndef OPENSSL_NO_EC
if (ctx->tlsext_ecpointformatlist) {
s->tlsext_ecpointformatlist =
- BUF_memdup(ctx->tlsext_ecpointformatlist,
- ctx->tlsext_ecpointformatlist_length);
+ OPENSSL_memdup(ctx->tlsext_ecpointformatlist,
+ ctx->tlsext_ecpointformatlist_length);
if (!s->tlsext_ecpointformatlist)
goto err;
s->tlsext_ecpointformatlist_length =
}
if (ctx->tlsext_ellipticcurvelist) {
s->tlsext_ellipticcurvelist =
- BUF_memdup(ctx->tlsext_ellipticcurvelist,
- ctx->tlsext_ellipticcurvelist_length);
+ OPENSSL_memdup(ctx->tlsext_ellipticcurvelist,
+ ctx->tlsext_ellipticcurvelist_length);
if (!s->tlsext_ellipticcurvelist)
goto err;
s->tlsext_ellipticcurvelist_length =
}
OPENSSL_free(ctx->cert->psk_identity_hint);
if (identity_hint != NULL) {
- ctx->cert->psk_identity_hint = BUF_strdup(identity_hint);
+ ctx->cert->psk_identity_hint = OPENSSL_strdup(identity_hint);
if (ctx->cert->psk_identity_hint == NULL)
return 0;
} else
}
OPENSSL_free(s->cert->psk_identity_hint);
if (identity_hint != NULL) {
- s->cert->psk_identity_hint = BUF_strdup(identity_hint);
+ s->cert->psk_identity_hint = OPENSSL_strdup(identity_hint);
if (s->cert->psk_identity_hint == NULL)
return 0;
} else
#ifndef OPENSSL_NO_PSK
if (src->psk_identity_hint) {
- dest->psk_identity_hint = BUF_strdup(src->psk_identity_hint);
+ dest->psk_identity_hint = OPENSSL_strdup(src->psk_identity_hint);
if (dest->psk_identity_hint == NULL) {
goto err;
}
}
if (src->psk_identity) {
- dest->psk_identity = BUF_strdup(src->psk_identity);
+ dest->psk_identity = OPENSSL_strdup(src->psk_identity);
if (dest->psk_identity == NULL) {
goto err;
}
}
if (src->tlsext_hostname) {
- dest->tlsext_hostname = BUF_strdup(src->tlsext_hostname);
+ dest->tlsext_hostname = OPENSSL_strdup(src->tlsext_hostname);
if (dest->tlsext_hostname == NULL) {
goto err;
}
#ifndef OPENSSL_NO_EC
if (src->tlsext_ecpointformatlist) {
dest->tlsext_ecpointformatlist =
- BUF_memdup(src->tlsext_ecpointformatlist,
+ OPENSSL_memdup(src->tlsext_ecpointformatlist,
src->tlsext_ecpointformatlist_length);
if (dest->tlsext_ecpointformatlist == NULL)
goto err;
}
if (src->tlsext_ellipticcurvelist) {
dest->tlsext_ellipticcurvelist =
- BUF_memdup(src->tlsext_ellipticcurvelist,
+ OPENSSL_memdup(src->tlsext_ellipticcurvelist,
src->tlsext_ellipticcurvelist_length);
if (dest->tlsext_ellipticcurvelist == NULL)
goto err;
#endif
if (ticket != 0) {
- dest->tlsext_tick = BUF_memdup(src->tlsext_tick, src->tlsext_ticklen);
+ dest->tlsext_tick = OPENSSL_memdup(src->tlsext_tick, src->tlsext_ticklen);
if(dest->tlsext_tick == NULL)
goto err;
} else {
#ifndef OPENSSL_NO_SRP
if (src->srp_username) {
- dest->srp_username = BUF_strdup(src->srp_username);
+ dest->srp_username = OPENSSL_strdup(src->srp_username);
if (dest->srp_username == NULL) {
goto err;
}
sess_id_done:
if (s->tlsext_hostname) {
- ss->tlsext_hostname = BUF_strdup(s->tlsext_hostname);
+ ss->tlsext_hostname = OPENSSL_strdup(s->tlsext_hostname);
if (ss->tlsext_hostname == NULL) {
SSLerr(SSL_F_SSL_GET_NEW_SESSION, ERR_R_INTERNAL_ERROR);
SSL_SESSION_free(ss);
SSL_R_PSK_IDENTITY_NOT_FOUND);
goto psk_err;
}
-
OPENSSL_free(s->s3->tmp.psk);
- s->s3->tmp.psk = BUF_memdup(psk, psklen);
+ s->s3->tmp.psk = OPENSSL_memdup(psk, psklen);
OPENSSL_cleanse(psk, psklen);
if (s->s3->tmp.psk == NULL) {
}
s->s3->tmp.psklen = psklen;
-
identitylen = strlen(identity);
if (identitylen > PSK_MAX_IDENTITY_LEN) {
SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE,
goto psk_err;
}
OPENSSL_free(s->session->psk_identity);
- s->session->psk_identity = BUF_strdup(identity);
+ s->session->psk_identity = OPENSSL_strdup(identity);
if (s->session->psk_identity == NULL) {
OPENSSL_cleanse(identity, sizeof(identity));
goto memerr;
goto err;
}
OPENSSL_free(s->session->srp_username);
- s->session->srp_username = BUF_strdup(s->srp_ctx.login);
+ s->session->srp_username = OPENSSL_strdup(s->srp_ctx.login);
if (s->session->srp_username == NULL) {
SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE,
ERR_R_MALLOC_FAILURE);
}
OPENSSL_free(s->s3->tmp.psk);
- s->s3->tmp.psk = BUF_memdup(psk, psklen);
+ s->s3->tmp.psk = OPENSSL_memdup(psk, psklen);
OPENSSL_cleanse(psk, psklen);
if (s->s3->tmp.psk == NULL) {
goto f_err;
}
OPENSSL_free(s->session->srp_username);
- s->session->srp_username = BUF_strdup(s->srp_ctx.login);
+ s->session->srp_username = OPENSSL_strdup(s->srp_ctx.login);
if (s->session->srp_username == NULL) {
SSLerr(SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE);
goto err;
{
if (src->meths_count) {
dst->meths =
- BUF_memdup(src->meths,
+ OPENSSL_memdup(src->meths,
sizeof(custom_ext_method) * src->meths_count);
if (dst->meths == NULL)
return 0;
if (!s->hit && tlsext_servername == 1) {
if (s->tlsext_hostname) {
if (s->session->tlsext_hostname == NULL) {
- s->session->tlsext_hostname = BUF_strdup(s->tlsext_hostname);
+ s->session->tlsext_hostname = OPENSSL_strdup(s->tlsext_hostname);
if (!s->session->tlsext_hostname) {
*al = SSL_AD_UNRECOGNIZED_NAME;
return 0;
goto err;
}
if ((ctx->srp_ctx.login != NULL) &&
- ((s->srp_ctx.login = BUF_strdup(ctx->srp_ctx.login)) == NULL)) {
+ ((s->srp_ctx.login = OPENSSL_strdup(ctx->srp_ctx.login)) == NULL)) {
SSLerr(SSL_F_SSL_SRP_CTX_INIT, ERR_R_INTERNAL_ERROR);
goto err;
}
q = p + strlen(p);
if (!p)
- program = BUF_strdup("(unknown)");
+ program = OPENSSL_strdup("(unknown)");
else {
program = OPENSSL_malloc((q - p) + 1);
strncpy(program, p, q - p);
printf("About to beef up the engine-type list\n");
for (loop = 0; loop < 512; loop++) {
sprintf(buf, "id%i", loop);
- id = BUF_strdup(buf);
+ id = OPENSSL_strdup(buf);
sprintf(buf, "Fake engine type %i", loop);
- name = BUF_strdup(buf);
+ name = OPENSSL_strdup(buf);
if (((block[loop] = ENGINE_new()) == NULL) ||
!ENGINE_set_id(block[loop], id) ||
!ENGINE_set_name(block[loop], name)) {
key = OPENSSL_malloc(sizeof(*key));
if (!key)
return 0;
- key->name = BUF_strdup(value);
+ key->name = OPENSSL_strdup(value);
key->key = pk;
key->next = *lst;
*lst = key;
fprintf(stderr, "Line %d: multiple result lines\n", t->line);
return 0;
}
- t->expected_err = BUF_strdup(value);
+ t->expected_err = OPENSSL_strdup(value);
if (!t->expected_err)
return 0;
} else {
}
/* The result printing code expects a non-NULL buffer. */
- t->out_expected = BUF_memdup(expected, expected_len ? expected_len : 1);
+ t->out_expected = OPENSSL_memdup(expected, expected_len ? expected_len : 1);
t->out_expected_len = expected_len;
- t->out_received = BUF_memdup(received, received_len ? received_len : 1);
+ t->out_received = OPENSSL_memdup(received, received_len ? received_len : 1);
t->out_received_len = received_len;
if (t->out_expected == NULL || t->out_received == NULL) {
fprintf(stderr, "Memory allocation error!\n");
CRYPTO_cleanup_all_ex_data();
ERR_remove_thread_state(NULL);
ERR_free_strings();
+#ifdef CRYPTO_MDEBUG
CRYPTO_mem_leaks_fp(stderr);
+#endif
if (t.errors)
return 1;
return 0;
if (strcmp(keyword, "Key") == 0)
return test_bin(value, &mdata->key, &mdata->key_len);
if (strcmp(keyword, "Algorithm") == 0) {
- mdata->alg = BUF_strdup(value);
+ mdata->alg = OPENSSL_strdup(value);
if (!mdata->alg)
return 0;
return 1;
edata->encoding = BASE64_VALID_ENCODING;
} else if (strcmp(encoding, "invalid") == 0) {
edata->encoding = BASE64_INVALID_ENCODING;
- t->expected_err = BUF_strdup("DECODE_ERROR");
+ t->expected_err = OPENSSL_strdup("DECODE_ERROR");
if (t->expected_err == NULL)
return 0;
} else {
BN_free(m);
BN_CTX_free(ctx);
ERR_remove_thread_state(NULL);
+#ifdef CRYPTO_MDEBUG
CRYPTO_mem_leaks(out);
+#endif
BIO_free(out);
printf("\n");
result = 1;
} else {
char *actual_payload =
- BUF_strndup((const char *)p, actual_payload_len);
+ OPENSSL_strndup((const char *)p, actual_payload_len);
if (strcmp(actual_payload, fixture.expected_return_payload) != 0) {
printf
("%s failed:\n expected payload: \"%s\"\n received: \"%s\"\n",
static char *ssl_give_srp_client_pwd_cb(SSL *s, void *arg)
{
SRP_CLIENT_ARG *srp_client_arg = (SRP_CLIENT_ARG *)arg;
- return BUF_strdup((char *)srp_client_arg->srppassin);
+ return OPENSSL_strdup((char *)srp_client_arg->srppassin);
}
/* SRP server */
BUF_MEM_free 167 1_1_0 EXIST::FUNCTION:
BUF_MEM_grow 168 1_1_0 EXIST::FUNCTION:
BUF_MEM_new 169 1_1_0 EXIST::FUNCTION:
-BUF_strdup 170 1_1_0 EXIST::FUNCTION:
+BUF_strdup 170 1_1_0 NOEXIST::FUNCTION:
CONF_free 171 1_1_0 EXIST::FUNCTION:
CONF_get_number 172 1_1_0 EXIST::FUNCTION:
CONF_get_section 173 1_1_0 EXIST::FUNCTION:
ENGINE_up_ref 3238 1_1_0 EXIST::FUNCTION:ENGINE
BUF_MEM_grow_clean 3239 1_1_0 EXIST::FUNCTION:
CRYPTO_realloc_clean 3240 1_1_0 EXIST::FUNCTION:
-BUF_strlcat 3241 1_1_0 EXIST::FUNCTION:
+BUF_strlcat 3241 1_1_0 NOEXIST::FUNCTION:
BIO_indent 3242 1_1_0 EXIST::FUNCTION:
-BUF_strlcpy 3243 1_1_0 EXIST::FUNCTION:
+BUF_strlcpy 3243 1_1_0 NOEXIST::FUNCTION:
OpenSSLDie 3244 1_1_0 EXIST::FUNCTION:
OPENSSL_cleanse 3245 1_1_0 EXIST::FUNCTION:
ENGINE_setup_bsd_cryptodev 3246 1_1_0 EXIST:__FreeBSD__:FUNCTION:ENGINE
STORE_method_set_delete_function 3486 1_1_0 NOEXIST::FUNCTION:
STORE_list_certificate_next 3487 1_1_0 NOEXIST::FUNCTION:
ASN1_generate_nconf 3488 1_1_0 EXIST::FUNCTION:
-BUF_memdup 3489 1_1_0 EXIST::FUNCTION:
+BUF_memdup 3489 1_1_0 NOEXIST::FUNCTION:
BN_GF2m_mod_mul 3490 1_1_0 EXIST::FUNCTION:EC2M
STORE_meth_get_list_next_fn 3491 1_1_0 NOEXIST::FUNCTION:
STORE_method_get_list_next_function 3491 1_1_0 NOEXIST::FUNCTION:
SHA224 3510 1_1_0 EXIST::FUNCTION:
BIO_dump_indent_fp 3511 1_1_0 EXIST::FUNCTION:STDIO
EC_KEY_set_group 3512 1_1_0 EXIST::FUNCTION:EC
-BUF_strndup 3513 1_1_0 EXIST::FUNCTION:
+BUF_strndup 3513 1_1_0 NOEXIST::FUNCTION:
STORE_list_certificate_start 3514 1_1_0 NOEXIST::FUNCTION:
BN_GF2m_mod 3515 1_1_0 EXIST::FUNCTION:EC2M
X509_REQ_check_private_key 3516 1_1_0 EXIST::FUNCTION:
X509V3_EXT_free 4763 1_1_0 NOEXIST::FUNCTION:
BIO_hex_string 4764 1_1_0 EXIST::FUNCTION:
X509_VERIFY_PARAM_set_hostflags 4765 1_1_0 EXIST::FUNCTION:
-BUF_strnlen 4766 1_1_0 EXIST::FUNCTION:
+BUF_strnlen 4766 1_1_0 NOEXIST::FUNCTION:
X509_VERIFY_PARAM_get0_peername 4767 1_1_0 EXIST::FUNCTION:
ECDSA_METHOD_set_app_data 4768 1_1_0 NOEXIST::FUNCTION:
sk_deep_copy 4769 1_1_0 EXIST::FUNCTION:
EC_POINT_point2buf 5105 1_1_0 EXIST::FUNCTION:EC
EC_KEY_key2buf 5106 1_1_0 EXIST::FUNCTION:EC
EC_KEY_oct2key 5107 1_1_0 EXIST::FUNCTION:EC
+OPENSSL_strlcpy 5108 1_1_0 EXIST::FUNCTION:
+OPENSSL_strnlen 5109 1_1_0 EXIST::FUNCTION:
+OPENSSL_strlcat 5110 1_1_0 EXIST::FUNCTION:
+OPENSSL_memdup 5111 1_1_0 NOEXIST::FUNCTION:
+CRYPTO_memdup 5112 1_1_0 EXIST::FUNCTION:
+CRYPTO_strndup 5113 1_1_0 EXIST::FUNCTION: