#541 filename error in Upload

PHP_error
open
8
2012-10-11
2006-06-26
gpetty
No

When I upload a file called "test.png", it gets saved
to uploadstest.png rather than uploads/test.png.
It is then of course not found when I try to access the
file.

My version of plugin/Upload.php is 1.19

Discussion

  • Reini Urban

    Reini Urban - 2006-07-23

    Logged In: YES
    user_id=13755

    Can you please tell me the version of lib/config.php and
    the phpwiki release version (see lib/prepend.php).

    getUploadFilePath() always has an ending slash.

     
  • Nobody/Anonymous

    Logged In: NO

    Same issue here:

    phpwiki: 1.3.12p3
    lib/config.php: config.php,v 1.139 2006/03/19 14:50:42
    Php: 5.1.2

    Thanks,
    Hinnerk

     
  • gpetty

    gpetty - 2006-08-01

    Logged In: YES
    user_id=1546415

    From config.php:
    rcs_id('$Id: config.php,v 1.137 2005/08/06 14:31:10 rurban
    Exp $');

    From prepend.php:
    define('PHPWIKI_VERSION', '1.3.12p2')

     
  • Bron Gondwana

    Bron Gondwana - 2007-03-01

    Logged In: YES
    user_id=9941
    Originator: NO

    This just bit me as well, but I took the time to read the source code and find the bug.

    The problem is with realpath().

    http://php.net/realpath

    In particular look at this comment:

    ===================
    eric at themepark dot com
    18-Jul-2002 11:15
    note that realpath() will chop any trailing delimiter like \ or / ...don't forget to add it back on if you need it.

    Eric Mueller - themepark.com

    Now look at the code in getUploadFilePath() and notice that your "trailing slash" is inside the function call to realpath().

    Please move the trailing slash to after the realpath() function call and people who don't explicitly configure UPLOAD_FILE_PATH or PHPWIKI_DIR will be unbroken again.

    Actually, make that function take ANY of its possible inputs, call realpath on them and then append a slash. So much safer.

    (even better, put an explicit slash after it on every use, then you're really safe against configuration mistakes)

    Ta,

    Bron.

     
  • Reini Urban

    Reini Urban - 2007-03-01

    Logged In: YES
    user_id=13755
    Originator: NO

    Whow! Good catch!
    This caught me also for a long time.
    Will be fixed ASAP

     
  • Nobody/Anonymous

    Logged In: NO

    Here's the solution, whoever maintains this:
    edit line 101 in file lib/plugin/UpLoad.php to
    $file_dir = getUploadFilePath().'/';
    Cheers,
    Luzi.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks