@@ -965,37 +965,37 @@ boot_copy_region(struct boot_loader_state *state,
965
965
}
966
966
#endif
967
967
if (IS_ENCRYPTED (hdr )) {
968
- if (off + bytes_copied < hdr -> ih_hdr_size ) {
968
+ uint32_t abs_off = off + bytes_copied ;
969
+ if (abs_off < hdr -> ih_hdr_size ) {
969
970
/* do not decrypt header */
970
- if (off + bytes_copied + chunk_sz > hdr -> ih_hdr_size ) {
971
+ if (abs_off + chunk_sz > hdr -> ih_hdr_size ) {
971
972
/* The lower part of the chunk contains header data */
972
973
blk_off = 0 ;
973
- blk_sz = chunk_sz - (hdr -> ih_hdr_size - off -
974
- bytes_copied );
975
- idx = hdr -> ih_hdr_size - off - bytes_copied ;
974
+ blk_sz = chunk_sz - (hdr -> ih_hdr_size - abs_off );
975
+ idx = hdr -> ih_hdr_size - abs_off ;
976
976
} else {
977
977
/* The chunk contains exclusively header data */
978
978
blk_sz = 0 ; /* nothing to decrypt */
979
979
}
980
980
} else {
981
981
idx = 0 ;
982
982
blk_sz = chunk_sz ;
983
- blk_off = (( off + bytes_copied ) - hdr -> ih_hdr_size ) & 0xf ;
983
+ blk_off = (abs_off - hdr -> ih_hdr_size ) & 0xf ;
984
984
}
985
985
986
986
if (blk_sz > 0 )
987
987
{
988
988
tlv_off = BOOT_TLV_OFF (hdr );
989
- if (off + bytes_copied + chunk_sz > tlv_off ) {
989
+ if (abs_off + chunk_sz > tlv_off ) {
990
990
/* do not decrypt TLVs */
991
- if (off + bytes_copied >= tlv_off ) {
991
+ if (abs_off >= tlv_off ) {
992
992
blk_sz = 0 ;
993
993
} else {
994
- blk_sz = tlv_off - ( off + bytes_copied ) ;
994
+ blk_sz = tlv_off - abs_off ;
995
995
}
996
996
}
997
997
boot_encrypt (BOOT_CURR_ENC (state ), image_index , fap_src ,
998
- (off + bytes_copied + idx ) - hdr -> ih_hdr_size , blk_sz ,
998
+ (abs_off + idx ) - hdr -> ih_hdr_size , blk_sz ,
999
999
blk_off , & buf [idx ]);
1000
1000
}
1001
1001
}
0 commit comments