DEV9: Replace sprintf()/strcat() with snprintf()

This commit is contained in:
Stenzek 2023-10-02 02:05:32 +10:00 committed by Connor McLaughlin
parent e8201b115f
commit 61ce0d1117
1 changed files with 3 additions and 4 deletions

View File

@ -321,11 +321,10 @@ bool PCAPAdapter::InitPCAP(const std::string& adapter, bool promiscuous)
bool PCAPAdapter::SetMACSwitchedFilter(MAC_Address mac)
{
bpf_program fp;
char filter[1024] = "ether broadcast or ether dst ";
char virtual_mac_str[18];
sprintf(virtual_mac_str, "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x", mac.bytes[0], mac.bytes[1], mac.bytes[2], mac.bytes[3], mac.bytes[4], mac.bytes[5]);
strcat(filter, virtual_mac_str);
char filter[128];
std::snprintf(filter, std::size(filter), "ether broadcast or ether dst %.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
mac.bytes[0], mac.bytes[1], mac.bytes[2], mac.bytes[3], mac.bytes[4], mac.bytes[5]);
if (pcap_compile(hpcap, &fp, filter, 1, PCAP_NETMASK_UNKNOWN) == -1)
{