From f81bb7e2c4ee8d8c070e2bd212562cc4315edf3a Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 21 Apr 2022 17:45:56 +0200 Subject: seedrng: use posix positional params to avoid space splitting The value of ${seed_dir} may have spaces in it, making the current argument string building method unsafe. Instead, use positional parameters to pass these arguments safely. --- init.d/seedrng.in | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'init.d/seedrng.in') diff --git a/init.d/seedrng.in b/init.d/seedrng.in index 10fb931d..15dd3f54 100644 --- a/init.d/seedrng.in +++ b/init.d/seedrng.in @@ -19,18 +19,18 @@ depend() provide urandom } -seedrng_options() +seedrng_with_options() { - [ -n "${seed_dir}" ] && - echo "--seed-dir \"${seed_dir}\"" - yesno "${skip_credit}" && - echo "--skip-credit" + set -- + [ -n "${seed_dir}" ] && set -- "$@" --seed-dir "${seed_dir}" + yesno "${skip_credit}" && set -- "$@" --skip-credit + seedrng "$@" } start() { ebegin "Seeding random number generator" - seedrng $(seedrng_options) + seedrng_with_options eend $? "Error seeding random number generator" return 0 } @@ -38,7 +38,7 @@ start() stop() { ebegin "Saving random number generator seed" - seedrng $(seedrng_options) + seedrng_with_options eend $? "Error saving random number generator seed" return 0 } -- cgit v1.2.3