glibc vs uClibc and UB issue

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

 



Hi,

PJSip library makes a lot if printf's printing pj_str_t strings. It uses "%.*s" format to print that strings.
Also it process's a lot of URI's, storing their parts into pj_str_t strings.
If some part of URI is absent, ptr remains NULL, slen remains 0.
After that URI is created again from parts, using printf's.
Passing NULL to printf is UB. Some implementations of glibc print nothing, but uClibc, that i use, prints "(null)", although value of length modifier is 0. As I know VS2010 also prints "(null)". OK, It's better than crash.
I was very surprised seeing "(null)" in DisplayName receiving a call from subscriber with empty DisplayName. But this is not the main problem (UB is the big problem).
I can't work with "local account" whose URI is "<sip:1.2.3.4>", because when this URI is printed in Contact header we get "(null)<sip:(null)1.2.3.4>".
When account creates Contact header (pjsua_acc.c - pjsua_acc_create_uas_contact func) the length of DisplayName is checked not to print quotation if DisplayName is empty. Also the length of UserPart is checked not to print "@" if UserPart is empty. But in my case "(null)"s are printed instead of nothing. So the resulting URI is invalid.

I can patch this function myself, but I'm afraid there's a lot of the same things in the library.

---
Alexey Ermoshin
_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

[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