Browse Source

Rename some BUF_xxx to OPENSSL_xxx

Rename BUF_{strdup,strlcat,strlcpy,memdup,strndup,strnlen}
to OPENSSL_{strdup,strlcat,strlcpy,memdup,strndup,strnlen}
Add #define's for the old names.
Add CRYPTO_{memdup,strndup}, called by OPENSSL_{memdup,strndup} macros.

Reviewed-by: Tim Hudson <tjh@openssl.org>
master
Rich Salz 7 years ago
committed by Rich Salz
parent
commit
7644a9aef8
86 changed files with 362 additions and 460 deletions
  1. +5
    -5
      apps/apps.c
  2. +13
    -30
      apps/ca.c
  3. +1
    -1
      apps/cms.c
  4. +2
    -2
      apps/engine.c
  5. +1
    -1
      apps/ocsp.c
  6. +1
    -1
      apps/openssl.c
  7. +3
    -3
      apps/passwd.c
  8. +2
    -2
      apps/pkcs12.c
  9. +2
    -2
      apps/rehash.c
  10. +9
    -9
      apps/req.c
  11. +1
    -1
      apps/s_server.c
  12. +1
    -1
      apps/s_socket.c
  13. +6
    -6
      apps/srp.c
  14. +3
    -3
      apps/x509.c
  15. +7
    -2
      crypto/Makefile
  16. +3
    -3
      crypto/asn1/a_time.c
  17. +2
    -2
      crypto/asn1/ameth_lib.c
  18. +4
    -4
      crypto/asn1/asn_mime.c
  19. +7
    -7
      crypto/bio/b_dump.c
  20. +1
    -1
      crypto/bio/b_sock.c
  21. +1
    -1
      crypto/bio/bss_acpt.c
  22. +5
    -5
      crypto/bio/bss_conn.c
  23. +5
    -5
      crypto/bio/bss_file.c
  24. +2
    -10
      crypto/buffer/Makefile
  25. +0
    -3
      crypto/buffer/buf_err.c
  26. +0
    -137
      crypto/buffer/buf_str.c
  27. +2
    -2
      crypto/conf/conf_def.c
  28. +7
    -7
      crypto/conf/conf_mod.c
  29. +1
    -0
      crypto/cpt_err.c
  30. +3
    -3
      crypto/dh/dh_ameth.c
  31. +1
    -1
      crypto/dh/dh_pmeth.c
  32. +2
    -2
      crypto/dso/dso_lib.c
  33. +1
    -1
      crypto/ec/ec_pmeth.c
  34. +3
    -3
      crypto/engine/eng_dyn.c
  35. +1
    -1
      crypto/err/err.c
  36. +1
    -1
      crypto/evp/e_chacha20_poly1305.c
  37. +1
    -1
      crypto/evp/evp_pbe.c
  38. +1
    -1
      crypto/lock.c
  39. +0
    -9
      crypto/mem.c
  40. +1
    -1
      crypto/mem_dbg.c
  41. +81
    -0
      crypto/o_str.c
  42. +3
    -3
      crypto/objects/obj_dat.c
  43. +5
    -5
      crypto/ocsp/ocsp_lib.c
  44. +6
    -6
      crypto/pem/pem_lib.c
  45. +4
    -2
      crypto/rand/Makefile
  46. +2
    -2
      crypto/rand/rand_egd.c
  47. +6
    -6
      crypto/rand/randfile.c
  48. +1
    -1
      crypto/rsa/rsa_pmeth.c
  49. +5
    -5
      crypto/srp/srp_vfy.c
  50. +2
    -2
      crypto/store/str_lib.c
  51. +1
    -1
      crypto/store/str_meth.c
  52. +15
    -15
      crypto/ui/ui_lib.c
  53. +1
    -1
      crypto/x509/x509_trs.c
  54. +4
    -4
      crypto/x509/x509_vpm.c
  55. +3
    -3
      crypto/x509v3/v3_addr.c
  56. +1
    -1
      crypto/x509v3/v3_asid.c
  57. +1
    -1
      crypto/x509v3/v3_enum.c
  58. +3
    -3
      crypto/x509v3/v3_info.c
  59. +2
    -2
      crypto/x509v3/v3_purp.c
  60. +7
    -7
      crypto/x509v3/v3_utl.c
  61. +0
    -25
      doc/crypto/buffer.pod
  62. +2
    -2
      engines/ccgost/gost_ctl.c
  63. +3
    -3
      engines/e_capi.c
  64. +1
    -1
      engines/e_chil.c
  65. +1
    -1
      engines/e_ubsec.c
  66. +15
    -20
      include/openssl/buffer.h
  67. +16
    -6
      include/openssl/crypto.h
  68. +2
    -3
      ssl/packet_locl.h
  69. +3
    -3
      ssl/s3_lib.c
  70. +2
    -2
      ssl/ssl_asn1.c
  71. +1
    -1
      ssl/ssl_cert.c
  72. +2
    -2
      ssl/ssl_conf.c
  73. +6
    -6
      ssl/ssl_lib.c
  74. +8
    -8
      ssl/ssl_sess.c
  75. +3
    -5
      ssl/statem/statem_clnt.c
  76. +2
    -2
      ssl/statem/statem_srvr.c
  77. +1
    -1
      ssl/t1_ext.c
  78. +1
    -1
      ssl/t1_lib.c
  79. +1
    -1
      ssl/tls_srp.c
  80. +1
    -1
      test/dummytest.c
  81. +2
    -2
      test/enginetest.c
  82. +8
    -6
      test/evp_test.c
  83. +2
    -0
      test/exptest.c
  84. +1
    -1
      test/heartbeat_test.c
  85. +1
    -1
      test/ssltest.c
  86. +12
    -6
      util/libeay.num

