create_ap

create a nat-ed wifi ap
git clone git://git.2f30.org/create_ap
Log | Files | Refs | README | LICENSE

commit 5ff7503e015433cbc86f026d76585b929566fffa
parent f66819c145dbc90bb8000e81ad3a89877e1f3a42
Author: oblique <psyberbits@gmail.com>
Date:   Sun,  7 Sep 2014 03:18:13 +0300

check the length of passphrase and SSID at the beginning

Diffstat:
Mcreate_ap | 23++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/create_ap b/create_ap @@ -566,10 +566,21 @@ else INTERNET_IFACE=$2 fi if tty -s; then - read -p "SSID: " SSID + while :; do + read -p "SSID: " SSID + if [[ ${#SSID} -lt 1 || ${#SSID} -gt 32 ]]; then + echo "ERROR: Invalid SSID length ${#SSID} (expected 1..32)" >&2 + continue + fi + break + done while :; do read -p "Passphrase: " -s PASSPHRASE echo + if [[ ${#PASSPHRASE} -gt 0 && ${#PASSPHRASE} -lt 8 ]] || [[ ${#PASSPHRASE} -gt 63 ]]; then + echo "ERROR: Invalid passphrase length ${#PASSPHRASE} (expected 8..63)" >&2 + continue + fi read -p "Retype passphrase: " -s PASSPHRASE2 echo if [[ "$PASSPHRASE" != "$PASSPHRASE2" ]]; then @@ -589,6 +600,16 @@ if [[ "$SHARE_METHOD" != "none" ]] && ! is_interface $INTERNET_IFACE; then exit 1 fi +if [[ ${#SSID} -lt 1 || ${#SSID} -gt 32 ]]; then + echo "ERROR: Invalid SSID length ${#SSID} (expected 1..32)" >&2 + exit 1 +fi + +if [[ ${#PASSPHRASE} -gt 0 && ${#PASSPHRASE} -lt 8 ]] || [[ ${#PASSPHRASE} -gt 63 ]]; then + echo "ERROR: Invalid passphrase length ${#PASSPHRASE} (expected 8..63)" >&2 + exit 1 +fi + if [[ "$SHARE_METHOD" == "bridge" ]]; then OLD_BRIDGE_IPTABLES=$(cat /proc/sys/net/bridge/bridge-nf-call-iptables)