Skip to content

Commit 42ec082

Browse files
committed
Fix critical safety and correctness issues in release.sh
- Replace unsafe dynamic function dispatch (increment_on_$1) with explicit case validation - Fix incorrect argument validation in bump_release() - Harden apply_triplets_to_file() to avoid word-splitting issues
1 parent 88a6a29 commit 42ec082

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

release_tools/release.sh

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,22 @@ increment_on_breaking_change()
159159
# $3: The concerned file
160160
apply_triplets_to_file()
161161
{
162-
local _previous=( $1 ) _replacement=( $2 ) _file="$3" _varnames=(LT_CURRENT LT_REVISION LT_AGE)
162+
163+
local _previous
164+
local _replacement
165+
local _file="$3"
166+
local _varnames=(LT_CURRENT LT_REVISION LT_AGE)
167+
168+
_previous=( $1 )
169+
_replacement=( $2 )
170+
163171
for i in 0 1 2
164172
do
165-
substitute_variable_assignment_value_in_file "${_varnames[$i]}" "${_previous[$i]}" "${_replacement[$i]}" "$_file"
173+
substitute_variable_assignment_value_in_file \
174+
"${_varnames[$i]}" \
175+
"${_previous[$i]}" \
176+
"${_replacement[$i]}" \
177+
"$_file"
166178
done
167179
}
168180

@@ -174,7 +186,15 @@ increment_ltversions()
174186
local _cmake_file="$OSCAP_REPO_ROOT/CMakeLists.txt" _old_versions _new_versions _new_soname _old_soname
175187
# check_for_clean_repo
176188
_old_versions="$(get_lt_triplet_from_file "$_cmake_file")" || die "Unable to get current LT versions"
177-
_new_versions="$(increment_on_$1 "$_old_versions")" || die "Unable to get calculate refreshed LT version with strategy '$1'"
189+
case "$1" in
190+
backwards_compatible|bugfix|breaking_change)
191+
_new_versions="$(increment_on_$1 "$_old_versions")"
192+
;;
193+
*)
194+
die "Invalid strategy: $1"
195+
;;
196+
esac
197+
178198
_old_soname="$(get_soname_from_triplet "$_old_versions")"
179199
_new_soname="$(get_soname_from_triplet "$_new_versions")"
180200

@@ -316,7 +336,7 @@ bump_release_in_cmake()
316336
# $1: The next version
317337
bump_release()
318338
{
319-
test $# -lt 2 || die "Provide the version number as an argument"
339+
test $# -eq 1 || die "Provide the version number as an argument"
320340
check_that_bump_is_appropriate
321341
bump_release_in_cmake "$1"
322342
bump_release_in_release_script "$FILE_WITH_VERSIONS" "$1"

0 commit comments

Comments
 (0)