+ 5
- 5
apps/apps.c View File

@ -432,14 +432,14 @@ static char *app_get_pass(char *arg, int keepbio)
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) {
@ -495,7 +495,7 @@ static char *app_get_pass(char *arg, int keepbio)
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)
@ -1444,7 +1444,7 @@ int save_serial(char *serialfile, char *suffix, BIGNUM *serial,
}
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);
@ -1930,7 +1930,7 @@ int pkey_ctrl_string(EVP_PKEY_CTX *ctx, char *value)
{
int rv;
char *stmp, *vtmp = NULL;
stmp = BUF_strdup(value);
stmp = OPENSSL_strdup(value);
if (!stmp)
return -1;
vtmp = strchr(stmp, ':');


+ 13
- 30
apps/ca.c View File

@ -1067,7 +1067,7 @@ end_of_options:
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])]);
@ -1679,7 +1679,7 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
}
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) {
@ -1898,17 +1898,13 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
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) ||
@ -1916,9 +1912,6 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
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++) {
@ -2118,7 +2111,7 @@ static int do_revoke(X509 *x509, CA_DB *db, int type, char *value)
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);
@ -2137,23 +2130,13 @@ static int do_revoke(X509 *x509, CA_DB *db, int type, char *value)
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++) {
@ -2428,14 +2411,14 @@ char *make_revocation_str(int rev_type, char *rev_arg)
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;
@ -2553,7 +2536,7 @@ int unpack_revinfo(ASN1_TIME **prevtm, int *preason, ASN1_OBJECT **phold,
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;


+ 1
- 1
apps/cms.c View File

@ -902,7 +902,7 @@ int cms_main(int argc, char **argv)
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,


+ 2
- 2
apps/engine.c View File

@ -109,8 +109,8 @@ static int append_buf(char **buf, const char *s, int *size, int step)
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;
}


+ 1
- 1
apps/ocsp.c View File

@ -1007,7 +1007,7 @@ static char **lookup_serial(CA_DB *db, ASN1_INTEGER *ser)
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;


+ 1
- 1
apps/openssl.c View File

@ -218,7 +218,7 @@ static char *make_config_name()
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;


+ 3
- 3
apps/passwd.c View File

@ -314,9 +314,9 @@ static char *md5crypt(const char *passwd, const char *magic, const char *salt)
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);


+ 2
- 2
apps/pkcs12.c View File

@ -484,7 +484,7 @@ int pkcs12_main(int argc, char **argv)
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);
@ -542,7 +542,7 @@ int pkcs12_main(int argc, char **argv)
}
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",


+ 2
- 2
apps/rehash.c View File

@ -175,7 +175,7 @@ static int add_entry(enum Type type, unsigned int hash, const char *filename,
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)
@ -468,7 +468,7 @@ int rehash_main(int argc, char **argv)
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);


+ 9
- 9
apps/req.c View File

