misc: fix an out-of-bound write with zero-length hardware address

In case a device without a MAC address (such as tun) is enslaved, the team
master looses its MAC address too. Don't let that confuse teamd state
dump.

  ==32459== Invalid write of size 1
  ==32459==    at 0x409C32: hwaddr_str (misc.h:62)
  ==32459==    by 0x409C32: a_hwaddr_str (misc.h:77)
  ==32459==    by 0x409C32: ifinfo_state_dev_addr_get (teamd_state.c:518)
  ==32459==    by 0x409A16: teamd_state_val_dump (teamd_state.c:237)
  ==32459==    by 0x40A53A: teamd_state_vals_dump (teamd_state.c:280)
  ==32459==    by 0x40A53A: teamd_state_dump (teamd_state.c:459)
  ==32459==    by 0x40E1D5: teamd_ctl_method_state_dump (teamd_ctl.c:186)
  ==32459==    by 0x40F35F: process_rcv_msg (teamd_usock.c:197)
  ==32459==    by 0x40F35F: callback_usock_acc_conn (teamd_usock.c:219)
  ==32459==    by 0x40550F: teamd_run_loop_do_callbacks (teamd.c:325)
  ==32459==    by 0x40550F: teamd_run_loop_run (teamd.c:405)
  ==32459==    by 0x4070A9: teamd_start (teamd.c:1528)
  ==32459==    by 0x4070A9: main (teamd.c:1847)
  ==32459==  Address 0x851a2bf is 1 bytes before a block of size 1 alloc'd
  ==32459==    at 0x4C2BBAD: malloc (vg_replace_malloc.c:299)
  ==32459==    by 0x409BF4: a_hwaddr_str (misc.h:74)
  ==32459==    by 0x409BF4: ifinfo_state_dev_addr_get (teamd_state.c:518)
  ==32459==    by 0x409A16: teamd_state_val_dump (teamd_state.c:237)
  ==32459==    by 0x40A53A: teamd_state_vals_dump (teamd_state.c:280)
  ==32459==    by 0x40A53A: teamd_state_dump (teamd_state.c:459)
  ==32459==    by 0x40E1D5: teamd_ctl_method_state_dump (teamd_ctl.c:186)
  ==32459==    by 0x40F35F: process_rcv_msg (teamd_usock.c:197)
  ==32459==    by 0x40F35F: callback_usock_acc_conn (teamd_usock.c:219)
  ==32459==    by 0x40550F: teamd_run_loop_do_callbacks (teamd.c:325)
  ==32459==    by 0x40550F: teamd_run_loop_run (teamd.c:405)
  ==32459==    by 0x4070A9: teamd_start (teamd.c:1528)
  ==32459==    by 0x4070A9: main (teamd.c:1847)

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
1 file changed