Notice: We have migrated to GitLab launching 2024-05-01 see here:

#705 closed defect (fixed)

ether_sprintf in cpukit/libnetworking/net/if_ethersubr.c is wrong

Reported by: Eric Norum Owned by: Eric Norum
Priority: lowest Milestone: 2
Component: network/legacy Version: unknown
Severity: normal Keywords:
Cc: bugs@… Blocked By:


The implementation of ether_sprintf in cpukit/libnetworking/net/if_ethersubr.c seem like it was halfway converted.

char *ether_sprintf(const u_char *ap)

static char etherbuf[18];
snprintf(etherbuf, sizeof (etherbuf), "%6D", ap, ":");
return (etherbuf);


Perhaps a better implementation would be based on the code from the i82586.c driver:
static char *ether_sprintf(unsigned char *addr)

static char buf[32];
char *b = buf;
int i;

for (i = 0; i < ETHER_ADDR_LEN; i++, b+=3) {

sprintf(b, "%02x:", *addr++);

*--b = '\0';
return buf;


This still has the problem of a static buffer, but at least it prints a valid number.
BTW -- the code in the i82586.c is wrong (there's no * on the final assignment and the final assignment has double quotes, not single!!!), but if the version in if_ethersubr.c is fixed the code in i82586.c could be removed anyhow.

CVS trunk

All network targets

Change History (1)

comment:1 Changed on 10/26/04 at 13:21:47 by Eric Norum

Status: assignedclosed

State-Changed-From-To: open->closed
State-Changed-Why: Changes committed

Note: See TracTickets for help on using tickets.