Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@patmarion
Copy link
Contributor

The sub->channel is a shortened string clipped at ZCM_CHANNEL_MAXLEN=32 while channel is the full string.

The sub->channel is a shortened string clipped at ZCM_CHANNEL_MAXLEN=32
while channel is the full string.
@patmarion
Copy link
Contributor Author

Hi @jbendes and @olsoni, this is a fix to a bug I encountered when using zcm-logger -c <channel_regex>. If the given regex string is longer than ZCM_CHANNEL_MAXLEN characters, which is only 32, then the string is clipped and the regex attempts to parse the clipped string and fails.

This change fixes the issue for me. But I do find the whole concept of clipping the string to be a bit sketchy here. It seems like maybe it should be a fatal error if someone calls subscribe with a channel name that is too long? I have an alternative fix where I introduce a --logger-regex command line arg that can accept a regex string and handle the channel name filtering in the logger's callback handler, rather than passing the regex string into the zcm subscriber channel.

sub->regex = isRegexChannel(channel);
if (sub->regex) {
sub->regexobj = (void*) new std::regex(sub->channel);
sub->regexobj = (void*) new std::regex(channel);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

channel is the complete string. sub->channel has been truncated at ZCM_CHANNEL_MAXLEN. Note that just below here the sub is stored in a map using channel as the key.

@jbendes jbendes merged commit 4fce93f into ZeroCM:master Nov 17, 2025
1 check failed
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 this pull request may close these issues.

2 participants