@@ -1743,13 +1743,13 @@ static int base_diff(const char *f_base, uint8_t *pubkey, uint32_t pubkey_sz, in
17431743 int r ;
17441744 uint32_t patch_sz , patch_inv_sz ;
17451745 uint32_t patch_inv_off ;
1746- uint32_t delta_base_version = 0 ;
1747- char * base_ver_p , * base_ver_e ;
1746+ uint32_t * delta_base_version = NULL ;
1747+ uint16_t delta_base_version_sz = 0 ;
17481748 WB_DIFF_CTX diff_ctx ;
17491749 int ret = -1 ;
17501750 int io_sz ;
17511751 uint8_t * base_hash = NULL ;
1752- uint32_t base_hash_sz = 0 ;
1752+ uint16_t base_hash_sz = 0 ;
17531753 uint32_t wolfboot_sector_size = 0 ;
17541754 uint32_t blksz ;
17551755
@@ -1804,24 +1804,12 @@ static int base_diff(const char *f_base, uint8_t *pubkey, uint32_t pubkey_sz, in
18041804#endif
18051805
18061806 /* Check base image version */
1807- base_ver_p = strstr (f_base , "_v" );
1808- if (base_ver_p ) {
1809- base_ver_p += 2 ;
1810- base_ver_e = strchr (base_ver_p , '_' );
1811- if (base_ver_e ) {
1812- long long retval ;
1813- retval = strtoll (base_ver_p , NULL , 10 );
1814- if (retval < 0 )
1815- delta_base_version = 0 ;
1816- else
1817- delta_base_version = (uint32_t )(retval & 0xFFFFFFFF );
1818- }
1819- }
1820- if (delta_base_version == 0 ) {
1807+ delta_base_version_sz = sign_tool_find_header ((uint8_t * )base + 8 , HDR_VERSION , (void * )& delta_base_version );
1808+ if ((delta_base_version_sz != sizeof (uint32_t )) || (* delta_base_version == 0 )) {
18211809 printf ("Could not read firmware version from base file %s\n" , f_base );
18221810 goto cleanup ;
18231811 } else {
1824- printf ("Delta base version: %u\n" , delta_base_version );
1812+ printf ("Delta base version: %u\n" , * delta_base_version );
18251813 }
18261814
18271815 /* Retrieve the hash digest of the base image */
@@ -1986,7 +1974,7 @@ static int base_diff(const char *f_base, uint8_t *pubkey, uint32_t pubkey_sz, in
19861974 /* Create delta file, with header, from the resulting patch */
19871975
19881976 ret = make_header_delta (pubkey , pubkey_sz , wolfboot_delta_file , CMD .output_diff_file ,
1989- delta_base_version , patch_sz , patch_inv_off , patch_inv_sz , base_hash , base_hash_sz );
1977+ * delta_base_version , patch_sz , patch_inv_off , patch_inv_sz , base_hash , base_hash_sz );
19901978
19911979cleanup :
19921980 if (dest ) {
0 commit comments