From: Michael Jerris Date: Wed, 16 Mar 2016 21:10:57 +0000 (-0500) Subject: FS-8937: [mod_easyroute] handle segfault when using bad customer query or on query... X-Git-Tag: v1.6.7^2~93 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=973e2031910bef05acbe04ea92d36e2481b0ebb4;p=thirdparty%2Ffreeswitch.git FS-8937: [mod_easyroute] handle segfault when using bad customer query or on query error --- diff --git a/src/mod/applications/mod_easyroute/mod_easyroute.c b/src/mod/applications/mod_easyroute/mod_easyroute.c index db5852ea91..980e845e50 100644 --- a/src/mod/applications/mod_easyroute/mod_easyroute.c +++ b/src/mod/applications/mod_easyroute/mod_easyroute.c @@ -82,14 +82,16 @@ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_custom_query, globals.custom_query) static int route_callback(void *pArg, int argc, char **argv, char **columnNames) { route_callback_t *cbt = (route_callback_t *) pArg; - - switch_copy_string(cbt->gateway, argv[0], 128); - switch_copy_string(cbt->group, argv[1], 128); - switch_copy_string(cbt->limit, argv[2], 128); - switch_copy_string(cbt->techprofile, argv[3], 128); - switch_copy_string(cbt->acctcode, argv[4], 128); - switch_copy_string(cbt->translated, argv[5], 60); - + if (argc >= 6) { + switch_copy_string(cbt->gateway, argv[0], 128); + switch_copy_string(cbt->group, argv[1], 128); + switch_copy_string(cbt->limit, argv[2], 128); + switch_copy_string(cbt->techprofile, argv[3], 128); + switch_copy_string(cbt->acctcode, argv[4], 128); + switch_copy_string(cbt->translated, argv[5], 60); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "sql for route_callback only returning %d fields\n", argc); + } return 0; }