Fixed bugs in ipmi_ek_display_chassis_info_area(),
ipmi_ek_display_product_info_area(), and
ipmi_ekanalyzer_fru_file2structure() where fread was being called to
read one byte of data into a int or long data type.  This would result
in the value being byte swapped since the byte was read into the most
significant byte of the int (ie byte 0) on big endian machines.

Signed-off-by: Dan Gora <d...@adax.com>
---
 ipmitool/lib/ipmi_ekanalyzer.c |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/ipmitool/lib/ipmi_ekanalyzer.c b/ipmitool/lib/ipmi_ekanalyzer.c
index 2fcf4e5..448b308 100644
--- a/ipmitool/lib/ipmi_ekanalyzer.c
+++ b/ipmitool/lib/ipmi_ekanalyzer.c
@@ -2539,6 +2539,7 @@ static void
 ipmi_ek_display_chassis_info_area(FILE * input_file, long offset)
 {
        unsigned char data = 0;
+       unsigned char clen = 0;
        unsigned char ch_type = 0;
        unsigned int len;
        size_t file_offset;
@@ -2561,9 +2562,9 @@ ipmi_ek_display_chassis_info_area(FILE * input_file, long 
offset)
        if ( feof(input_file) )
                return;
 
-       fread (&len, 1, 1, input_file);
+       fread (&clen, 1, 1, input_file);
        /* len is in factor of 8 bytes */
-       len = len * 8;
+       len = clen * 8;
        printf("Area Length: %d\n", len);
            len -= 2;
        if ( feof(input_file) )
@@ -2733,6 +2734,7 @@ static void
 ipmi_ek_display_product_info_area( FILE * input_file, long offset )
 {
        unsigned char data = 0;
+       unsigned char clen = 0;
        unsigned int len;
        size_t file_offset = ftell (input_file);
 
@@ -2754,9 +2756,11 @@ ipmi_ek_display_product_info_area( FILE * input_file, 
long offset )
        if ( feof(input_file) )
                return;
 
-       fread (&len, 1, 1, input_file);
+       /* Have to read this into a char or else
+        * it ends up byte swapped on big endian machines */
+       fread (&clen, 1, 1, input_file);
        /* length is in factor of 8 bytes */
-       len = len * 8;
+       len = clen * 8;
        printf("Area Length: %d\n", len);
        len -= 2; /* -1 byte of format version and -1 byte itself */
        if ( feof(input_file) )
@@ -3885,8 +3889,9 @@ ipmi_ekanalyzer_fru_file2structure( char * filename,
 {
        int return_status = ERROR_STATUS;
        FILE * input_file;
+       char data;
        unsigned char last_record = 0;
-       long multi_offset;
+       int multi_offset;
        int record_count = 0;
 
        input_file = fopen ( filename, "r");
@@ -3896,7 +3901,7 @@ ipmi_ekanalyzer_fru_file2structure( char * filename,
        }
 
        fseek ( input_file, START_DATA_OFFSET, SEEK_SET );
-       fread ( &multi_offset, 1, 1, input_file );
+       fread ( &data, 1, 1, input_file );
        if ( data <= 0 ){
                lprintf(LOG_NOTICE, "There is no multi record in the file %s\n",
                filename);
-- 
1.7.7


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Ipmitool-devel mailing list
Ipmitool-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel

Reply via email to