Zend Framework

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

Details

  • Type: Improvement Improvement
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.6.0
  • Fix Version/s: 1.8.4
  • Component/s: Zend_Captcha
  • Labels:
    None

Description

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.

Activity

Hide
Ota Mares added a comment -

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.

Show
Ota Mares added a comment - 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.
Hide
Ota Mares added a comment -

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.

Show
Ota Mares added a comment - 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.
Hide
Stanislav Malyshev added a comment -

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?

Show
Stanislav Malyshev added a comment - 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?
Hide
Ota Mares added a comment -

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

Show
Ota Mares added a comment - I did not saw it happen but it could happen. And prevention is better then a late reaction.
Hide
Stanislav Malyshev added a comment -

fixed, thanks

Show
Stanislav Malyshev added a comment - fixed, thanks

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: