From e1e2b61ecf0148cc7d176f80012e0ef0729edccc Mon Sep 17 00:00:00 2001 From: cschantz Date: Fri, 27 Feb 2026 19:10:50 -0500 Subject: [PATCH] CRITICAL: Add missing explicit returns to 5 step functions These 5 functions were called in conditional statements but had NO explicit return: - step1_detect_datadir (line 2138) - used in: while ! step1_detect_datadir - step2_set_restore_location (line 2376) - used in: while ! step2_set_restore_location - step3_select_database (line 2448) - used in: while ! step3_select_database - step4_configure_options (line 2511) - called in menu case 4 - step5_create_dump (line 2674) - used in: if step5_create_dump All ended with press_enter and closing brace with NO explicit return 0. This caused undefined return codes from read command, breaking while/if logic. FIX: Added explicit `return 0` before closing brace in all 5 functions. These were CATASTROPHICALLY MISSED in previous audit! Script would have failed in production when any step completed successfully. Severity: CRITICAL Impact: Script cannot function without explicit returns on success paths Co-Authored-By: Claude Haiku 4.5 --- modules/backup/mysql-restore-to-sql.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/backup/mysql-restore-to-sql.sh b/modules/backup/mysql-restore-to-sql.sh index faaf803..05f03a1 100755 --- a/modules/backup/mysql-restore-to-sql.sh +++ b/modules/backup/mysql-restore-to-sql.sh @@ -2134,6 +2134,7 @@ step1_detect_datadir() { echo "" press_enter + return 0 } # Step 2: Configure temporary location for restored MySQL data @@ -2372,6 +2373,7 @@ step2_set_restore_location() { echo "" press_enter + return 0 } # Step 3: Allow user to select which database to extract from the restored data @@ -2442,6 +2444,7 @@ step3_select_database() { print_success "Selected database: $DATABASE_NAME" echo "" press_enter + return 0 } # Step 4: Configure InnoDB recovery options and ticket information @@ -2505,6 +2508,7 @@ step4_configure_options() { echo "" press_enter + return 0 } # Step 5: Create SQL dump from the restored database using second MySQL instance @@ -2665,6 +2669,7 @@ step5_create_dump() { echo "" press_enter + return 0 } ################################################################################