dslite: Quote resolveip hostname argument
authorHans Dedecker <dedeckeh@gmail.com>
Thu, 6 Oct 2016 07:13:40 +0000 (09:13 +0200)
committerJo-Philipp Wich <jo@mein.io>
Thu, 6 Oct 2016 10:16:12 +0000 (12:16 +0200)
Quote resolveip hostname argument to avoid bad shell injections.
While at it fix pattern match logic in case multiple IPv6 addresses
are returned for a hostname as they're seperated by newline by
resolveip and not a white space

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
package/network/ipv6/ds-lite/Makefile
package/network/ipv6/ds-lite/files/dslite.sh

index 919ac7e74d76a0ce1f66cc203ab098df406fd786..58e7156b95a312039f583bec73b415bcaa685822 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=ds-lite
 PKG_VERSION:=7
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 PKG_LICENSE:=GPL-2.0
 
 include $(INCLUDE_DIR)/package.mk
index a7e0a10542b856aa640fd438558cfffe524d6c93..2485a424dca0f616005d12d346aec55cf75aa59d 100755 (executable)
@@ -26,16 +26,20 @@ proto_dslite_setup() {
 
        ( proto_add_host_dependency "$cfg" "::" "$tunlink" )
 
-       remoteip6=$(resolveip -6 $peeraddr)
+       remoteip6=$(resolveip -6 "$peeraddr")
        if [ -z "$remoteip6" ]; then
                sleep 3
-               remoteip6=$(resolveip -6 $peeraddr)
+               remoteip6=$(resolveip -6 "$peeraddr")
                if [ -z "$remoteip6" ]; then
                        proto_notify_error "$cfg" "AFTR_DNS_FAIL"
                        return
                fi
        fi
-       peeraddr="${remoteip6%% *}"
+
+       for ip6 in $remoteip6; do
+               peeraddr=$ip6
+               break
+       done
 
        [ -z "$ip6addr" ] && {
                local wanif="$tunlink"