diff mbox

[2/2] Check return result of sbe_xip_get_section in sbe_xip_image.c

Message ID 1447220287-614-3-git-send-email-stewart@linux.vnet.ibm.com
State Accepted
Headers show

Commit Message

Stewart Smith Nov. 11, 2015, 5:38 a.m. UTC
In the event of failure, stringsSection will be untouched, which
is very likely not a good thing as then we'll just use garbage
in the following line.

Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
---
 libpore/sbe_xip_image.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/libpore/sbe_xip_image.c b/libpore/sbe_xip_image.c
index 800892c565a6..7ee48864432c 100644
--- a/libpore/sbe_xip_image.c
+++ b/libpore/sbe_xip_image.c
@@ -1070,8 +1070,11 @@  xipDecodeToc(void* i_image,
         o_item->iv_toc = i_imageToc;
         o_item->iv_type = hostToc.iv_type;
         o_item->iv_elements = hostToc.iv_elements;
-    
-        sbe_xip_get_section(i_image, SBE_XIP_SECTION_STRINGS, &stringsSection);
+
+        rc = sbe_xip_get_section(i_image, SBE_XIP_SECTION_STRINGS,
+				 &stringsSection);
+        if (rc) break;
+
         o_item->iv_id = 
             (char*)i_image + stringsSection.iv_offset + hostToc.iv_id;