diff options
author | madmonkey <madfkingmonkey@gmail.com> | 2017-03-01 21:54:12 +0300 |
---|---|---|
committer | madmonkey <madfkingmonkey@gmail.com> | 2017-03-01 21:54:12 +0300 |
commit | 2df54929d86c75b39971c688fd816c80ca74644c (patch) | |
tree | 4685e22c76fbbb0123672c639f48ffea2c30954b | |
parent | 9d16ffd1ecc8cb5c2fa5a5fbc7ef35745e52d154 (diff) |
uboot checksum check/fix added
-rw-r--r-- | sntool/sntool.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/sntool/sntool.cpp b/sntool/sntool.cpp index 3aaa51a..22aa582 100644 --- a/sntool/sntool.cpp +++ b/sntool/sntool.cpp @@ -121,16 +121,16 @@ int checksum(const char*in,int fix) fs=loadFile(in,data); uint32_t*data32=reinterpret_cast<uint32_t*>(data); - if((fs<32)||(memcmp(data+4,"eGON.BT",7)!=0)) + if((fs<32)||((memcmp(data+4,"eGON.BT",7)!=0)&&(memcmp(data+4,"uboot",6)!=0))) { - printf("eGON header is not found\n"); + printf("header is not found\n"); return 1; } - uint32_t l=le32toh(data32[4]); + uint32_t l=le32toh(data32[(memcmp(data+4,"uboot",6)==0)?5:4]); if((l>fs)||((l%4)!=0)) { - printf("bad length in the eGON header\n"); + printf("bad length in header\n"); return 1; } l/=4; @@ -176,6 +176,7 @@ int split(const char*in) fs=offs; while(data[fs-1]==0xff) --fs; + data32[3]=0; data32[5]=0; data32[6]=0; saveFile(in,data,fs); @@ -205,6 +206,7 @@ int join(const char*in0,const char*in1) data[fs0++]=0xff; data32[5]=htole32(fs0); saveFile(in0,data,fs0); + checksum(in0,1); return 0; } return 1; |