Bug #82246

CLI return code overflow and reserved code 255

Added by Oliver Eglseder about 2 years ago. Updated 12 months ago.

Status:
Closed
Priority:
Must have
Category:
CLI
Target version:
Start date:
2017-08-30
Due date:
% Done:

100%

TYPO3 Version:
7
PHP Version:
7.0
Tags:
Complexity:
no-brainer
Is Regression:
Sprint Focus:

Description

When executing a command which results in an exception the exception code will be passed to PHP's function exit() without further investigation, which will actually result in any return code between 0 and 255.
This has two bad implications, first of all using timestamps as an exception code will eventually yield a code (e.g. 1504100352) that results in 0 retuned by the command which implies that there was nothing wrong (very bad!) and other codes like "1504100095" which result in 255, which is reserved for PHP according to the documentation of PHP: http://php.net/manual/en/function.exit.php
Affected LTS version are 7 and 8. Version 9 relies on symfony/console which limits these codes at least to 255 (i already submitted a patch to limit them to 254).

Associated revisions

Revision 22a20932 (diff)
Added by Oliver Eglseder about 2 years ago

[BUGFIX] Prevent command exit status overflow to non-error status

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 <>
Tested-by: Frank Naegler <>
Tested-by: TYPO3com <>
Reviewed-by: Christian Kuhn <>
Tested-by: Christian Kuhn <>

Revision d8b99acf (diff)
Added by Oliver Eglseder about 2 years ago

[BUGFIX] Prevent command exit status overflow to non-error status

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/53842
Tested-by: TYPO3com <>
Reviewed-by: Christian Kuhn <>
Tested-by: Christian Kuhn <>

History

#1 Updated by Gerrit Code Review about 2 years ago

  • Status changed from New to Under Review

Patch set 1 for branch TYPO3_8-7 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/53839

#2 Updated by Gerrit Code Review about 2 years ago

Patch set 2 for branch TYPO3_8-7 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/53839

#3 Updated by Gerrit Code Review about 2 years ago

Patch set 3 for branch TYPO3_8-7 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/53839

#4 Updated by Gerrit Code Review about 2 years ago

Patch set 1 for branch TYPO3_7-6 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/53842

#5 Updated by Oliver Eglseder about 2 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#6 Updated by Benni Mack 12 months ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF