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

Initialize dmac array to nulls #5538

Merged
merged 3 commits into from
Dec 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/platform/portduino/PortduinoGlue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ void getMacAddr(uint8_t *dmac)
if (optionMac != nullptr && strlen(optionMac) > 0) {
if (strlen(optionMac) >= 12) {
MAC_from_string(optionMac, dmac);
std::cout << optionMac << std::endl;
} else {
uint32_t hwId = sscanf(optionMac, "%u", &hwId);
dmac[0] = 0x80;
Expand All @@ -98,7 +97,6 @@ void getMacAddr(uint8_t *dmac)
}
} else if (settingsStrings[mac_address].length() > 11) {
MAC_from_string(settingsStrings[mac_address], dmac);
std::cout << settingsStrings[mac_address] << std::endl;
exit;
} else {

Expand Down Expand Up @@ -203,14 +201,14 @@ void portduinoSetup()
}
}

uint8_t dmac[6];
uint8_t dmac[6] = {0};
getMacAddr(dmac);
if (dmac[0] == 0 && dmac[1] == 0 && dmac[2] == 0 && dmac[3] == 0 && dmac[4] == 0 && dmac[5] == 0) {
std::cout << "*** Blank MAC Address not allowed!" << std::endl;
std::cout << "Please set a MAC Address in config.yaml using either MACAddress or MACAddressSource." << std::endl;
exit(EXIT_FAILURE);
}
printBytes("MAC Address: ", dmac, 6);
std::cout << "MAC Address: " << std::hex << +dmac[0] << +dmac[1] << +dmac[2] << +dmac[3] << +dmac[4] << +dmac[5] << std::endl;
// Rather important to set this, if not running simulated.
randomSeed(time(NULL));

Expand Down Expand Up @@ -531,4 +529,4 @@ bool MAC_from_string(std::string mac_str, uint8_t *dmac)
} else {
return false;
}
}
}
Loading