1
0
mirror of https://github.com/open-simh/simh.git synced 2026-01-19 01:27:53 +00:00
B. Scott Michel c20b391eea ETH_MAC indirection erratum
Pervasive misuse of "ETH_MAC *" (a pointer to an ETH_MAC, aka a 6
element unsigned char array) when a simple "ETH_MAC" is correct.  The
best example of this was eth_mac_fmt() in sim_ether.c with the following
prototype:

    t_stat eth_mac_fmt (ETH_MAC* const mac, char* strmac)

The first parameter is a pointer to an array of 6 unsigned characters,
whereas it really just wants to be a pointer to the first element of the
array:

    t_stat eth_mac_scan (const ETH_MAC mac, char* strmac)

The "ETH_MAC *" indirection error also results in subtle memcpy() and
memcmp() issues, e.g.:

    void network_func(DEVICE *dev, ETH_MAC *mac)
    {
      ETH_MAC other_mac;

      /* ...code... */

      /* memcpy() bug: */
      memcpy(other_mac, mac, sizeof(ETH_MAC));

      /* or worse: */
      memcpy(mac, other_mac, sizeof(ETH_MAC));
    }

eth_copy_mac() and eth_mac_cmp() replace calls to memcpy() and memcmp()
that copy or compare Ethernet MAC addresses. These are type-enforcing
functions, i.e., the parameters are ETH_MAC-s, to avoid the subtle
memcpy() and memcmp() bugs.

This fix solves at least one Heisenbug in _eth_close() while free()-ing
write request buffers (and possibly other Heisenbugs.)
2025-08-17 16:02:56 -04:00
..
2024-02-01 12:51:13 -05:00
2022-10-29 14:15:41 -04:00
2015-02-13 06:18:24 -08:00
2022-10-29 14:15:41 -04:00
2018-09-10 15:13:06 +02:00
2024-07-23 14:25:19 -04:00
2023-11-28 09:48:36 -05:00
2025-08-17 16:02:56 -04:00
2025-08-17 16:02:56 -04:00