-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
2.5
-
None
-
MOODLE_25_STABLE
In mod/turnitintool/lib.php there is a function called turnitintool_tempfile(). This contains a potential infinite loop..
The lines are...
while(!$fp) {
|
$file = $temp_dir.DIRECTORY_SEPARATOR.mt_rand().'.'.$suffix;
|
$fp = @fopen($file, 'w');
|
}
|
I assume the idea is that it loops if a filename clashes. However, this will loop "forever" if the fopen() fails for ANY reason. Something like a permission problem or a lack of disk space would be all that was needed. Worse - if something has gone wrong the @ prevents the admin ever finding out what the actual underlying error is.
This needs rewriting. Personally I would pick a random number and then increment it by one until a valid file was found by actually checking if the file exists. I think Moodle had a function for this somewhere but, of course, I can't find it now!