The set_time_limit function in Gallery before 1.4.4_p2 deletes non-image files in a temporary directory every 30 seconds after they have been uploaded using save_photos.php, which allows remote attackers to upload and execute execute arbitrary scripts before they are deleted, if the temporary directory is under the web root.
https://exchange.xforce.ibmcloud.com/vulnerabilities/17021
https://euvd.enisa.europa.eu/vulnerability/EUVD-2004-1460
http://www.securityfocus.com/bid/10968
http://www.gentoo.org/security/en/glsa/glsa-200409-05.xml
http://archives.neohapsis.com/archives/fulldisclosure/2004-08/0757.html