summaryrefslogtreecommitdiff
path: root/src/input/input_file.c
diff options
context:
space:
mode:
authorDiego 'Flameeyes' Pettenò <flameeyes@gmail.com>2007-06-09 18:21:04 +0200
committerDiego 'Flameeyes' Pettenò <flameeyes@gmail.com>2007-06-09 18:21:04 +0200
commitf36b9d822626dbbaf585e70cfa7ea60aa6d194af (patch)
tree220b7a7d185f262dc793c14c92a77ea615950d86 /src/input/input_file.c
parentb6055c5fe61d918259d1c253aa32fa97dd3e5163 (diff)
parentd5d3776bf7e2733d382c5811b317bcdb7c2c9e88 (diff)
downloadxine-lib-f36b9d822626dbbaf585e70cfa7ea60aa6d194af.tar.gz
xine-lib-f36b9d822626dbbaf585e70cfa7ea60aa6d194af.tar.bz2
Merge with 1.2 branch.
Diffstat (limited to 'src/input/input_file.c')
-rw-r--r--src/input/input_file.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/input/input_file.c b/src/input/input_file.c
index 0ec25e1f8..cc1e55c87 100644
--- a/src/input/input_file.c
+++ b/src/input/input_file.c
@@ -144,7 +144,7 @@ static int check_mmap_file(file_input_plugin_t *this) {
}
#endif
-static off_t file_plugin_read (input_plugin_t *this_gen, char *buf, off_t len) {
+static off_t file_plugin_read (input_plugin_t *this_gen, void *buf, off_t len) {
file_input_plugin_t *this = (file_input_plugin_t *) this_gen;
#ifdef HAVE_MMAP
@@ -359,6 +359,9 @@ static int file_plugin_open (input_plugin_t *this_gen ) {
file_input_plugin_t *this = (file_input_plugin_t *) this_gen;
char *filename;
struct stat sbuf;
+#ifdef HAVE_MMAP
+ size_t tmp_size;
+#endif
lprintf("file_plugin_open\n");
@@ -423,10 +426,14 @@ static int file_plugin_open (input_plugin_t *this_gen ) {
}
#ifdef HAVE_MMAP
- if ( (this->mmap_base = mmap(NULL, sbuf.st_size, PROT_READ, MAP_SHARED, this->fh, 0)) != (void*)-1 ) {
+ tmp_size = sbuf.st_size; /* may cause truncation - if it does, DON'T mmap! */
+ if ((tmp_size == sbuf.st_size) &&
+ ( (this->mmap_base = mmap(NULL, tmp_size, PROT_READ, MAP_SHARED, this->fh, 0)) != (void*)-1 )) {
this->mmap_on = 1;
this->mmap_curr = this->mmap_base;
this->mmap_len = sbuf.st_size;
+ } else {
+ this->mmap_base = NULL;
}
#endif