From 26a244cbedcfa4aea86b04db875e6ad7d00f408f Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Sat, 21 Dec 2024 10:28:14 +0100 Subject: [PATCH] Fix potential overflow in sequence number Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- versioning/bump_version.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/versioning/bump_version.sh b/versioning/bump_version.sh index 5571617..6fa82c2 100644 --- a/versioning/bump_version.sh +++ b/versioning/bump_version.sh @@ -20,7 +20,12 @@ VERSION_MONTH=$(echo "$CURRENT_VERSION" | awk -F. '{print $2}') # Determine new version if [[ "$CURRENT_YEAR" == "$VERSION_YEAR" && "$CURRENT_MONTH" == "$VERSION_MONTH" ]]; then - NEW_SEQ=$(printf "%02d" $((10#$CURRENT_SEQ + 1))) # Increment sequence + NEXT_SEQ=$((10#$CURRENT_SEQ + 1)) + if [ $NEXT_SEQ -gt 99 ]; then + echo "Error: Sequence number would exceed 99" + exit 1 + fi + NEW_SEQ=$(printf "%02d" $NEXT_SEQ) else NEW_SEQ="01" # Reset sequence for a new month fi