summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Hall <halex@cvs.openbsd.org>2016-08-21 19:22:16 +0000
committerAlexander Hall <halex@cvs.openbsd.org>2016-08-21 19:22:16 +0000
commit87b1caca3286a6a9a45622cb2cf2b153298603fb (patch)
treeebc15c5b366a30ebf26eed65ee07bac73aced16f
parent3614127053c36cd9eb06eb2b65efcf38afa72046 (diff)
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@
-rw-r--r--distrib/miniroot/install.sub9
1 files 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 <rpe@openbsd.org>
@@ -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
}