I know this doesn't directly answer your question, but I think it's more important to observe that you will have better luck keeping your applications secure with a "default-deny" mindset, which I think is one of the most important concepts in computer security.
For example, you seem to be chasing down all the possible bad stuff people could do with your script, and acting against them. This is known as "enumerating badness", and is generally acknowledged as an impossible task.
Instead, it is much better to write your code in such a way that all images are uploaded without execute permissions, for example, since they don't need them, and therefore it makes sense to "deny by default". And then you don't have to worry about people executing them.
Or, instead of finding out if a file is an image when uploading, "deny by default" execution permissions for any uploaded file, and add them later if a specific set of conditions is met (although I can't imagine letting random stuff uploaded to be executed is ever a good idea).
So it's better to allow *only* the stuff you want to allow, than to try to deny every single bad thing that could happen.
I do hope that helps.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.