Potential bug that can overwrite the MBR of the host machine if no loop devices are available

This commit is contained in:
Adrien Bourmault 2020-02-02 17:30:06 +01:00
parent 69e2069471
commit 02e7b7ea77
2 changed files with 22 additions and 1 deletions

View File

@ -54,6 +54,7 @@
│   │   ├── boot.h
│   │   └── mboot.h
│   ├── io
│   │   ├── acpi.h
│   │   ├── ata.h
│   │   ├── cursor.h
│   │   ├── keyb.h
@ -94,6 +95,7 @@
│   │   │   ├── ssp.c
│   │   │   └── table.c
│   │   ├── io
│   │   │   ├── acpi.c
│   │   │   ├── ata.asm
│   │   │   ├── ata.c
│   │   │   ├── cursor.c
@ -160,4 +162,4 @@
├── ProjectTree
└── README.md
28 directories, 107 files
28 directories, 109 files

View File

@ -45,6 +45,12 @@ sudo losetup $lpblock $1 -o 1048576
echo ${CL2}[create_disk.sh]${NC} Sync image... \(sync\)${CL3}
sync
if [ -z $lpblock ];
then
echo No loop device partition to target. Fatal error !
return 13
fi
## Format
echo ${CL2}[create_disk.sh]${NC} Formatting image... \(mkdosfs\)${CL3}
sudo mkdosfs -F32 -f 2 $lpblock
@ -61,6 +67,19 @@ lpblock=$(sudo losetup -f)
sudo losetup $lpblock $1 -o 1048576
lpblockbase=$(sudo losetup -f)
sudo losetup $lpblockbase $1
if [ -z $lpblockbase ];
then
echo No loop device to target. Fatal error !
return 13
fi
if [ -z $lpblock ];
then
echo No loop device partition to target. Fatal error !
return 13
fi
sudo udisksctl mount -b $lpblock --no-user-interaction
## Sync