Project

General

Profile

Actions

Bug #9053

closed

dladm show-phys -P speaks gibberish

Added by Robert Mustacchi over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Category:
cmd - userland programs
Start date:
2018-02-06
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

dladm show-phys -P can speak giberish when fields are specified:

[root@haswell ~]# dladm show-phys -o link,speed,speed,speed -P
LINK         SPEED  SPEED  SPEED
igb0         0E��������AE� 0E��������AE� 0E��������AE�
igb2         0E��������AE� 0E��������AE� 0E��������AE�
igb1         0E��������AE� 0E��������AE� 0E��������AE�
igb3         0E��������AE� 0E��������AE� 0E��������AE�

The root cause of this is that we are only initializing fields that are valid for the mode (whether using -P or not). This means that the rest of the structure is stack garbage!

I've opted to fix this by zeroing the structure, which libofmt will then handle correct as the field not being present. The alternative idea I had was to go through and actually limit the valid fields to those that made sense. I have opted to not do that because I was afraid that this might end up breaking things unintentionally that were used to using those fields.

Actions

Also available in: Atom PDF