irontec / sngrep

Ncurses SIP Messages flow viewer
GNU General Public License v3.0
1k stars 189 forks source link

openbsd warnings during compiling #79

Open jungle-boogie opened 8 years ago

jungle-boogie commented 8 years ago

Hello,

Compiling sngrep on openbsd 5.9 beta generates these warnings:

i_filter.o ui_save.o  ui_msg_diff.o ui_column_select.o  ui_settings.o  -lmenu -lform -lpanel -lncurses -lpcap -lpthread 
capture.o: In function `is_local_address_str':
/home/sean/bin/sngrep/src/capture.c:1149: warning: warning: strcpy() is almost always misused, please use strlcpy()
ui_manager.o: In function `dialog_progress_run':
/home/sean/bin/sngrep/src/ui_manager.c:710: warning: warning: vsprintf() is often misused, please use vsnprintf()
ui_call_flow.o: In function `call_flow_draw':
/home/sean/bin/sngrep/src/ui_call_flow.c:177: warning: warning: strcat() is almost always misused, please use strlcat()
sip.o: In function `sip_address_port_format':
/home/sean/bin/sngrep/src/sip.c:739: warning: warning: sprintf() is often misused, please use snprintf()

Here's the man page on the preferred openBSD choices of strlcpy and strlcat:

http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man3/strlcat.3?query=strlcat

For vsnprintf and snprintf:

www.openbsd.org/cgi-bin/man.cgi?query=vsnprintf

Kaian commented 8 years ago

Hi @jungle-boogie

I have tested this and it requires to change all strcpy, strcat and strprintf calls in the code. After fixing the lines you reported it complains about other lines.

It seems the 'n' versions (strncpy, strncat, and so) of those functions doesn't make any waring and are more compatible with other OS.

This change affects more lines than expected so I'll do it when I have more spare time 0:) If somehow this cause crashes in sngrep, just let me know to fix it ASAP.

Thanks for reporting!!