Summary: | ASTERISK-11787: chan_sip.c: realtime_peer function make crash on version 1.4.19 and 1.6.0Beta7.1 | ||
Reporter: | german aracil boned (tecnoxarxa) | Labels: | |
Date Opened: | 2008-04-05 11:38:28 | Date Closed: | 2008-04-07 16:31:58 |
Priority: | Critical | Regression? | No |
Status: | Closed/Complete | Components: | Channels/chan_sip/General |
Versions: | Frequency of Occurrence | ||
Related Issues: | |||
Environment: | Attachments: | ||
Description: | This is my problem (1.4.19): Core was generated by `/usr/sbin/asterisk -f -p -g -c'. Program terminated with signal 11, Segmentation fault. #0 0xb7653a80 in realtime_peer (newpeername=0xbfede360 "Tecnoxarxa0", sin=0x0) at chan_sip.c:2547 2547 if (!(hp = ast_gethostbyname(tmp->value, &ahp)) || (memcmp(&hp->h_addr, &sin->sin_addr, sizeof(hp->h_addr)))) { (gdb) bt #0 0xb7653a80 in realtime_peer (newpeername=0xbfede360 "Tecnoxarxa0", sin=0x0) at chan_sip.c:2547 #1 0xb7654585 in find_peer (peer=0xbfede360 "Tecnoxarxa0", sin=0x0, realtime=1) at chan_sip.c:2676 #2 0xb76967ad in sip_devicestate (data=0xbfede804) at chan_sip.c:15896 #3 0x080a0a5a in ast_device_state (device=0xbfede894 "SIP/Tecnoxarxa0") at devicestate.c:170 #4 0x080d4aa1 in ast_extension_state2 (e=0x84bd618) at pbx.c:1931 ASTERISK-1 0x080d5519 in ast_add_hint (e=0x84bd618) at pbx.c:2209 ASTERISK-2 0x080dc4eb in ast_add_extension2 (con=0x84bd3d0, replace=0, extension=0xbfedfa14 "200", priority=-1, label=0x0, callerid=0x0, application=0x841cb69 "SIP/Tecnoxarxa0", data=0x841cbf0, datad=0xb71c0398 <ast_free>, registrar=0xb71c8363 "pbx_config") at pbx.c:4869 ASTERISK-3 0xb71c75af in pbx_load_config (config_file=0xb71c8353 "extensions.conf") at pbx_config.c:2306 ASTERISK-4 0xb71c811f in pbx_load_module () at pbx_config.c:2453 ASTERISK-5 0xb71c81a6 in load_module () at pbx_config.c:2470 ASTERISK-6 0x080bfd2d in load_resource (resource_name=0x81bdef8 "pbx_config.so", global_symbols_only=0) at loader.c:680 ASTERISK-7 0x080c05d3 in load_modules (preload_only=0) at loader.c:874 ASTERISK-8 0x08072fc1 in main (argc=5, argv=0xbfee0444) at asterisk.c:2965 ASTERISK-9 0xb7df8ea8 in __libc_start_main () from /lib/tls/libc.so.6 ASTERISK-10 0x08057d51 in ?? () at ../sysdeps/i386/elf/start.S:119 This is a 1.4.18.1 version for this funcion working perfectly: static struct sip_peer *realtime_peer(const char *newpeername, struct sockaddr_in *sin) .... if (var) { for (tmp = var; tmp; tmp = tmp->next) { if (!strcasecmp(var->name, "host")) { struct in_addr sin2; struct ast_dnsmgr_entry *dnsmgr = NULL; memset(&sin2, 0, sizeof(sin2)); if ((ast_dnsmgr_lookup(tmp->value, &sin2, &dnsmgr) < 0) || (memcmp(&sin2, &sin->sin_addr, sizeof(sin2)) != 0)) { /* No match */ ast_variables_destroy(var); var = NULL; } break; } } } .... And this is a 1.4.19 version extract: static struct sip_peer *realtime_peer(const char *newpeername, struct sockaddr_in *sin) .... if (var) { for (tmp = var; tmp; tmp = tmp->next) { if (!strcasecmp(tmp->name, "host")) { struct hostent *hp; struct ast_hostent ahp; if (!(hp = ast_gethostbyname(tmp->value, &ahp)) || (memcmp(&hp->h_addr, &sin->sin_addr, sizeof(hp->h_addr)))) { /* No match */ ast_variables_destroy(var); var = NULL; } break; } } } .... I think the problem is this new line: if (!(hp = ast_gethostbyname(tmp->value, &ahp)) || (memcmp(&hp->h_addr, &sin->sin_addr, sizeof(hp->h_addr)))) This is a bug ? What is the best solution ? I was changed this line only: if (!strcasecmp(var->name, "host")) { Prior was: if (!strcasecmp(tmp->name, "host")) { this is an ok solution ? | ||
Comments: | By: Joshua C. Colp (jcolp) 2008-04-05 12:16:28 This is a duplicate of issue 12362. Please follow progress there and try the patch. By: Digium Subversion (svnbot) 2008-04-07 10:12:17 Repository: asterisk Revision: 113012 U branches/1.4/channels/chan_sip.c ------------------------------------------------------------------------ r113012 | jpeeler | 2008-04-07 10:11:51 -0500 (Mon, 07 Apr 2008) | 7 lines (closes issue ASTERISK-11777) (closes issue ASTERISK-11787) Reported by: vinsik Tested by: tecnoxarxa This one line change makes an if inside a for loop (in realtime_peer) check all the ast_variables the loop was intending to test rather than just the first one. ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=113012 By: Digium Subversion (svnbot) 2008-04-07 10:13:32 Repository: asterisk Revision: 113013 _U trunk/ U trunk/channels/chan_sip.c ------------------------------------------------------------------------ r113013 | jpeeler | 2008-04-07 10:13:28 -0500 (Mon, 07 Apr 2008) | 15 lines Merged revisions 113012 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r113012 | jpeeler | 2008-04-07 10:16:44 -0500 (Mon, 07 Apr 2008) | 7 lines (closes issue ASTERISK-11777) (closes issue ASTERISK-11787) Reported by: vinsik Tested by: tecnoxarxa This one line change makes an if inside a for loop (in realtime_peer) check all the ast_variables the loop was intending to test rather than just the first one. ........ ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=113013 By: Digium Subversion (svnbot) 2008-04-07 10:23:41 Repository: asterisk Revision: 113042 _U branches/1.6.0/ U branches/1.6.0/channels/chan_sip.c ------------------------------------------------------------------------ r113042 | jpeeler | 2008-04-07 10:23:41 -0500 (Mon, 07 Apr 2008) | 23 lines Merged revisions 113013 via svnmerge from https://origsvn.digium.com/svn/asterisk/trunk ................ r113013 | jpeeler | 2008-04-07 10:18:10 -0500 (Mon, 07 Apr 2008) | 15 lines Merged revisions 113012 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r113012 | jpeeler | 2008-04-07 10:16:44 -0500 (Mon, 07 Apr 2008) | 7 lines (closes issue ASTERISK-11777) (closes issue ASTERISK-11787) Reported by: vinsik Tested by: tecnoxarxa This one line change makes an if inside a for loop (in realtime_peer) check all the ast_variables the loop was intending to test rather than just the first one. ........ ................ ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=113042 By: Jeff Peeler (jpeeler) 2008-04-07 11:40:14 I only partially fixed the problem, please continue to follow here: http://bugs.digium.com/view.php?id=12362 By: Digium Subversion (svnbot) 2008-04-07 16:31:02 Repository: asterisk Revision: 113241 U trunk/channels/chan_sip.c ------------------------------------------------------------------------ r113241 | jpeeler | 2008-04-07 16:31:01 -0500 (Mon, 07 Apr 2008) | 23 lines Merged revisions 113013 via svnmerge from https://origsvn.digium.com/svn/asterisk/trunk ................ r113013 | jpeeler | 2008-04-07 10:18:10 -0500 (Mon, 07 Apr 2008) | 15 lines Merged revisions 113012 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r113012 | jpeeler | 2008-04-07 10:16:44 -0500 (Mon, 07 Apr 2008) | 7 lines (closes issue ASTERISK-11777) (closes issue ASTERISK-11787) Reported by: vinsik Tested by: tecnoxarxa This one line change makes an if inside a for loop (in realtime_peer) check all the ast_variables the loop was intending to test rather than just the first one. ........ ................ ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=113241 By: Digium Subversion (svnbot) 2008-04-07 16:31:58 Repository: asterisk Revision: 113242 _U branches/1.6.0/ U branches/1.6.0/channels/chan_sip.c ------------------------------------------------------------------------ r113242 | jpeeler | 2008-04-07 16:31:57 -0500 (Mon, 07 Apr 2008) | 31 lines Merged revisions 113241 via svnmerge from https://origsvn.digium.com/svn/asterisk/trunk ................ r113241 | jpeeler | 2008-04-07 16:35:48 -0500 (Mon, 07 Apr 2008) | 23 lines Merged revisions 113013 via svnmerge from https://origsvn.digium.com/svn/asterisk/trunk ................ r113013 | jpeeler | 2008-04-07 10:18:10 -0500 (Mon, 07 Apr 2008) | 15 lines Merged revisions 113012 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r113012 | jpeeler | 2008-04-07 10:16:44 -0500 (Mon, 07 Apr 2008) | 7 lines (closes issue ASTERISK-11777) (closes issue ASTERISK-11787) Reported by: vinsik Tested by: tecnoxarxa This one line change makes an if inside a for loop (in realtime_peer) check all the ast_variables the loop was intending to test rather than just the first one. ........ ................ ................ ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=113242 |