From 860a91dd2f05f0fa935e4429ed91fd8b72c911d0 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Thu, 17 Aug 2017 08:49:28 +0200 Subject: [PATCH] Preventing NULL dereference if root directory bears a RRIP RE entry --- libisofs/fs_image.c | 10 ++++++++++ libisofs/libisofs.h | 3 +++ libisofs/messages.c | 2 ++ 3 files changed, 15 insertions(+) diff --git a/libisofs/fs_image.c b/libisofs/fs_image.c index 72b4141..6d2309b 100644 --- a/libisofs/fs_image.c +++ b/libisofs/fs_image.c @@ -1699,6 +1699,12 @@ if (name != NULL && !namecont) { */ susp_iter_free(iter); free(name); + if (flag & 1) { + ret = iso_rr_msg_submit(fsdata, 3, ISO_NO_ROOT_DIR, 0, + "Root directory is marked by RRIP RE as relocated"); + ret= ISO_NO_ROOT_DIR; + goto ex; + } {ret = 0; goto ex;} /* it's not an error */ } else if (SUSP_SIG(sue, 'C', 'L')) { /* @@ -5734,6 +5740,10 @@ int iso_image_import(IsoImage *image, IsoDataSource *src, iso_filesystem_unref(fs); return ret; } + if (newroot == NULL) { + iso_filesystem_unref(fs); + return ISO_NO_ROOT_DIR; + } /* Lookup character set even if no AAIP loading is enabled */ ret = iso_file_source_get_aa_string(newroot, &aa_string, 2); diff --git a/libisofs/libisofs.h b/libisofs/libisofs.h index 21c18f2..3c47793 100644 --- a/libisofs/libisofs.h +++ b/libisofs/libisofs.h @@ -8880,6 +8880,9 @@ int iso_conv_name_chars(IsoWriteOpts *opts, char *name, size_t name_len, (FAILURE, HIGH, -417) */ #define ISO_BAD_GPT_GUID_MODE 0xE830FE5F +/** Unable to obtain root directory (FATAL,HIGH, -418) */ +#define ISO_NO_ROOT_DIR 0xF030FE5E + /* Internal developer note: Place new error codes directly above this comment. diff --git a/libisofs/messages.c b/libisofs/messages.c index 6aedba6..f97e2ba 100644 --- a/libisofs/messages.c +++ b/libisofs/messages.c @@ -547,6 +547,8 @@ const char *iso_error_to_msg(int errcode) return "Cannot derive GPT GUID from undefined pseudo-UUID volume timestamp"; case ISO_BAD_GPT_GUID_MODE: return "Unrecognized GPT disk GUID setup mode"; + case ISO_NO_ROOT_DIR: + return "Unable to obtain root directory"; default: return "Unknown error"; }