librdkafka
librdkafka copied to clipboard
[WIP] Strip a trailing . when present in name - #4348
This is a very poor attempt at addressing the issue mentioned here: https://github.com/confluentinc/librdkafka/issues/4348, which is caused by https://github.com/openssl/openssl/issues/11560#issuecomment-1619143823
If this is the wrong place to be attempting to address the issue, I would love guidance on how to properly tackle the problem. I don't use librdkafka directly, but rely on a ruby wrapping library. (karafka).
What I'm attempting here is to transform
my.kafka.domain.com.:9093
-> my.kafka.domain.com:9093
by splitting on ":" and replacing trailing "." with "\0"
No comment on the desirability of this patch (versus waiting for OpenSSL to fix it, or discovering that it's not really a bug after all) — but unless I'm mistaken, the :9093
part has already been stripped by line 452, and any :
characters that remain are part of an IPv6 address. So probably all you want here is:
/* Remove ":9092" port suffix from nodename */
if ((t = strrchr(name, ':')))
*t = '\0';
+
+ /* Remove "." trailing dot suffix from nodename */
+ if ((t = strrchr(name, '.')) && t[1] == '\0')
+ *t = '\0';