From f4dbc8a5d43f6a97cadf731b2a7f06634aefefb0 Mon Sep 17 00:00:00 2001 From: Girish Subramanya Date: Wed, 28 Sep 2022 19:04:43 -0400 Subject: [PATCH] Reject input name with collect utility when name length exceeds 235 When using the collect utility and where the user provides a bundle name with --name that is 236 characters or longer: An error log to notify the max size of log name shall have the allowed limit defined in the collect utility - without bad substitution error An inappropriate error "no space left on device" was being reported; An "operation timeout" error was reported when name length exceeds 239 On a standalone system, the Error reported is: "refusing to creating empty .tar file". This update rectifies the bad substitution with new Max length error log This update validates the name length and fixes the inappropriate Error indicating the maximum allowed length for the bundle name. Test Plan: Verify long name error has no bad substitution in max_length error log Verify collector package build with iso build in CentOS Verify log name within limit is accepted and collect bundle is created Verify name length 1 over max-length fails Verify log name is rejected with the error code 55 with name_length 236 Verify log name is rejected with the error code 55 with name_length 240 Verify log name is rejected with the error code 55 without timeout error Verify boundary condition with name length equal to max-length succeeds Regression: Verify named collect bundle tar under scratch with name length under 236 Signed-off-by: Girish Subramanya Closes-Bug: 1990533 Change-Id: Ia55d759773af666e64f687b0f203740dbda8e309 --- tools/collector/scripts/collect | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/collector/scripts/collect b/tools/collector/scripts/collect index 247eb991..c35b7a6b 100755 --- a/tools/collector/scripts/collect +++ b/tools/collector/scripts/collect @@ -620,7 +620,7 @@ while [[ ${#} -gt 0 ]] ; do max_length=$(expr 255 - 16 - 4) # Padding of timestamp and .tar if [ ${len} -gt ${max_length} ] ; then - report_error "name must not be longer than ${$max_length} characters" ${FAIL_NAME_TOO_LONG} + report_error "name must not be longer than ${max_length} characters" ${FAIL_NAME_TOO_LONG} collect_exit ${FAIL_NAME_TOO_LONG} fi fi