[libbluray-devel] meta_parse: check for failed read

hpi1 git at videolan.org
Mon Jan 21 13:02:35 CET 2013


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Mon Jan 21 13:31:15 2013 +0200| [a37d7d9e8b93080b587cbb7402d6a983cfa12d07] | committer: hpi1

meta_parse: check for failed read

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=a37d7d9e8b93080b587cbb7402d6a983cfa12d07
---

 src/libbluray/bdnav/meta_parse.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/libbluray/bdnav/meta_parse.c b/src/libbluray/bdnav/meta_parse.c
index 1a088c8..6bf44dc 100644
--- a/src/libbluray/bdnav/meta_parse.c
+++ b/src/libbluray/bdnav/meta_parse.c
@@ -161,9 +161,13 @@ META_ROOT *meta_parse(const char *device_path)
 
         if (length > 0 && length < MAX_META_FILE_SIZE) {
             file_seek(handle, 0, SEEK_SET);
-            uint8_t *data = malloc(length);
-            int64_t size_read = file_read(handle, data, length);
-            doc = xmlReadMemory((char*)data, size_read, base, NULL, 0);
+            size_t size = (size_t)length;
+            uint8_t *data = malloc(size);
+            size_t size_read = file_read(handle, data, size);
+            if (size != size_read) {
+                BD_DEBUG(DBG_DIR, "Failed to read %s\n", path);
+            } else {
+            doc = xmlReadMemory((char*)data, (int)size, base, NULL, 0);
             if (doc == NULL) {
                 BD_DEBUG(DBG_DIR, "Failed to parse %s\n", path);
                 X_FREE(path);
@@ -179,6 +183,7 @@ META_ROOT *meta_parse(const char *device_path)
             root->dl_entries[i].thumbnails = NULL;
             _parseManifestNode(root_element, &root->dl_entries[i]);
             xmlFreeDoc(doc);
+            }
             X_FREE(data);
         }
         file_close(handle);



More information about the libbluray-devel mailing list