drachtio / drachtio-freeswitch-modules

A collection of open-sourced freeswitch modules that I use in various drachtio applications
MIT License
176 stars 119 forks source link

If a silly user, specifies a file path in the GOOGLE_APPLICATION_CREDENTIALS channel variable it causes a crash #59

Open jaybinks opened 3 years ago

jaybinks commented 3 years ago

Im the silly user, that didnt read the docs right, and I set the file path in GOOGLE_APPLICATION_CREDENTIALS.

the result of that is a crash with this stack trace `(gdb) info stack

0 0x00007ffacbb06a40 in grpc_impl::CompositeChannelCredentials(std::shared_ptr const&, std::shared_ptr const&) () at /usr/local/lib/libgrpc++.so.1

1 0x00007ffa880290ed in grpc::CompositeChannelCredentials (call_creds=std::shared_ptr (empty) = {...}, channel_creds=warning: RTTI symbol not found for class 'std::_Sp_counted_ptr<grpc_impl::SecureChannelCredentials*, (__gnu_cxx::_Lock_policy)2>'

warning: RTTI symbol not found for class 'std::_Sp_counted_ptr<grpc_impl::SecureChannelCredentials*, (__gnu_cxx::_Lock_policy)2>' std::shared_ptr (use count 1, weak count 0) = {...}) at /usr/local/include/grpcpp/security/credentials.h:80

2 0x00007ffa880290ed in GStreamer::GStreamer(switch_core_session, char const, char, char, char*)

(this=0x7ffaa80218b0, session=0x7ffaa4036358, lang=<optimized out>, projectId=<optimized out>, event=0x7ffa4c0368d9 "Welcome", text=0x7ffa4c0368e1 "Text") at google_glue.cpp:104

3 0x00007ffa88023f90 in google_dialogflow_session_init(switch_core_session_t, responseHandler_t, errorHandler_t, uint32_t, char, char, char, char*, cap_cb**)

(session=session@entry=0x7ffaa4036358, responseHandler=responseHandler@entry=0x7ffa880212f0 <responseHandler>, errorHandler=errorHandler@entry=0x7ffa880219d0 <errorHandler>, samples_per_second=<optimized out>, lang=lang@entry=0x7ffa4c0368d3 "en-AU", projectId=projectId@entry=0x7ffa4c0368c5 "newagent-tape", event=0x7ffa4c0368d9 "Welcome", text=0x7ffa4c0368e1 "Text", ppUserData=0x7ffa81c45d88) at google_glue.cpp:396

4 0x00007ffa88021dbf in start_capture (flags=17, text=0x7ffa4c0368e1 "Text", event=0x7ffa4c0368d9 "Welcome", projectId=0x7ffa4c0368c5 "newagent-tape", lang=0x7ffa4c0368d3 "en-AU", session=0x7ffaa4036358) at mod_dialogflow.c:100

5 0x00007ffa88021dbf in dialogflow_api_start_function (cmd=, session=, stream=0x7ffa81c45f00) at mod_dialogflow.c:172

6 0x00007ffacce25fd5 in switch_api_execute

(cmd=cmd@entry=0x7ffa4c036e18 "dialogflow_start", arg=arg@entry=0x7ffaa402ad38 "e03fdfb4-3a07-4191-9889-b9c01ccde552 newagent-tape en-AU Welcome Text", session=0x0, stream=stream@entry=0x7ffa81c45f00) at src/switch_loadable_module.c:3010

7 0x00007ffaccebdca7 in API::execute(char const, char const) (this=0x7ffa4c009dd0, cmd=cmd@entry=0x7ffa4c036e18 "dialogflow_start", arg=0x7ffaa402ad38 "e03fdfb4-3a07-4191-9889-b9c01ccde552 newagent-tape en-AU Welcome Text")

at src/switch_cpp.cpp:247

8 0x00007ffa820088a1 in _wrap_API_execute(lua_State*) (L=0x7ffa4c006cc0) at mod_lua_wrap.cpp:3309

9 0x00007ffa81dc2c75 in () at /lib/x86_64-linux-gnu/liblua5.2.so.0

10 0x00007ffa81dce825 in () at /lib/x86_64-linux-gnu/liblua5.2.so.0

11 0x00007ffa81dc2f9e in () at /lib/x86_64-linux-gnu/liblua5.2.so.0`

the call to grpc::ServiceAccountJWTAccessCredentials(var); is actually fine, I'm just going to go out on a limb here and suggest that grpc::ServiceAccountJWTAccessCredentials(var); returns a nil pointer in this case which then causes the crash when nil is passed to grpc::CompositeChannelCredentials

The real solution is for people such as myself to not do silly things, however we have to protect against segfaults :)

davehorton commented 3 years ago

Good find, thanks. I will look into a fix