]> git.ipfire.org Git - network.git/commitdiff
pppoe-server: improve input validation
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Sat, 3 Jun 2017 11:25:10 +0000 (13:25 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 7 Jun 2017 16:32:17 +0000 (18:32 +0200)
We now check if the subnet, the mtu and the max-sessions valud is valid.

Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/hooks/configs/pppoe-server

index 1ef3ba9c5208ecbef1a262a9bdfa7be57546ea0c..6f95212625ae3a2a70b32ea9957b8f710f5ff2d0 100644 (file)
@@ -69,15 +69,30 @@ hook_new() {
                                ;;
                        --max-sessions=*)
                                MAX_SESSIONS=$(cli_get_val ${1})
+                               if ! isinteger ${MAX_SESSIONS} || ! [ ${MAX_SESSIONS} -ge 0 ]; then
+                                       error "Invalid value for '--max-session'. This value must be an integer greate or eqal zero."
+                                       exit ${EXIT_ERROR}
+                               fi
                                ;;
                        --mtu=*)
                                MTU=$(cli_get_val ${1})
+                               if ! mtu_is_valid "ipv4" ${MTU}; then
+                                       error "Invalid value for '--mtu'. Cannot be larger then 9000 or smaller than 576"
+                                       exit ${EXIT_ERROR}
+                               fi
                                ;;
                        --service-name=*)
                                SERVICE_NAME=$(cli_get_val ${1})
                                ;;
                        --subnet=*)
                                SUBNET=$(cli_get_val ${1})
+                               if ! ipv4_net_is_valid "${SUBNET}"; then
+                                       error "Invalid IPv4 Subnet ${SUBNET}."
+                                       exit ${EXIT_ERROR}
+                               fi
+                               ;;
+                       *)
+                               warning "Ignoring unknown option '${1}'"
                                ;;
                esac
                shift