Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AMQPException will crash in function AMQP::login() #71

Closed
fan-chao opened this issue Oct 10, 2017 · 0 comments · Fixed by #75
Closed

AMQPException will crash in function AMQP::login() #71

fan-chao opened this issue Oct 10, 2017 · 0 comments · Fixed by #75

Comments

@fan-chao
Copy link

Currently the AMQP::login() is as below.
void AMQP::login() { amqp_rpc_reply_t res = amqp_login(cnn, vhost.c_str(), 0, FRAME_MAX, 0, AMQP_SASL_METHOD_PLAIN, user.c_str(), password.c_str()); if ( res.reply_type != AMQP_RESPONSE_NORMAL) { amqp_destroy_connection(cnn); throw AMQPException(&res); } }

I use latest rabbit-c library and it has crash issue if login fails.
The reason is that cache buffer will be cleared in function amqp_destroy_connection(cnn). So the pointer of res.reply.decoded is invalid while execute AMQPException(&res) and causes the following codes to crash.
if(res->reply.id == AMQP_CONNECTION_CLOSE_METHOD) { amqp_connection_close_t *m = (amqp_connection_close_t *) res->reply.decoded; this->code = m->reply_code; sprintf(buf, "server connection error %d, message: %.*s", m->reply_code, (int) m->reply_text.len, (char *) m->reply_text.bytes ); }

I modify the order of the above two lines and it works.
if ( res.reply_type != AMQP_RESPONSE_NORMAL) { auto amqp_exception = AMQPException(&res); amqp_destroy_connection(cnn); throw amqp_exception; }

reunanen added a commit to reunanen/amqpcpp that referenced this issue Jan 16, 2018
…akalend#71)

- Also, fix indentation to use tabs like elsewhere in the code
reunanen added a commit to reunanen/amqpcpp that referenced this issue Jan 16, 2018
…akalend#71)

- Also, fix indentation to use tabs like elsewhere in the code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant