Previously filesrc would segfault when fed with the name of a directory.
authorMartin Enlund <martin@enlund.net>
Tue, 15 Jan 2002 22:33:15 +0000 (22:33 +0000)
committerMartin Enlund <martin@enlund.net>
Tue, 15 Jan 2002 22:33:15 +0000 (22:33 +0000)
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.

gst/elements/gstfilesrc.c
plugins/elements/gstfilesrc.c

index 2d9541e..0f768ab 100644 (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);
index 2d9541e..0f768ab 100644 (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);