EldoS | Feel safer!

Software components for data protection, secure storage and transfer

IOS eventCallback

Also by EldoS: SecureBlackbox
200+ components and classes for digital security, signing, encryption and secure networking.
#20095
Posted: 05/09/2012 01:30:26
by zheng kai (Basic support level)
Joined: 04/18/2012
Posts: 2

I have some trouble in "MsgConnect evaluation,C++ package for IOS".
if i use code :

Code
void eventCallback(void* resv, void* sender, MCMessage& message, bool& handled)
{
    
    NSString *str = @"1231...1111";
    NSLog(@"length str%d",[str length]);
    
  
    const char *cCallBack = [str UTF8String];
    int nCallBack = strlen(cCallBack);
    memcpy(message.Data, cCallBack, nCallBack+1);
    message.DataSize = nCallBack+1;
    
    handled = true;    
}


The programe crashed.
detail in sales@eldos.com
#20096
Posted: 05/09/2012 01:53:34
by Eugene Mayevski (EldoS Corp.)

Please read the support policy before requesting assistance.

1) We don't provide support to users from China who don't have a license.
2) sales e-mail is not used for support. Your e-mail if you sent it went to spam anyway.

I am replying here just because other users might be interested in the problem.

In your code you don't allocate memory and copy the data into message.Data which doesn't reference a valid buffer.


Sincerely yours
Eugene Mayevski
#20097
Posted: 05/09/2012 03:17:21
by zheng kai (Basic support level)
Joined: 04/18/2012
Posts: 2

1. I have the license, but IOS product does not support it.
2.i have code:
Code
    unsigned int size = nCallBack+1;
    printf("*********** data ***********\n");
    char *c;
    int counter=0;
    int i;
    for (i=2; i<size+2; i++) {
        c = (char *)message.Data+i;
        if ( *c != ' ' ) {
            printf("%c", *c);
            counter++;
        }
        else {
            printf("NULL ");
        }
     }

It works fine.
2. If the feedback string length within 20 chars, it works fine.
#20098
Posted: 05/09/2012 03:45:03
by Eugene Mayevski (EldoS Corp.)

If you have a license, please assign the license ticket to your user account before we continue. The ticket itself and the procedure of it's use are specified in the registration e-mail that was sent to you upon license purchase.


Sincerely yours
Eugene Mayevski
#20099
Posted: 05/09/2012 03:48:29
by Eugene Mayevski (EldoS Corp.)

When you send some data, Message.Data will have a reference to received data block. The buffer size will be equal to the size of data. Consequently if you put larger piece of data to that block, you will corrupt the memory that follows the allocated block. This is why your application crashes.

On a side note please use "code" markup (see the CODE button above the message edit field) to mark your code and make it more readable. I've done this for you manually in above messages.


Sincerely yours
Eugene Mayevski
Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages

Reply

Statistics

Topic viewed 3759 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!