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

Fail to read/write if register number is not parsed correctly #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion rdmsr.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,11 @@ int main(int argc, char *argv[])
exit(127);
}

reg = strtoul(argv[optind], NULL, 0);
reg = strtoul(argv[optind], &endarg, 0);
if (*endarg) {
printf("Failed to parse register number. Do you need a prefix?\n");
exit(127);
}

if (cpu == -1) {
doing_for_all = 1;
Expand Down
6 changes: 5 additions & 1 deletion wrmsr.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ int main(int argc, char *argv[])
exit(127);
}

reg = strtoul(argv[optind++], NULL, 0);
reg = strtoul(argv[optind++], &endarg, 0);
if (*endarg) {
printf("Failed to parse register number. Do you need a prefix?\n");
exit(127);
}

if (cpu == -1) {
doing_for_all = 1;
Expand Down