#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:
Blocking:

Description

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.

Release:
CVS trunk

Environment:
All network targets

Change History (1)

comment:1 Changed on Oct 26, 2004 at 1:21:47 PM by Eric Norum

Status: assignedclosed

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

Note: See TracTickets for help on using tickets.