~ubuntu-branches/ubuntu/lucid/mahara/lucid-security

« back to all changes in this revision

Viewing changes to htdocs/lib/file.php

  • Committer: Package Import Robot
  • Author(s): Melissa Draper
  • Date: 2011-11-02 21:26:46 UTC
  • Revision ID: package-import@ubuntu.com-20111102212646-vlu4g4gzrsz00od9
Tags: 1.2.4-1ubuntu0.4
* SECURITY UPDATE: XSS in unvalidated URI attributes
  - Added a filter to sanitise user input urls (LP: #888358)
  - debian/patches/CVE-2011-2771.patch: upstream patch
  - CVE-2011-2771

* SECURITY UPDATE: DoS attack via invalid or excessively large images
  - Added a check to evaluate available memory before processing
    (LP: #888358)
  - debian/patches/CVE-2011-2772.patch: upstream patch
  - CVE-2011-2772

* SECURITY UPDATE: XSRF allowing attackers to trick an admin into adding 
  them to an institution
  - Session check added (LP: #888358)
  - debian/patches/CVE-2011-2773.patch: upstream patch
  - CVE-2011-2773

* SECURITY UPDATE: Prevent masquerading users from jumping as others
  - Added a check to prevent jumping as other users. (LP: #888358)
  - debian/patches/mnet_masquerading.patch: upstream patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
408
408
 *                if an appropriate file could not be located or generated
409
409
 */
410
410
function get_dataroot_image_path($path, $id, $size=null) {
 
411
    global $THEME;
411
412
    $dataroot = get_config('dataroot');
412
413
    $imagepath = $dataroot . $path;
413
414
    if (substr($imagepath, -1) == '/') {
455
456
 
456
457
            $imageinfo = getimagesize($originalimage);
457
458
            $originalmimetype = $imageinfo['mime'];
 
459
 
 
460
            // gd can eat a lot of memory shrinking large images, so use a placeholder image
 
461
            // here if necessary
 
462
            if (isset($imageinfo[0]) && isset($imageinfo[1]) && isset($imageinfo['bits'])) {
 
463
                $approxmem = $imageinfo[0] * $imageinfo[1] * ($imageinfo['bits'] / 8)
 
464
                    * (isset($imageinfo['channels']) ? $imageinfo['channels'] : 3);
 
465
            }
 
466
            if (empty($approxmem) || $approxmem > get_config('maximageresizememory')) {
 
467
                log_debug("Refusing to resize large image $originalimage $originalmimetype "
 
468
                    . $imageinfo[0] . 'x' .  $imageinfo[1] . ' ' . $imageinfo['bits'] . '-bit');
 
469
                $originalimage = $THEME->get_path('images/no_thumbnail.png');
 
470
                if (empty($originalimage) || !is_readable($originalimage)) {
 
471
                    return false;
 
472
                }
 
473
                $imageinfo = getimagesize($originalimage);
 
474
                $originalmimetype = $imageinfo['mime'];
 
475
            }
 
476
 
458
477
            $format = 'png';
459
478
            switch ($originalmimetype) {
460
479
                case 'image/jpeg':