Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Conversation

@yghannam
Copy link

It's possible that a user will provide a register number in a format
that strtoul() can't parse. strtoul() will return 0 if it fails to parse
a value. The msr-tools will then silently read/write to MSR 0x0 and
succeed. At best this may confuse the user, or at worst this will
unintentionally write bad data to the system.

Check that the register number parsing has succeeded. If it fails, then
inform the user, give a suggestion, and exit.

Signed-off-by: Yazen Ghannam yazen.ghannam@amd.com

It's possible that a user will provide a register number in a format
that strtoul() can't parse. strtoul() will return 0 if it fails to parse
a value. The msr-tools will then silently read/write to MSR 0x0 and
succeed. At best this may confuse the user, or at worst this will
unintentionally write bad data to the system.

Check that the register number parsing has succeeded. If it fails, then
inform the user, give a suggestion, and exit.

Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com>
@dilinger
Copy link

dilinger commented Dec 2, 2018

This patch works (thanks!), but I'd suggest changing the error message to drop the "Do you need a prefix?" part. I can imagine the confusion from a user doing this:

dilinger@e7470:~$ sudo rdmsr MSR_K8_TOP_MEM2
Failed to parse register number. Do you need a prefix?
dilinger@e7470:~$ sudo rdmsr 0xMSR_K8_TOP_MEM2
Failed to parse register number. Do you need a prefix?
dilinger@e7470:~$ 

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants