From c4b12967a298137b2559de238fd067ff163bb473 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Tue, 26 Nov 2019 02:03:44 +0100 Subject: Secured numeric inputs --- joes-arch-install-UEFI.sh | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'joes-arch-install-UEFI.sh') diff --git a/joes-arch-install-UEFI.sh b/joes-arch-install-UEFI.sh index ead5df4..9f23b75 100755 --- a/joes-arch-install-UEFI.sh +++ b/joes-arch-install-UEFI.sh @@ -17,6 +17,7 @@ somemore=false intelamdcpu="none" intelamdgpu="none" ltskern=true +numregex='^[0-9]+$' if [ ! -r /sys/firmware/efi/efivars ]; then efimode=false else @@ -130,19 +131,16 @@ while [[ $answr != y && $answr != Y && $answr != yes && $answr != Yes && $answr done echo -n -e "${BYELLOW}> " read -r drvnm - if [[ $drvnm == "" ]]; then + if [ "$drvnm" = "" ]; then echo && echo echo -e "${BRED}Can't be empty, retrying...${END}" - fi - if [[ $drvnm -gt $(lsblk | grep -c disk) ]]; then + elif ! [[ $drvnm =~ $numregex ]]; then echo && echo echo -e "${BRED}Illegal value, please choose something reasonable. Retrying...${END}" - fi - if [[ $drvnm -lt 0 ]]; then + elif [ "$drvnm" -gt $(lsblk | grep -c disk) ]; then echo && echo echo -e "${BRED}Illegal value, please choose something reasonable. Retrying...${END}" - fi - if [[ $drvnm == 0 ]]; then + elif [ "$drvnm" -le 0 ]; then echo && echo echo -e "${BRED}Illegal value, please choose something reasonable. Retrying...${END}" fi @@ -167,6 +165,9 @@ __G" if [[ $swps == "" ]]; then echo && echo echo -e "${BRED}Can't be empty, retrying...${END}" + elif ! [[ $swps =~ $numregex ]]; then + echo && echo + echo -e "${BRED}Illegal value, please choose something reasonable. Retrying...${END}" fi done clear @@ -188,6 +189,9 @@ __G" if [[ $rts == "" ]]; then echo && echo echo -e "${BRED}Can't be empty, retrying...${END}" + elif ! [[ $swps =~ $numregex ]]; then + echo && echo + echo -e "${BRED}Illegal value, please choose something reasonable. Retrying...${END}" fi done btsze="128M" @@ -434,6 +438,8 @@ w FDISK_EFI_INPUT else fdisk "$drv" << FDISK_BIOS_INPUT +o +n FDISK_BIOS_INPUT fi -- cgit v1.2.3