[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Libcdio-devel] [PATCH] fix file offset out of bounds when reading multi

From: Pete Batard
Subject: [Libcdio-devel] [PATCH] fix file offset out of bounds when reading multiple UDF files
Date: Mon, 23 Jan 2012 00:01:52 +0000
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0) Gecko/20111222 Thunderbird/9.0.1

If you followed the instructions from the previous e-mail and tried to run the extract sample against the Windows 8 preview UDF, this is what you get:

# ./extract /mnt/extra/WindowsDeveloperPreview-64bit-English-Developer.iso /mnt/data/test/ --DEBUG: source name /mnt/extra/WindowsDeveloperPreview-64bit-English-Developer.iso is not recognized as a TOC file
--DEBUG: opened source...
INFO: Image not recognized as either version 5.0 or version 5.5.x-6.x type NRG
--DEBUG: closed source...
--DEBUG: source name /mnt/extra/WindowsDeveloperPreview-64bit-English-Developer.iso is not recognized as a NRG image
--DEBUG: opened source...
Volume id: UDF Volume
Volume set id: UDF Volume
Partition number: 2989
Extracting: /mnt/data/test//
Extracting: /mnt/data/test//autorun.inf
Extracting: /mnt/data/test//boot
Extracting: /mnt/data/test//boot/
Extracting: /mnt/data/test//boot/bcd
Extracting: /mnt/data/test//boot/boot.sdi
File offset out of bounds
  Error reading UDF file /boot/boot.sdi
--DEBUG: closed source...

Analysis shows that the issue is due to the p_udf->i_position attribute not being reset when accessing files sequentially (i.e. on subsequent file access the UDF file offset will be set close to the size of the previous file instead of zero) which eventually results in an out of bound offset. The attached patch fixes this.

Again, I'll be holding on pushing this patch for a day or two unless I get a green light.


>From fb55e37d3d832ad2004bb020a724d243e338235f Mon Sep 17 00:00:00 2001
From: Pete Batard <address@hidden>
Date: Fri, 20 Jan 2012 16:43:57 +0000
Subject: [PATCH] Fix offset not being reset for sequential UDF file access

 lib/udf/udf_fs.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/lib/udf/udf_fs.c b/lib/udf/udf_fs.c
index e5900c7..dcd6e53 100644
--- a/lib/udf/udf_fs.c
+++ b/lib/udf/udf_fs.c
@@ -236,7 +236,10 @@ udf_fopen(udf_dirent_t *p_udf_root, const char *psz_name)
   if (p_udf_root) {
     char tokenline[udf_MAX_PATHLEN];
     char *psz_token;
+    /* file position must be reset when accessing a new file */
+    p_udf_root->p_udf->i_position = 0;
     strncpy(tokenline, psz_name, udf_MAX_PATHLEN);
     psz_token = strtok(tokenline, udf_PATH_DELIMITERS);
     if (psz_token) {
@@ -612,7 +615,10 @@ udf_readdir(udf_dirent_t *p_udf_dirent)
     return NULL;
+  /* file position must be reset when accessing a new file */
   p_udf = p_udf_dirent->p_udf;
+  p_udf->i_position = 0;
   if (p_udf_dirent->fid) { 
     /* advance to next File Identifier Descriptor */
     /* FIXME: need to advance file entry (fe) as well.  */

reply via email to

[Prev in Thread] Current Thread [Next in Thread]