test/nvmf: Sanitize random string
In case the random string beggins with `-` (still a valid ascii char that nvme supports) the rpc.py arg parser will treat it as an additional argument instead of actual subsystem value. To mitigate, escape the `-` in case it's the char that starts the string. Fixes: 1240 Change-Id: I07bd8134fb9fc16234e72e9ebd27e2b6b90d6b62 Signed-off-by: Michal Berger <michalx.berger@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1054 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
23f78f22cf
commit
70cc99bccf
@ -22,6 +22,10 @@ gen_random_s () {
|
|||||||
for (( ll = 0; ll < length; ll++ )); do
|
for (( ll = 0; ll < length; ll++ )); do
|
||||||
string+="$(echo -e "\x$(printf '%x' "${chars[RANDOM % ${#chars[@]}]}")")"
|
string+="$(echo -e "\x$(printf '%x' "${chars[RANDOM % ${#chars[@]}]}")")"
|
||||||
done
|
done
|
||||||
|
# Be nice to rpc.py's arg parser and escape `-` in case it's a first character
|
||||||
|
if [[ ${string::1} == "-" ]]; then
|
||||||
|
string=${string/-/\\-}
|
||||||
|
fi
|
||||||
echo "$string"
|
echo "$string"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user