Skip to content

Commit

Permalink
Use the "right" byte-swapping function for port in Darwin DnssdImpl. (p…
Browse files Browse the repository at this point in the history
…roject-chip#23894)

The incoming port is in host byte order and we are converting to network byte
order, so should use htons (which happens to do the same thing as ntohs, so no
behavior change).

Co-authored-by: Andrei Litvin <andy314@gmail.com>
  • Loading branch information
2 people authored and sharadb-amazon committed Mar 17, 2023
1 parent 0a64e9f commit d927a0f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/platform/Darwin/DnssdImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ CHIP_ERROR Register(void * context, DnssdPublishCallback callback, uint32_t inte
sdCtx->mHostNameRegistrar.Init(hostname, addressType, interfaceId);

DNSServiceRef sdRef;
auto err = DNSServiceRegister(&sdRef, kRegisterFlags, interfaceId, name, type, kLocalDot, hostname, ntohs(port), record.size(),
auto err = DNSServiceRegister(&sdRef, kRegisterFlags, interfaceId, name, type, kLocalDot, hostname, htons(port), record.size(),
record.data(), OnRegister, sdCtx);
VerifyOrReturnError(kDNSServiceErr_NoError == err, sdCtx->Finalize(err));

Expand Down

0 comments on commit d927a0f

Please sign in to comment.