From f8883cb101061c85c49cc1a3e68b890eab8ab118 Mon Sep 17 00:00:00 2001
From: wdenk <wdenk>
Date: Fri, 4 Feb 2005 15:38:08 +0000
Subject: [PATCH] Fix byteorder problem in usbboot and scsiboot commands.

---
 CHANGELOG         | 2 ++
 common/cmd_scsi.c | 4 ++--
 common/cmd_usb.c  | 4 ++--
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index e3f71e23c6..dc1423eb15 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,8 @@
 Changes for U-Boot 1.1.3:
 ======================================================================
 
+* Fix byteorder problem in usbboot and scsiboot commands.
+
 * Patch by Cajus Hahn, 04 Feb 2005:
   - don't insist on leading '/' for filename in ext2load
   - set default partition to useful value (1) in ext2load
diff --git a/common/cmd_scsi.c b/common/cmd_scsi.c
index 062b1c9cb3..61309f90a4 100644
--- a/common/cmd_scsi.c
+++ b/common/cmd_scsi.c
@@ -269,7 +269,7 @@ int do_scsiboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 
 	hdr = (image_header_t *)addr;
 
-	if (hdr->ih_magic == IH_MAGIC) {
+	if (ntohl(hdr->ih_magic) == IH_MAGIC) {
 		printf("\n** Bad Magic Number **\n");
 		return 1;
 	}
@@ -283,7 +283,7 @@ int do_scsiboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 	}
 
 	print_image_hdr (hdr);
-	cnt = (hdr->ih_size + sizeof(image_header_t));
+	cnt = (ntohl(hdr->ih_size) + sizeof(image_header_t));
 	cnt += info.blksz - 1;
 	cnt /= info.blksz;
 	cnt -= 1;
diff --git a/common/cmd_usb.c b/common/cmd_usb.c
index 3227db99d0..c6b5d140ac 100644
--- a/common/cmd_usb.c
+++ b/common/cmd_usb.c
@@ -387,7 +387,7 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 
 	hdr = (image_header_t *)addr;
 
-	if (hdr->ih_magic != IH_MAGIC) {
+	if (ntohl(hdr->ih_magic) != IH_MAGIC) {
 		printf("\n** Bad Magic Number **\n");
 		return 1;
 	}
@@ -402,7 +402,7 @@ int do_usbboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 
 	print_image_hdr (hdr);
 
-	cnt = (hdr->ih_size + sizeof(image_header_t));
+	cnt = (ntohl(hdr->ih_size) + sizeof(image_header_t));
 	cnt += info.blksz - 1;
 	cnt /= info.blksz;
 	cnt -= 1;
-- 
2.39.5