MACtoa: make return pointer const, use Snprintf vs sprintf

This commit is contained in:
dmiller 2026-07-17 21:56:28 +00:00
parent 16a39eaf76
commit c0f20bb211
2 changed files with 3 additions and 7 deletions

View file

@ -795,18 +795,14 @@ int parseMAC(const char *txt, u8 *targetbuff){
} /* End of parseMAC() */
char *MACtoa(u8 *mac){
const char *MACtoa(u8 *mac){
static char macinfo[24];
memset(macinfo, 0, 24);
sprintf(macinfo,"%02X:%02X:%02X:%02X:%02X:%02X",
Snprintf(macinfo, sizeof(macinfo), "%02X:%02X:%02X:%02X:%02X:%02X",
mac[0],mac[1],mac[2],mac[3],mac[4],mac[5]);
return macinfo;
} /* End of MACtoa() */
/* Returns a buffer of ASCII information about an ARP/RARP packet that may look
like "ARP who has 192.168.10.1? Tell 192.168.10.98"
Since this is a static buffer, don't use threads or call twice

View file

@ -101,7 +101,7 @@ struct hostent *gethostbynameCached(char *host);
struct hostent *hostentcpy(struct hostent *src);
int hostentfree(struct hostent *src);
int parseMAC(const char *txt, u8 *targetbuff);
char *MACtoa(u8 *mac);
const char *MACtoa(u8 *mac);
const char *getRandomTextPayload();
int send_packet(NpingTarget *target, int rawfd, u8 *pkt, size_t pktLen);
int print_dnet_interface(const struct intf_entry *entry, void *arg) ;