Review main Merged

42888[BUGFIX] Handling of uploaded files not within open_basedir

Bernhard Kraft CR +2 V +2 Easy +2 −1 updated 11/13/15, 19:51

Commit message

When the "upload_tmp_dir" folder is not within the "open_basedir"
an Exception will get thrown when uploading files in the fileadmin.
This patch silences open_basedir() warnings occuring in the file_exists()
check and adds detection of uploaded files as the handling of these with
move_uploaded_file() is not influenced by the open_basedir setting.

Review

  • Code review CR +2
    • Morton Jonuschat +2
    • Wouter Wolters +1
    • Markus Sommer +1
    • Frank Nägler +1
  • Verified V +2
    • Morton Jonuschat +2
    • Markus Sommer +1

Issues 1

Files 1

Review log 15

  1. Bernhard Kraft uploaded patch set 1 08/27/15, 12:14

  2. Benni Mack uploaded patch set 2 10/01/15, 13:22

  3. Benni Mack voted on patch set 2 CR +1 10/08/15, 20:28

  4. Oliver Hader uploaded patch set 3 10/08/15, 23:53

  5. Morton Jonuschat uploaded patch set 4 11/13/15, 14:38

  6. Morton Jonuschat voted on patch set 4 CR +1 V +1 11/13/15, 14:39

  7. Frank Nägler commented on patch set 4 CR -1 11/13/15, 16:49

    dislike the @ operator... suppress the error is not a solution. If I understand it correctly, this is a failure of a misconfigured system. From my point of view, it is absolut correct to get an exception here.
  8. Morton Jonuschat commented on patch set 4 CR 0 V 0 11/13/15, 16:54

    Sorry, but it's no a misconfigured system. It's perfectly valid for the webserver to store the (temporary) uploaded file in a directory where the user has no access. Thats why there is move_uploaded_file(). The comment in the PHP docs says: move_uploaded_file() is both safe mode and open_basedir aware. However, restrictions are placed only on the destination path as to allow the moving of uploaded files in which filename may conflict with such restrictions. move_uploaded_file() ensures the safety of this operation by allowing only those files uploaded through PHP to be moved. Switching the conditions around might avoid the open_basedir warning for uploaded files, will try and push a new patchset if it works out.
  9. Morton Jonuschat uploaded patch set 5 11/13/15, 17:02

  10. Morton Jonuschat commented on patch set 5 CR +1 V +1 11/13/15, 17:03

    Check for uploaded files first as PHP will then not process the file_exists call in case of uploaded files. This avoids the need of silencing the open_basedir warning.
  11. Frank Nägler commented on patch set 5 CR +1 11/13/15, 17:07

    thx, looks much better :)
  12. Wouter Wolters voted on patch set 5 CR +1 11/13/15, 19:01

  13. Markus Sommer voted on patch set 5 CR +1 V +1 11/13/15, 19:47

  14. Morton Jonuschat voted on patch set 5 CR +2 V +2 11/13/15, 19:50

  15. Gerrit merged patch set 5 11/13/15, 19:51