On Tuesday 27 January 2009 02:31:52 pm Scott Wood wrote:
> E Robertson wrote:
> > I did the following:
> >     memcpy (gd->bd->bi_enetaddr, MACAddress,
> > sizeof(gd->bd->bi_enetaddr)); memcpy (dupMACAddress, MACAddress,
> > sizeof(dupMACAddress));
> >
> >     printf("Before %02X:%02X:%02X:%02X:%02X:%02X\n",dupMACAddress[0],
> > dupMACAddress[1],
> > dupMACAddress[2], dupMACAddress[3],
> > dupMACAddress[4], dupMACAddress[5]);
> >
> >     sprintf(env_ethaddr,"%02X:%02X:%02X:%02X:%02X:%02X",dupMACAddress[0],
> > dupMACAddress[1],
> > dupMACAddress[2], dupMACAddress[3],
> > dupMACAddress[4], dupMACAddress[5]);
> >     printf("After %02X:%02X:%02X:%02X:%02X:%02X\n",dupMACAddress[0],
> > dupMACAddress[1],
> > dupMACAddress[2], dupMACAddress[3],
> > dupMACAddress[4], dupMACAddress[5]);
> >      printf("ethaddr
> > %02X:%02X:%02X:%02X:%02X:%02X\n",gd->bd->bi_enetaddr[0],
> > gd->bd->bi_enetaddr[1],
> > gd->bd->bi_enetaddr[2], gd->bd->bi_enetaddr[3],
> > gd->bd->bi_enetaddr[4], gd->bd->bi_enetaddr[5]);
> >
> >
> > and I got this:
> >
> > Before 00:04:A6:00:6A:E6
> > After 36:00:A6:00:6A:E6
> > ethaddr 00:04:A6:00:6A:E6
> > Alse env_ethaddr has the correct correct.
>
> Looks like you're overflowing a buffer -- 0x36 0x00 are the last two
> bytes of the sprintf output.  Where are env_ethaddr and dupMACaddress
> defined?
>
Ah!! Yes, big user error! I forgot about the string termination.

Thanks.


> -Scott


Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to