@@ -579,13 +579,16 @@ void MdnsAvahi::HandleBrowse(AvahiServiceBrowser * browser, AvahiIfIndex interfa
579
579
if (strcmp (" local" , domain) == 0 )
580
580
{
581
581
MdnsService service = {};
582
+ char typeAndProtocol[kMdnsTypeAndProtocolMaxSize + 1 ];
582
583
583
584
strncpy (service.mName , name, sizeof (service.mName ));
584
- strncpy (service.mType , type, sizeof (service.mType ));
585
585
service.mName [kMdnsNameMaxSize ] = 0 ;
586
+ strncpy (typeAndProtocol, type, sizeof (typeAndProtocol));
587
+ typeAndProtocol[kMdnsTypeAndProtocolMaxSize ] = 0 ;
588
+ service.mProtocol = TruncateProtocolInType (typeAndProtocol);
589
+ service.mAddressType = ToAddressType (protocol);
590
+ strncpy (service.mType , typeAndProtocol, sizeof (service.mType ));
586
591
service.mType [kMdnsTypeMaxSize ] = 0 ;
587
- service.mProtocol = TruncateProtocolInType (service.mType );
588
- service.mAddressType = ToAddressType (protocol);
589
592
context->mServices .push_back (service);
590
593
}
591
594
break ;
@@ -655,16 +658,19 @@ void MdnsAvahi::HandleResolve(AvahiServiceResolver * resolver, AvahiIfIndex inte
655
658
break ;
656
659
case AVAHI_RESOLVER_FOUND:
657
660
MdnsService result = {};
661
+ char typeAndProtocol[kMdnsTypeAndProtocolMaxSize + 1 ];
658
662
659
663
result.mAddress .SetValue (chip::Inet::IPAddress ());
660
664
ChipLogError (DeviceLayer, " Avahi resolve found" );
661
665
strncpy (result.mName , name, sizeof (result.mName ));
662
- strncpy (result.mType , type, sizeof (result.mType ));
663
666
result.mName [kMdnsNameMaxSize ] = 0 ;
667
+ strncpy (typeAndProtocol, type, sizeof (typeAndProtocol));
668
+ typeAndProtocol[kMdnsTypeAndProtocolMaxSize ] = 0 ;
669
+ result.mProtocol = TruncateProtocolInType (typeAndProtocol);
670
+ result.mPort = port;
671
+ result.mAddressType = ToAddressType (protocol);
672
+ strncpy (result.mType , typeAndProtocol, sizeof (result.mType ));
664
673
result.mType [kMdnsTypeMaxSize ] = 0 ;
665
- result.mProtocol = TruncateProtocolInType (result.mType );
666
- result.mPort = port;
667
- result.mAddressType = ToAddressType (protocol);
668
674
669
675
if (address)
670
676
{
0 commit comments