@ -1189,8 +1189,8 @@ static int add_DN_object(X509_NAME *n, char *text, const char *def,
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';
@ -1208,8 +1208,8 @@ static int add_DN_object(X509_NAME *n, char *text, const char *def,
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);
@ -1248,8 +1248,8 @@ static int add_attribute_object(X509_REQ *req, char *text, const char *def,
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';
@ -1267,8 +1267,8 @@ static int add_attribute_object(X509_REQ *req, char *text, const char *def,
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);
@ -1428,7 +1428,7 @@ static EVP_PKEY_CTX *set_keygen_ctx(const char *gstr,
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);


+ 1
- 1
apps/s_server.c View File

@ -3165,7 +3165,7 @@ static int add_session(SSL *ssl, SSL_SESSION *session)
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");


+ 1
- 1
apps/s_socket.c View File

@ -560,7 +560,7 @@ static int do_accept(int acc_sock, int *sock, char **host)
/* 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) {


+ 6
- 6
apps/srp.c View File

@ -486,9 +486,9 @@ int srp_main(int argc, char **argv)
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)
@ -496,7 +496,7 @@ int srp_main(int argc, char **argv)
|| (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]);
@ -571,7 +571,7 @@ int srp_main(int argc, char **argv)
}
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
@ -579,7 +579,7 @@ int srp_main(int argc, char **argv)
|| row[DB_srpverifier] == NULL
|| row[DB_srpsalt] == NULL
|| (userinfo
&& ((row[DB_srpinfo] = BUF_strdup(userinfo))
&& ((row[DB_srpinfo] = OPENSSL_strdup(userinfo))
== NULL)))
goto end;


+ 3
- 3
apps/x509.c View File

@ -949,15 +949,15 @@ static ASN1_INTEGER *x509_load_serial(char *CAfile, char *serialfile,
: (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)


+ 7
- 2
crypto/Makefile View File

@ -202,8 +202,13 @@ o_init.o: ../include/openssl/lhash.h ../include/openssl/opensslconf.h
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


+ 3
- 3
crypto/asn1/a_time.c View File

@ -139,11 +139,11 @@ ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t,
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;
}


+ 2
- 2
crypto/asn1/ameth_lib.c View File

@ -285,13 +285,13 @@ EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_new(int id, int flags,
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;
}


+ 4
- 4
crypto/asn1/asn_mime.c View File

@ -829,7 +829,7 @@ static MIME_HEADER *mime_hdr_new(char *name, char *value)
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;
@ -840,7 +840,7 @@ static MIME_HEADER *mime_hdr_new(char *name, char *value)
}
}
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;
@ -872,7 +872,7 @@ static int mime_hdr_addparam(MIME_HEADER *mhdr, char *name, char *value)
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++) {
@ -884,7 +884,7 @@ static int mime_hdr_addparam(MIME_HEADER *mhdr, char *name, char *value)
}
}
if (value) {
tmpval = BUF_strdup(value);
tmpval = OPENSSL_strdup(value);
if (!tmpval)
goto err;
}


+ 7
- 7
crypto/bio/b_dump.c View File

@ -104,20 +104,20 @@ int BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u),
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;
@ -131,9 +131,9 @@ int BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u),
? 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


+ 1
- 1
crypto/bio/b_sock.c View File

@ -402,7 +402,7 @@ int BIO_get_accept_socket(char *host, int bind_mode)
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;


+ 1
- 1
crypto/bio/bss_acpt.c View File

@ -350,7 +350,7 @@ static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr)
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) {


+ 5
- 5
crypto/bio/bss_conn.c View File

@ -149,7 +149,7 @@ static int conn_state(BIO *b, BIO_CONNECT *c)
break;
}
OPENSSL_free(c->param_port);
c->param_port = BUF_strdup(p);
c->param_port = OPENSSL_strdup(p);
}
}
@ -455,10 +455,10 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
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;
@ -466,14 +466,14 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *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;
}
}


+ 5
- 5
crypto/bio/bss_file.c View File

@ -367,15 +367,15 @@ static long file_ctrl(BIO *b, int cmd, long num, void *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;


+ 2
- 10
crypto/buffer/Makefile View File

@ -15,8 +15,8 @@ CFLAGS= $(INCLUDES) $(CFLAG)
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)
@ -67,14 +67,6 @@ buf_err.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
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


+ 0
- 3
crypto/buffer/buf_err.c View File

@ -70,12 +70,9 @@
# 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}
};


+ 0
- 137
crypto/buffer/buf_str.c View File

@ -1,137 +0,0 @@
/* 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);
}

+ 2
- 2
crypto/conf/conf_def.c View File

@ -223,7 +223,7 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
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;
@ -366,7 +366,7 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
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;


+ 7
- 7
crypto/conf/conf_mod.c View File

@ -286,7 +286,7 @@ static CONF_MODULE *module_add(DSO *dso, const char *name,
return NULL;
tmod->dso = dso;
tmod->name = BUF_strdup(name);
tmod->name = OPENSSL_strdup(name);
tmod->init = ifunc;
tmod->finish = ffunc;
@ -340,8 +340,8 @@ static int module_init(CONF_MODULE *pmod, char *name, char *value,
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)
@ -525,7 +525,7 @@ char *CONF_get1_default_config_file(void)
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
@ -537,11 +537,11 @@ char *CONF_get1_default_config_file(void)
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;
}


+ 1
- 0
crypto/cpt_err.c View File

@ -75,6 +75,7 @@ static ERR_STRING_DATA CRYPTO_str_functs[] = {
{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"},


+ 3
- 3
crypto/dh/dh_ameth.c View File

@ -482,7 +482,7 @@ static int int_dh_param_copy(DH *to, const DH *from, int is_x942)
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;
@ -770,7 +770,7 @@ static int dh_cms_set_shared_info(EVP_PKEY_CTX *pctx, CMS_RecipientInfo *ri)
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;
}
@ -914,7 +914,7 @@ static int dh_cms_encrypt(CMS_RecipientInfo *ri)
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;
}


+ 1
- 1
crypto/dh/dh_pmeth.c View File

@ -134,7 +134,7 @@ static int pkey_dh_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src)
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;


+ 2
- 2
crypto/dso/dso_lib.c View File

@ -353,7 +353,7 @@ int DSO_set_filename(DSO *dso, const char *filename)
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);
@ -402,7 +402,7 @@ char *DSO_convert_filename(DSO *dso, const char *filename)
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);
}


+ 1
- 1
crypto/ec/ec_pmeth.c View File

@ -124,7 +124,7 @@ static int pkey_ec_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src)
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


+ 3
- 3
crypto/engine/eng_dyn.c View File

@ -352,7 +352,7 @@ static int dynamic_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void))
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);
@ -365,7 +365,7 @@ static int dynamic_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void))
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);
@ -392,7 +392,7 @@ static int dynamic_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void))
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;


+ 1
- 1
crypto/err/err.c View File

@ -968,7 +968,7 @@ void ERR_add_error_vdata(int num, va_list args)
}
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);


+ 1
- 1
crypto/evp/e_chacha20_poly1305.c View File

@ -383,7 +383,7 @@ static int chacha20_poly1305_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg,
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;


+ 1
- 1
crypto/evp/evp_pbe.c View File

@ -141,7 +141,7 @@ int EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
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);


+ 1
- 1
crypto/lock.c View File

@ -215,7 +215,7 @@ int CRYPTO_get_new_lockid(char *name)
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);
}


+ 0
- 9
crypto/mem.c View File

@ -321,15 +321,6 @@ void *CRYPTO_zalloc(int num, const char *file, int line)
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;


+ 1
- 1
crypto/mem_dbg.c View File

@ -704,7 +704,7 @@ static void print_leak_doall_arg(const MEM *m, MEM_LEAK *l)
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");


+ 81
- 0
crypto/o_str.c View File

@ -58,7 +58,10 @@
*/
#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) && \
@ -114,3 +117,81 @@ int OPENSSL_memcmp(const void *v1, const void *v2, size_t n)
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);
}

+ 3
- 3
crypto/objects/obj_dat.c View File

@ -484,7 +484,7 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
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;
}
@ -558,7 +558,7 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
*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;
@ -574,7 +574,7 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name)
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;


+ 5
- 5
crypto/ocsp/ocsp_lib.c View File

@ -183,7 +183,7 @@ int OCSP_parse_url(const char *url, char **phost, char **pport, char **ppath,
*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;
@ -217,9 +217,9 @@ int OCSP_parse_url(const char *url, char **phost, char **pport, char **ppath,
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';
}
@ -244,11 +244,11 @@ int OCSP_parse_url(const char *url, char **phost, char **pport, char **ppath,
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;