Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed bug in openFile() function #80

Closed
wants to merge 1 commit into from

Conversation

PHPGangsta
Copy link
Contributor

No description provided.

@derickr
Copy link
Member

derickr commented Feb 1, 2020

Has this bug always been there? Surprise nobody ran into that in 12 years! Would it be possible to make a test for it?

@PHPGangsta
Copy link
Contributor Author

@derickr As far as I remember, we had PHP warnigns about "Filename too long" or "File not found" a few times per year, but it occurs very rarely, so I didn't find the time to debug. I found it now while debugging.

See also the diff of @speller at #45 (comment) , he also found the bug while hunting :-)

I found it because I got these 2 errors in the same second:

PHP Warning: fopen(/tmp/6356-1/XXXXXSOMETHINGVERYLONGXXXXXXX): failed to open stream: File name too long in /xxxx/Mail/src/parser/parts/file_parser.php on line 158

The file '/tmp/6356-1/XXXXXSOMETHINGVERYLONGXXXXXXX' could not be found.

The second error happened in the destructor, as far as I remember. It can only happen if the check directly after fopen() does not already stop the processing of the invalid filename.

I just tried to write a test, but phpunit locally already seems to stop at the PHP WARNING when fopen() fails. I'm not sure how to test the following if-check...

Travis-CI is broken, someone should fix that first. If I run the tests in tests/parser/parser_test.php with PHP 7.3 locally on Windows, I get lots of errors 😢 Some of them you can see in the Travis-CI PHP 5.6 tests: https://travis-ci.org/zetacomponents/Mail/jobs/644405808

Travis-CI running with PHP 7.0 does not run at all:
https://travis-ci.org/zetacomponents/Mail/jobs/644405809

$ phpunit
PHPUnit 7.5.0 by Sebastian Bergmann and contributors.
This version of PHPUnit is supported on PHP 7.1 and PHP 7.2.
You are using PHP 7.0.33 (/home/travis/.phpenv/versions/7.0.33/bin/php).
The command "phpunit" exited with 1.

It would be nice to run the tests with PHP 7.2, 7.3 and 7.4.

derickr added a commit that referenced this pull request Jun 13, 2020
derickr added a commit that referenced this pull request Jun 13, 2020
@derickr
Copy link
Member

derickr commented Jun 13, 2020

I've fixed this issue, and the other things from the comments too, through #83. Thanks!

@derickr derickr closed this Jun 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants