You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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; }
The text was updated successfully, but these errors were encountered:
reunanen
added a commit
to reunanen/amqpcpp
that referenced
this issue
Jan 16, 2018
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; }
The text was updated successfully, but these errors were encountered: