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

MessageImpl::errstr() can attempt to construct std::string with NULL #3140

Closed
2 of 7 tasks
ephisino opened this issue Nov 11, 2020 · 0 comments
Closed
2 of 7 tasks

MessageImpl::errstr() can attempt to construct std::string with NULL #3140

ephisino opened this issue Nov 11, 2020 · 0 comments

Comments

@ephisino
Copy link

Bug in MessageImpl::errstr() can attempt to construct std::string with NULL which is defined as undefined behavior by the standard.

Description

recently introduced code in MessageImpl::errstr() can try to construct a std::string with a null ptr

const char *rd_kafka_message_errstr (const rd_kafka_message_t *rkmessage) {
        if (!rkmessage->err)
                return NULL;
  std::string         errstr() const {
    /* message_errstr() is only available for the consumer. */
    if (rk_type_ == RD_KAFKA_CONSUMER)
      return std::string(rd_kafka_message_errstr(rkmessage_));

How to reproduce

call errstr from a consumer on message with no error

IMPORTANT: Always try to reproduce the issue on the latest released version (see https://github.com/edenhill/librdkafka/releases), if it can't be reproduced on the latest version the issue has been fixed.

Checklist

IMPORTANT: We will close issues where the checklist has not been completed.

Please provide the following information:

  • librdkafka version (release number or git tag): v1.5.2
  • Apache Kafka version: <REPLACE with e.g., 0.10.2.3>
  • librdkafka client configuration: <REPLACE with e.g., message.timeout.ms=123, auto.reset.offset=earliest, ..>
  • Operating system: Linux x86-64
  • Provide logs (with debug=.. as necessary) from librdkafka
  • Provide broker log excerpts
  • Critical issue
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

No branches or pull requests

2 participants