Open MatthewTingum opened 3 years ago
Looking at this from a maintainability perspective, I think the Xbox related functionality could be moved to it's own binary. We don't need to shoehorn this all in to smartctl. Admittedly, I haven't read through the ATA spec. I don't think locking and unlocking is part of S.M.A.R.T. SMART is supposed to be for diagnostics so why would it be? If it is, we should work towards adding support for unlocking drives to the smartctl project. Then we'd only need code to decrypt the keys.
I feel like the original authors hacked up this project because it has code to send ATA commands. Is there no well maintained library that can do this? If there is, I feel that we could create a new project based off of that. If there isn't, I still feel that separating drive unlocking / xbox related logic is best.
This was first noticed when smartctl attempted to open a different file than the one I had provided on the command line.
Examples:
These lines are the culprits: https://github.com/TheMuso/smartmontools-xbox/blob/96500832cf4ce5f0ec92d1775094a05b4900bde2/smartmontools/smartctl.cpp#L931 https://github.com/TheMuso/smartmontools-xbox/blob/96500832cf4ce5f0ec92d1775094a05b4900bde2/smartmontools/smartctl.cpp#L937 https://github.com/TheMuso/smartmontools-xbox/blob/96500832cf4ce5f0ec92d1775094a05b4900bde2/smartmontools/smartctl.cpp#L941
The parsing here seems a little redundant. Maybe it can be cleaned up a bit.
It looks like the same bug shows up in the password parsing too: https://github.com/TheMuso/smartmontools-xbox/blob/96500832cf4ce5f0ec92d1775094a05b4900bde2/smartmontools/smartctl.cpp#L955 https://github.com/TheMuso/smartmontools-xbox/blob/96500832cf4ce5f0ec92d1775094a05b4900bde2/smartmontools/smartctl.cpp#L961 https://github.com/TheMuso/smartmontools-xbox/blob/96500832cf4ce5f0ec92d1775094a05b4900bde2/smartmontools/smartctl.cpp#L967
Some options are inconsistent in their
memset
ofset_security_password
. https://github.com/TheMuso/smartmontools-xbox/blob/96500832cf4ce5f0ec92d1775094a05b4900bde2/smartmontools/smartctl.cpp#L966 Here and at least one other place, the length of the memset is 32. The buffer is 33 bytes in length and some options memset the entire 33 bytes. I think this value should be defined.