Copilot commented on code in PR #14568:
URL: https://github.com/apache/cloudstack/pull/14568#discussion_r4454087088


##########
scripts/storage/qcow2/managesnapshot.sh:
##########
@@ -189,14 +189,11 @@ backup_snapshot() {
   local destName=$4
   local forceShareFlag="-U"
 
-  if [ ! -d $destPath ]
+  mkdir_ret=$(mkdir -p "$destPath" 2>&1)
+  if [ $? -gt 0 ]
   then
-     mkdir -p $destPath >& /dev/null
-     if [ $? -gt 0 ]
-     then
-        printf "Failed to create $destPath\n" >&2
-        return 3
-     fi
+     printf "Failed to create $destPath: $mkdir_ret\n" >&2

Review Comment:
   The new diagnostic is interpolated into the `printf` format string. A 
destination path or mkdir diagnostic containing `%s` (or another printf 
directive) will be interpreted rather than printed literally, so the reported 
mkdir failure can be corrupted. Use a constant format string and pass the 
message as an argument.
   
   This issue also appears in the following locations of the same file:
   - line 233
   - line 265



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to