Hi All,
Mine is an iOS application (xcode 4.5.2 and iOS 6.1) I make use of a 3rd party library which is written in .C file.
There in one of the methods named lookup_txt, the DNS error "kDNSServiceErr_Timeout = -65568" which is an enum is formatted into a string using sprintf.
Found that this formatting code is crashing occasionally. Not sure why.
Below is the extract from apple's crash dump.
Found that sprintf is a macro for __sprintf_chk which appears in the callstack above and also found in _stdio.h.
Can somebody help me out of the possible reason why this sprintf could be crashing?.
Thanks in advance for the help.
Mine is an iOS application (xcode 4.5.2 and iOS 6.1) I make use of a 3rd party library which is written in .C file.
There in one of the methods named lookup_txt, the DNS error "kDNSServiceErr_Timeout = -65568" which is an enum is formatted into a string using sprintf.
Found that this formatting code is crashing occasionally. Not sure why.
Code:
char *response = NULL;
signed int timeout_error_code = kDNSServiceErr_Timeout;
response = (char*)malloc(6);
sprintf(response, "%d", timeout_error_code); <----This line crashes occasionally.
Below is the extract from apple's crash dump.
Code:
Thread 7 Crashed:
0 libsystem_kernel.dylib 0x31912350 __pthread_kill + 8
1 libsystem_c.dylib 0x30ebe11e pthread_kill + 54
2 libsystem_c.dylib 0x30efa9f2 __abort + 90
3 libsystem_c.dylib 0x30ec00f6 __chk_fail + 26
4 libsystem_c.dylib 0x30ec019e __sprintf_chk + 54
5 MyApp 0x0028724a lookup_txt (lookup_sd.c:206)
Found that sprintf is a macro for __sprintf_chk which appears in the callstack above and also found in _stdio.h.
Code:
#define sprintf(str, ...) \
__builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
Can somebody help me out of the possible reason why this sprintf could be crashing?.
Thanks in advance for the help.