Package: isc-dhcp-client
Version: 4.3.2-1
Tags: patch
Followup-For: Bug #768860

Dear Maintainer,


The immediate cause of this issue seem to be, that in file
/etc/dhcp/dhclient-exit-hooks.d/rfc3442-classless-routes
the "shift <n>" commands perform no actual shift and leaves the
positional arguments as before.

the bash manual explains:

> shift [n]
>        If n is greater than $#, the positional parameters are not
>        changed.

My patch attached to this email proposes to check for this condition and
abort the script.

Although the issue should be resolved by this, no attempts are made to
further mitigate the effect of bogus dhcp option 121 sent by the dhcp
server (I think a bogus rfc-3442 option should be ignore entirely).

As a further note: I would like to write an error message to system log
(in the patch it's only written to stderr and thus does not reach
syslog). Although /usr/bin/logger seems to be the perfect tool, I am
unsure regarding support/presence of this tool on non-debian operating
systems (i.e. *BSD))


-- System Information:
Debian Release: stretch/sid
  APT prefers stable
  APT policy: (990, 'stable'), (500, 'stable-updates'), (500, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.0.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages isc-dhcp-client depends on:
ii  debianutils       4.4+b1
ii  iproute2          3.16.0-2
ii  isc-dhcp-common   4.3.1-6
ii  libc6             2.19-18
ii  libdns-export100  1:9.9.5.dfsg-9
ii  libirs-export91   1:9.9.5.dfsg-9
ii  libisc-export95   1:9.9.5.dfsg-9

isc-dhcp-client recommends no packages.

Versions of packages isc-dhcp-client suggests:
ii  avahi-autoipd  0.6.31-5
pn  resolvconf     <none>

-- no debconf information



diff -urNp isc-dhcp-client_4.3.2-1_amd64.old/etc/dhcp/dhclient-exit-hooks.d/rfc3442-classless-routes isc-dhcp-client_4.3.2-1_amd64/etc/dhcp/dhclient-exit-hooks.d/rfc3442-classless-routes
--- isc-dhcp-client_4.3.2-1_amd64.old/etc/dhcp/dhclient-exit-hooks.d/rfc3442-classless-routes	2015-06-18 19:39:50.532165415 +0200
+++ isc-dhcp-client_4.3.2-1_amd64/etc/dhcp/dhclient-exit-hooks.d/rfc3442-classless-routes	2015-06-18 14:39:53.908765610 +0200
@@ -7,6 +7,9 @@
 
 RUN="yes"
 
+rfc3442_msg() {
+    echo "Illegal rfc3442 classless static route option parameters" >&2
+}
 
 if [ "$RUN" = "yes" ]; then
 	if [ -n "$new_rfc3442_classless_static_routes" ]; then
@@ -22,26 +25,31 @@ if [ "$RUN" = "yes" ]; then
 					32|31|30|29|28|27|26|25)
 						net_address="${2}.${3}.${4}.${5}"
 						gateway="${6}.${7}.${8}.${9}"
+                                                [ $# -ge 9 ] || { rfc3442_msg; return 1; }
 						shift 9
 						;;
 					24|23|22|21|20|19|18|17)
 						net_address="${2}.${3}.${4}.0"
 						gateway="${5}.${6}.${7}.${8}"
+                                                [ $# -ge 8 ] || { rfc3442_msg; return 1; }
 						shift 8
 						;;
 					16|15|14|13|12|11|10|9)
 						net_address="${2}.${3}.0.0"
 						gateway="${4}.${5}.${6}.${7}"
+                                                [ $# -ge 7 ] || { rfc3442_msg; return 1; }
 						shift 7
 						;;
 					8|7|6|5|4|3|2|1)
 						net_address="${2}.0.0.0"
 						gateway="${3}.${4}.${5}.${6}"
+                                                [ $# -ge 6 ] || { rfc3442_msg; return 1; }
 						shift 6
 						;;
 					0)	# default route
 						net_address="0.0.0.0"
 						gateway="${2}.${3}.${4}.${5}"
+                                                [ $# -ge 5 ] || { rfc3442_msg; return 1; }
 						shift 5
 						;;
 					*)	# error

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to