You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2017/11/22 20:40:57 UTC

[GitHub] mkiiskila closed pull request #672: imgmgr; imgmgr_read_info() was not checking image header magic unless

mkiiskila closed pull request #672: imgmgr; imgmgr_read_info() was not checking image header magic unless
URL: https://github.com/apache/mynewt-core/pull/672
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/mgmt/imgmgr/src/imgmgr.c b/mgmt/imgmgr/src/imgmgr.c
index fb4272561..62d73932f 100644
--- a/mgmt/imgmgr/src/imgmgr.c
+++ b/mgmt/imgmgr/src/imgmgr.c
@@ -152,17 +152,19 @@ imgr_read_info(int image_slot, struct image_version *ver, uint8_t *hash,
         goto end;
     }
 
-    if (ver != NULL) {
+    if (ver) {
         memset(ver, 0xff, sizeof(*ver));
-        if (hdr->ih_magic == IMAGE_MAGIC) {
+    }
+    if (hdr->ih_magic == IMAGE_MAGIC) {
+        if (ver) {
             memcpy(ver, &hdr->ih_ver, sizeof(*ver));
-        } else if (hdr->ih_magic == 0xffffffff) {
-            rc = 2;
-            goto end;
-        } else {
-            rc = 1;
-            goto end;
         }
+    } else if (hdr->ih_magic == 0xffffffff) {
+        rc = 2;
+        goto end;
+    } else {
+        rc = 1;
+        goto end;
     }
 
     if (flags) {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services