Programmer's Ultimate Security DeskRef

Prototype: string basename ( string path [, string suffix])
Summary: This function is used to strip path information and file extensions from a filename.
Description: The basename function is used to remove directory information and optionally file extension from a path string for a file. The first parameter is used to determine the full path of the file. All directory names in the path defined by a "/" or "\" are removed leaving only the filename. Additionally, a suffix may be used (file extension) which will be removed from the end of the name. For example, the string variable $path="/var/www/html/index.html" would return index.html when run through basename as follows basename($path). If .html was added as the suffix, then only index would be returned.
Risk: basename allows for imprecise file instructions to be sent to the systems processing. When using basename as a means to normalize filenames it is possible to interpret two different files with identical names that exist in different directory structures. This can lead to file corruption and unintentional disclosure of data. When using this function it is imperative that directory structures are not ignored.
Additional Resources: www.php.net/manual/en/function.basename.php
Impact: Low
Cross References: dirname
Prototype: resource bzopen ( string filename, string mode)
Summary: Similar to fopen, this function is used to open bzip2 files.
Description: The bzopen function is used in a manner similar to fopen, to open a bzip2 file (.bz2) These files can...