strange crash in pjsip

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi!

I encounter a crash in pjsua_acc.c: pjsua_acc_create_uac_contact() 
function during:
contact->slen = pj_ansi_snprintf(contact->ptr, PJSIP_MAX_URL_SIZE,
	     "%.*s%s<%s:%.*s%s%s%.*s%s:%d%s%.*s>%.*s",
	     (int)acc->display.slen,
	     acc->display.ptr,
	     (acc->display.slen?" " : ""),
	     ......

When the account is configured without a user name (display name), then 
acc->display.slen will be 0 and acc->display.ptr will be uninitialized.

When I build pjproject/QjSimple with an old mingw release (gcc3.4.5) 
then everything is fine, but if I build pjproject/QjSimple with mingw 
included in QtSDK2009.05 (gcc4.4.0) I get a segfault in 
c:\windows\system32\msvcrt.dll:strlen when creating the contact header.

Questions:
Is it allowed to call snprintf with an uninitialized pointer?
Why does crash behavior depend on the used compiler? Isn't snprintf a 
Windows function?
When using gcc4.4.0 - why is strlen called although %.*s is specified?

Anyway, solution would be to:

PJ_DEF(void) pjsip_name_addr_init(pjsip_name_addr *name)
{
     name->vptr = &name_addr_vptr;
     name->uri = NULL;
     name->display.slen = 0;
     name->display.ptr = NULL;
}

regards
Klaus



[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux