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

chip-tool (or anything on Darwin) beeps every time an mdns resolution is made #21867

Closed
bluebin14 opened this issue Aug 12, 2022 · 0 comments · Fixed by #22172
Closed

chip-tool (or anything on Darwin) beeps every time an mdns resolution is made #21867

bluebin14 opened this issue Aug 12, 2022 · 0 comments · Fixed by #22172
Assignees

Comments

@bluebin14
Copy link
Contributor

Problem

chip-tool beeps every time an mdns resolution is made. The beeping is caused by printf'ing the BELL character 0x07.

void ResolveContext::OnNewInterface(uint32_t interfaceId, const char * fullname, const char * hostnameWithDomain, uint16_t port,
                                    uint16_t txtLen, const unsigned char * txtRecord)
{
    ChipLogDetail(Discovery, "Mdns : %s hostname:%s fullname:%s interface: %" PRIu32 " port: %u TXT:\"%.*s\"", __func__,
                  hostnameWithDomain, fullname, interfaceId, port, static_cast<int>(txtLen), txtRecord);

Doing printf %s on an mdns text record is a bad idea since it's not only ASCII, it also has binary uint8 length bytes. When they happen to be 0x07 you get a beep, it's called the BELL character, referred to as control-G or ^G in caret notation.

TXT:"\^GSAI=300\^HSII=5000\^FD=3840\^DCM=1
VP=4874+77\^CT=0"

Proposed Solution

Do not printf random binary data with %s format specifier.

@bzbarsky-apple bzbarsky-apple changed the title chip-tool beeps every time an mdns resolution is made chip-tool (or anything on Darwin) beeps every time an mdns resolution is made Aug 25, 2022
@bzbarsky-apple bzbarsky-apple self-assigned this Aug 25, 2022
bzbarsky-apple added a commit to bzbarsky-apple/connectedhomeip that referenced this issue Aug 25, 2022
Instead, actually look at record lengths, remove the lengths in favor
of comma-separating the records, replace various things that are not
printable with hex escape sequences.

The new output ends up looking something like:

    TXT:"SII=5000,SAI=2000,T=1"

Fixes project-chip#21867
bzbarsky-apple added a commit to bzbarsky-apple/connectedhomeip that referenced this issue Aug 26, 2022
Instead, actually look at record lengths, remove the lengths in favor
of comma-separating the records, replace various things that are not
printable with hex escape sequences.

The new output ends up looking something like:

    TXT:"SII=5000,SAI=2000,T=1"

Fixes project-chip#21867
bzbarsky-apple added a commit that referenced this issue Aug 27, 2022
Instead, actually look at record lengths, remove the lengths in favor
of comma-separating the records, replace various things that are not
printable with hex escape sequences.

The new output ends up looking something like:

    TXT:"SII=5000,SAI=2000,T=1"

Fixes #21867
isiu-apple pushed a commit to isiu-apple/connectedhomeip that referenced this issue Sep 16, 2022
Instead, actually look at record lengths, remove the lengths in favor
of comma-separating the records, replace various things that are not
printable with hex escape sequences.

The new output ends up looking something like:

    TXT:"SII=5000,SAI=2000,T=1"

Fixes project-chip#21867
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants