aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crypto/c_src
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2013-12-03 20:26:09 +0100
committerSverker Eriksson <[email protected]>2013-12-03 20:26:09 +0100
commit94576fd805c9a88cb6fecf27215ec5d4fb86f278 (patch)
tree68849c4e000f9e857f438520abdf0702e92bdf94 /lib/crypto/c_src
parente8b80236275858fe1bd71a14c570879373b600f2 (diff)
downloadotp-94576fd805c9a88cb6fecf27215ec5d4fb86f278.tar.gz
otp-94576fd805c9a88cb6fecf27215ec5d4fb86f278.tar.bz2
otp-94576fd805c9a88cb6fecf27215ec5d4fb86f278.zip
crypto: Fix bug in change_basename
strrchr used on non null-terminated string.
Diffstat (limited to 'lib/crypto/c_src')
-rw-r--r--lib/crypto/c_src/crypto.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/crypto/c_src/crypto.c b/lib/crypto/c_src/crypto.c
index 322f08be64..7567a08894 100644
--- a/lib/crypto/c_src/crypto.c
+++ b/lib/crypto/c_src/crypto.c
@@ -548,9 +548,12 @@ static ERL_NIF_TERM atom_onbasis;
#ifdef HAVE_DYNAMIC_CRYPTO_LIB
static int change_basename(ErlNifBinary* bin, char* buf, int bufsz, const char* newfile)
{
- const unsigned char* p = (unsigned char*)strrchr((char*)bin->data, '/');
- int i = (p == NULL) ? 0 : (p+1) - bin->data;
+ int i;
+ for (i = bin->size; i > 0; i--) {
+ if (bin->data[i-1] == '/')
+ break;
+ }
if (i + strlen(newfile) >= bufsz) {
PRINTF_ERR0("CRYPTO: lib name too long");
return 0;