[BUGFIX] Prevent command exit status overflow to non-error status 39/53839/4
authorOliver Eglseder <oliver.eglseder@in2code.de>
Wed, 30 Aug 2017 13:53:48 +0000 (15:53 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 31 Aug 2017 13:12:22 +0000 (15:12 +0200)
If a command throws an exception the exception code will be used
as exit code of the CLI command. This will result in an integer overflow
since exit codes are limited to 255, whereas 255 is reserved for PHP.
(See PHP exit documentation)

This commit checks if the return code will result in a 0 and change it to 1 instead.
In TYPO3 v9 the exit code is limited by Symfony Console so no change in master is needed.

Resolves: #82246
Releases: 8.7, 7.6
Change-Id: Id85fcbb61d6f0b4dd7f5ee9a1aaf55e648819b9c
Reviewed-on: https://review.typo3.org/53839
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Classes/Console/CliRequestHandler.php

index 64dae82..cf93d9c 100644 (file)
@@ -92,6 +92,10 @@ class CliRequestHandler implements RequestHandlerInterface
             $exitCode = $e->getCode();
         }
 
+        if ($exitCode > 0 && 0 === $exitCode % 256) {
+            $exitCode = 1;
+        }
+
         exit($exitCode);
     }