Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

Hi,

The following line causes the app. to crash:

MEMCPY(b64encodedop, m_sCipherTextSharedSecret, STRLEN(b64encodedop));

b64encodedop and m_sCipherTextSharedSecret are both char *.
What could be the problem?

I also tried MEMMOVE, STRCPY, STRLCPY. But it does the same thing. There is just nothing being copied into m_sCipherTextSharedSecret.

Thanks.

b64encodedop is probably not null terminated.

b64encodedop is probably not null terminated.

max wrote:b64encodedop is probably not null terminated.
I checked and verified that the last byte is null-terminated using a test:
if (m_b64encodedop [outlen] != '\0')
{
outlen++;

else
{
outlen--;

What else can be wrong?
I am doing encryption and get the encrypted string, then I copy it into another string. But nothing is copied into pApp->m_sCipherTextSharedSecret
outlen = STRLEN(m_b64encodedop);
err = ICIPHER_Cipher(m_pICipher, (const byte *)(m_b64encodedop), STRLEN(m_b64encodedop), (byte *)(newstring), &outlen);
outlen = sizeof(newstring);
MEMCPY(pApp->m_sCipherTextSharedSecret, newstring, outlen);
Thanks.

max wrote:b64encodedop is probably not null terminated.
I checked and verified that the last byte is null-terminated using a test:
if (m_b64encodedop [outlen] != '\0')
{
outlen++;

else
{
outlen--;

What else can be wrong?
I am doing encryption and get the encrypted string, then I copy it into another string. But nothing is copied into pApp->m_sCipherTextSharedSecret
outlen = STRLEN(m_b64encodedop);
err = ICIPHER_Cipher(m_pICipher, (const byte *)(m_b64encodedop), STRLEN(m_b64encodedop), (byte *)(newstring), &outlen);
outlen = sizeof(newstring);
MEMCPY(pApp->m_sCipherTextSharedSecret, newstring, outlen);
Thanks.

If you already know the size of what you want copied, why are you using STRLEN? Just use the size directly.
Also, this shouldn't cause a crash, but I think you have your src and dest switched. The destination should be the first argument.

If you already know the size of what you want copied, why are you using STRLEN? Just use the size directly.
Also, this shouldn't cause a crash, but I think you have your src and dest switched. The destination should be the first argument.

I have solved the problem. It has to do with MALLOC bytes for the variable.
Thanks.

I have solved the problem. It has to do with MALLOC bytes for the variable.
Thanks.