From e6b04d9ffd8bef2482ab61957c138ae92527206d Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Wed, 13 Mar 2019 17:15:03 -0400 Subject: Protect [ commands from strings beginning with "-" --- (limited to 'src') diff --git a/src/ob-buildenv.sh b/src/ob-buildenv.sh index e224c54..dd16146 100644 --- a/src/ob-buildenv.sh +++ b/src/ob-buildenv.sh @@ -43,7 +43,7 @@ setup_toolchain() { # This check is done to allow at least native building on unsupported OSes. # It may be removed in the future. - if [ "${OPK_BUILD_ARCH}" != "${OPK_HOST_ARCH}" ]; then + if [ x"${OPK_BUILD_ARCH}" != x"${OPK_HOST_ARCH}" ]; then tool_prefix="${OPK_HOST_ARCH}-" else tool_prefix='' diff --git a/src/ob-buildopk.sh b/src/ob-buildopk.sh index 670740f..cfe7585 100644 --- a/src/ob-buildopk.sh +++ b/src/ob-buildopk.sh @@ -54,9 +54,9 @@ main() else for pkg in ${OPK_PACKAGES_REDUCED}; do arch="$(ob_get_binary_parameter "${pkg}" 'Architecture')" - [ "${arch}" != 'all' ] && arch="${OPK_HOST_ARCH}" + [ x"${arch}" != x'all' ] && arch="${OPK_HOST_ARCH}" plat="$(ob_get_binary_parameter "${pkg}" 'Platform')" - [ "${plat}" != 'all' ] && plat="${OPK_HOST_PLAT}" + [ x"${plat}" != x'all' ] && plat="${OPK_HOST_PLAT}" build_opk "${pkg}" "${OPK_BINARY_VERSION}" "${arch}" "${plat}" done fi diff --git a/src/ob-genchanges.sh b/src/ob-genchanges.sh index 37f96a9..db76027 100644 --- a/src/ob-genchanges.sh +++ b/src/ob-genchanges.sh @@ -73,9 +73,9 @@ write_files_bin() printf 'Files:\n' >&3 for pkg in ${OPK_PACKAGES_REDUCED}; do arch="$(ob_get_binary_parameter "${pkg}" 'Architecture')" - [ "${arch}" != 'all' ] && arch="${OPK_HOST_ARCH}" + [ x"${arch}" != x'all' ] && arch="${OPK_HOST_ARCH}" plat="$(ob_get_binary_parameter "${pkg}" 'Platform')" - [ "${plat}" != 'all' ] && plat="${OPK_HOST_PLAT}" + [ x"${plat}" != x'all' ] && plat="${OPK_HOST_PLAT}" file="${pkg}_${version}_${arch}_${plat}.opk" printf ' %s %s %s\n' \ "$(wc -c "../../${file}" | cut -d ' ' -f 1)" \ diff --git a/src/ob-gencontrol.sh b/src/ob-gencontrol.sh index 551e6de..434e491 100644 --- a/src/ob-gencontrol.sh +++ b/src/ob-gencontrol.sh @@ -182,9 +182,9 @@ main() for pkg in ${OPK_PACKAGES_REDUCED}; do ob_set_package_substvars "${pkg}" arch="$(ob_get_binary_parameter "${pkg}" 'Architecture')" - [ "${arch}" != 'all' ] && arch="${OPK_HOST_ARCH}" + [ x"${arch}" != x'all' ] && arch="${OPK_HOST_ARCH}" plat="$(ob_get_binary_parameter "${pkg}" 'Platform')" - [ "${plat}" != 'all' ] && plat="${OPK_HOST_PLAT}" + [ x"${plat}" != x'all' ] && plat="${OPK_HOST_PLAT}" desc="$(ob_get_binary_parameter "${pkg}" 'Description')" desc="$(ob_substvars "${desc}")" gen_control "${pkg}" "${OPK_BINARY_VERSION}" "${arch}" "${plat}" \ diff --git a/src/ob-installdocs.sh b/src/ob-installdocs.sh index 6b15e2c..cf67383 100644 --- a/src/ob-installdocs.sh +++ b/src/ob-installdocs.sh @@ -29,7 +29,7 @@ install_docs() for src in ${srcs}; do if [ -f "${src}" ]; then - if [ "${dest%/*}" != "${dest}" ]; then + if [ x"${dest%/*}" != x"${dest}" ]; then if ! mkdir -p "${data_doc_dir}/${dest%/*}"; then ob_error "$(ob_get_msg 'cant_make_doc_dir')" return 1 @@ -40,7 +40,7 @@ install_docs() return 1 fi elif [ -d "${src}" ]; then - if [ "${dest%/*}" != "${dest}" ]; then + if [ x"${dest%/*}" != x"${dest}" ]; then if ! mkdir -p "${data_doc_dir}/${dest%/*}"; then ob_error "$(ob_get_msg 'cant_make_doc_dir')" return 1 @@ -77,7 +77,7 @@ main() doc_dir="$(ob_get_system_path 'package-docs' \ "${pkg}" "${OPK_BINARY_VERSION}")" data_doc_dir="${pkg}.data/${doc_dir%/}" - if [ "${pkg}" = "${doc_pkg}" ]; then + if [ x"${pkg}" = x"${doc_pkg}" ]; then if [ -d "${data_doc_dir}" ]; then ob_info "$(ob_get_msg 'docs_already_installed')" "${pkg}" else diff --git a/src/opkbuild.sh b/src/opkbuild.sh index 6f3246b..affa6e2 100644 --- a/src/opkbuild.sh +++ b/src/opkbuild.sh @@ -394,11 +394,11 @@ main() setup_package || return 1 - if [ "${opt_build}" = 'source' -o "${opt_build}" = 'full' ]; then + if [ x"${opt_build}" = x'source' -o x"${opt_build}" = x'full' ]; then build_source || return 1 fi - if [ "${opt_build}" != 'source' ]; then + if [ x"${opt_build}" != x'source' ]; then print_arch_stats if "${opt_check_build_deps}"; then if ! "${BINDIR}/ob-checkbuilddeps"; then -- cgit v0.9.1