aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2013-12-04 19:44:34 +0100
committerSverker Eriksson <[email protected]>2013-12-04 19:44:34 +0100
commit573426e3fa7788060a228e08e0b7db7defc3aec5 (patch)
tree82095c62506346fb0bad4d39a3f5f312b0cf9d28 /lib
parent8c22a73b7308a76335699e52cefda7a2ccafdaac (diff)
parent94576fd805c9a88cb6fecf27215ec5d4fb86f278 (diff)
downloadotp-573426e3fa7788060a228e08e0b7db7defc3aec5.tar.gz
otp-573426e3fa7788060a228e08e0b7db7defc3aec5.tar.bz2
otp-573426e3fa7788060a228e08e0b7db7defc3aec5.zip
Merge branch 'sverk/crypto-strrchr-bug'
* sverk/crypto-strrchr-bug: crypto: Fix bug in change_basename
Diffstat (limited to 'lib')
-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;