Issue Details (XML | Word | Printable)

Key: ZF-4269
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Stanislav Malyshev
Reporter: Ota Mares
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Google issue summary
Zend Framework

Zend_Captcha_Image should check if a file with the unique name already exists

Created: 12/Sep/08 05:50 AM   Updated: 17/Jun/09 02:32 PM   Resolved: 17/Jun/09 02:32 PM
Component/s: Zend_Captcha
Affects Version/s: 1.6.0
Fix Version/s: 1.8.4

Time Tracking:
Not Specified

File Attachments: 1. Text File zend_captcha_image.patch (1 kB)



 Description  « Hide

Zend_Captcha_Image should check if a file with the generated unique name already exists.
On systems where there is a high load it could happen that a unique id gets generated twice. I know this is very unlikely but it could happen.

After generation of the id there should be an check if a file with that name already exists and if yes a new id should be generated.
I have created a fix that i will append to this issue. If the unique id generation fails three times an exception will be thrown.



Ota Mares added a comment - 12/Sep/08 05:56 AM

Added logic to the generate method to check if a filename with the generated it exists, if yes a new id will be generated.
If the generation fails three times an exception will be thrown.


Ota Mares added a comment - 12/Sep/08 08:28 AM

Ugh, i just saw that there is a suffix property that should be used instead of hardcoding the suffix into the path like in my patch file.
Because there is no way to delete or reupload previously uploaded fixes i wont reprovide the changed verison to avoid confusion.


Stanislav Malyshev added a comment - 23/Oct/08 12:30 PM

Did you actually see it happen? This requires that PHP random generator would give the same number in same microsecond for two processes. Is it a real problem?


Ota Mares added a comment - 24/Oct/08 02:05 AM

I did not saw it happen but it could happen. And prevention is better then a late reaction.


Stanislav Malyshev added a comment - 17/Jun/09 02:32 PM

fixed, thanks