Throw when the size does not fit into an int in PharFileInfo::getCompressedSize() - #23719
PavlNekrasov wants to merge 1 commit into
Conversation
Problem: The field compressed_filesize is a uint32_t, but PharFileInfo::getCompressedSize() returns it with RETURN_LONG. zend_long is 32-bit on 32-bit platforms, so a size above ZEND_LONG_MAX is reported as a negative number there and correctly on 64-bit ones. Solution: Throw a BadMethodCallException on platforms where the size does not fit into a zend_long, 64-bit platforms are unaffected. Signed-off-by: p.nekrasov@fobos-nt.ru Signed-off-by: crystarm@altlinux.org
|
Hi. Thanks for the PR. Several questions:
Code wise I think this is correct. |
Girgias
left a comment
There was a problem hiding this comment.
There are many such instances and people deal with negative values routinely. So I don't see why this (and other such issues) should be fixed.
Also if you are going to throw an exception don't use an SPL Exception (expecially one that makes no sense)
I am not very sure about the convention here. But I do find many such instance in the code base (getSize()、filesize() and stat() and perhaps mount()).
Can you explain the reason here? I am not familiar with SPL Exception so I can't tell why but I am willing to know, because I see some usage of this in the code base. |
Instance that throw an error if a u32 does not fit in a zend_long? I'm not sure I understand the sentence correctly.
SPL exceptions are just bad, but also one shouldn't be throwing an exception from a different extension Phar, expecially for Phar related errors, PharException exists for a reason. Moreover our coding style policy says:
See also #21766 |
fix #23718
Throw a BadMethodCallException on platforms where the size does not fit into a zend_long, 64-bit platforms are unaffected.
Signed-off-by: p.nekrasov@fobos-nt.ru
Signed-off-by: crystarm@altlinux.org