KanoComputing / kano-burners

SD Card burner for OSX
GNU General Public License v2.0
12 stars 11 forks source link

Verify disk before performing operations on it #22

Open CarolineClark opened 9 years ago

CarolineClark commented 9 years ago

We had a report of a customer wiping his 1TB internal hard drive after apparently selecting the SD card in the dropdown list. We need to verify the disk selected is the disk we're formatting and burning.

elyscape commented 9 years ago

The problem is with this line, which takes only the last character of the DeviceID. If the system has more than 10 drives attached (e.g. the user has a multi-card reader) and selects, for example, the drive with DeviceID=\.\PHYSICALDRIVE12, the tool will select the last character and format drive 2. A solution would be to replace the offending line with something like this:

drivenum = output_lines[index].lower().find('physicaldrive') + len('physicaldrive')
id = output_lines[index][drivenum:]

I moved everything to lower case because I don't know if WMI uses the same casing on all systems.

elyscape commented 9 years ago

As a side note, id is a Python built-in function, so it might be a good idea to rename that variable.

elyscape commented 9 years ago

Bump. I've submitted a pull request that fixes this issue (#24).

Ealdwulf commented 9 years ago

This was merged (Thanks @elyscape !) But I think there was one place where the single digit disk id was still being used: format_disk(). I' have made a fix here: https://github.com/KanoComputing/kano-burners/commit/dc3751ca8bba634dca55fb52881b5b028a42d816

Ealdwulf commented 9 years ago

@rluz @FMog Does either of you have a multi-in-one card reader writer ? If not we need to acquire one before this can be tested. This fault is caused by having a card reader which appears to windows as so many disks that there are 10 disks, so we ended writing to disk 0 instead of disk 10.

rluz commented 9 years ago

@Ealdwulf I have a multi card reader, I can bring it tomorrow.