From 2e1ca43b4acd9d5c10649eb3c80089df81639530 Mon Sep 17 00:00:00 2001 From: halex Date: Sun, 21 Aug 2016 19:22:15 +0000 Subject: [PATCH] Make lease_value() unescape quoted strings. To be fully compliant, we should unvis() it too, but I think this is enough, at least for now. ok krw@ --- distrib/miniroot/install.sub | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub index b42909635c4..e221b7b2832 100644 --- a/distrib/miniroot/install.sub +++ b/distrib/miniroot/install.sub @@ -1,5 +1,5 @@ #!/bin/ksh -# $OpenBSD: install.sub,v 1.904 2016/08/21 18:47:01 rpe Exp $ +# $OpenBSD: install.sub,v 1.905 2016/08/21 19:22:15 halex Exp $ # # Copyright (c) 1997-2015 Todd Miller, Theo de Raadt, Ken Westerback # Copyright (c) 2015, Robert Peichaer @@ -231,13 +231,18 @@ __EOT # Examine the contents of the DHCP lease file named in $1 for a line # containing the field provided as parameters. # +# Note that strings are unescaped but not unvis()'d. +# # Return the value of the first field found. lease_value () { local _lf=$1 _o shift for _o; do - sed -E '/^ *(option )?'"$_o"' (.*);$/!d;s//\2/;s/^"//;s/"$//;q' "$_lf" | grep ^ && return + sed -E \ + -e '/^ *(option )?'"$_o"' (.*);$/!d;s//\2/' \ + -e '/^"(.*)"$/{s//\1/;s/\\(.)/\1/g;};q' "$_lf" \ + | grep ^ && return done } -- 2.20.1