Previously filesrc would segfault when fed with the name of a directory.

Original commit message from CVS:
Previously filesrc would segfault when fed with the name of a directory.
Added check to ensure that the given file is a regular file.
This commit is contained in:
Martin Enlund 2002-01-15 22:33:15 +00:00
parent f1e89caecd
commit 7b1d5c7abd
2 changed files with 20 additions and 0 deletions

View file

@ -555,6 +555,16 @@ gst_filesrc_open_file (GstFileSrc *src)
src->filename, strerror (errno), NULL);
return FALSE;
} else {
/* check if it is a regular file, otherwise bail out */
struct stat stat_results;
fstat(src->fd, &stat_results);
if (!S_ISREG(stat_results.st_mode)) {
gst_element_error (GST_ELEMENT (src), "opening file \"%s\" failed. it isn't a regular file",
src->filename, NULL);
close(src->fd);
return FALSE;
}
/* find the file length */
src->filelen = lseek (src->fd, 0, SEEK_END);
lseek (src->fd, 0, SEEK_SET);

View file

@ -555,6 +555,16 @@ gst_filesrc_open_file (GstFileSrc *src)
src->filename, strerror (errno), NULL);
return FALSE;
} else {
/* check if it is a regular file, otherwise bail out */
struct stat stat_results;
fstat(src->fd, &stat_results);
if (!S_ISREG(stat_results.st_mode)) {
gst_element_error (GST_ELEMENT (src), "opening file \"%s\" failed. it isn't a regular file",
src->filename, NULL);
close(src->fd);
return FALSE;
}
/* find the file length */
src->filelen = lseek (src->fd, 0, SEEK_END);
lseek (src->fd, 0, SEEK_SET);