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 │   │   ├── boot.h
│   │   └── mboot.h │   │   └── mboot.h
│   ├── io │   ├── io
│   │   ├── acpi.h
│   │   ├── ata.h │   │   ├── ata.h
│   │   ├── cursor.h │   │   ├── cursor.h
│   │   ├── keyb.h │   │   ├── keyb.h
@ -94,6 +95,7 @@
│   │   │   ├── ssp.c │   │   │   ├── ssp.c
│   │   │   └── table.c │   │   │   └── table.c
│   │   ├── io │   │   ├── io
│   │   │   ├── acpi.c
│   │   │   ├── ata.asm │   │   │   ├── ata.asm
│   │   │   ├── ata.c │   │   │   ├── ata.c
│   │   │   ├── cursor.c │   │   │   ├── cursor.c
@ -160,4 +162,4 @@
├── ProjectTree ├── ProjectTree
└── README.md └── 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} echo ${CL2}[create_disk.sh]${NC} Sync image... \(sync\)${CL3}
sync sync
if [ -z $lpblock ];
then
echo No loop device partition to target. Fatal error !
return 13
fi
## Format ## Format
echo ${CL2}[create_disk.sh]${NC} Formatting image... \(mkdosfs\)${CL3} echo ${CL2}[create_disk.sh]${NC} Formatting image... \(mkdosfs\)${CL3}
sudo mkdosfs -F32 -f 2 $lpblock sudo mkdosfs -F32 -f 2 $lpblock
@ -61,6 +67,19 @@ lpblock=$(sudo losetup -f)
sudo losetup $lpblock $1 -o 1048576 sudo losetup $lpblock $1 -o 1048576
lpblockbase=$(sudo losetup -f) lpblockbase=$(sudo losetup -f)
sudo losetup $lpblockbase $1 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 sudo udisksctl mount -b $lpblock --no-user-interaction
## Sync ## Sync