@@ -197,6 +197,26 @@ START_TEST(test_wb_diff_self_match_extends_to_src_b_end)
197197}
198198END_TEST
199199
200+ START_TEST (test_wb_diff_preserves_trailing_header_margin_for_escape )
201+ {
202+ WB_DIFF_CTX diff_ctx ;
203+ uint8_t src_a [64 ] = {0 };
204+ uint8_t src_b [64 ] = {0 };
205+ uint8_t patch [BLOCK_HDR_SIZE + 2 ] = {0 };
206+ int ret ;
207+
208+ src_b [0 ] = ESC ;
209+
210+ ret = wb_diff_init (& diff_ctx , src_a , sizeof (src_a ), src_b , 1 );
211+ ck_assert_int_eq (ret , 0 );
212+
213+ ret = wb_diff (& diff_ctx , patch , BLOCK_HDR_SIZE + 1 );
214+
215+ ck_assert_int_eq (ret , 0 );
216+ ck_assert_uint_eq (patch [0 ], 0 );
217+ }
218+ END_TEST
219+
200220static void initialize_buffers (uint8_t * src_a , uint8_t * src_b , size_t size )
201221{
202222 uint32_t pseudo_rand = 0 ;
@@ -305,6 +325,7 @@ Suite *patch_diff_suite(void)
305325 tcase_add_test (tc_wolfboot_delta , test_wb_patch_trailing_escape_invalid );
306326 tcase_add_test (tc_wolfboot_delta , test_wb_diff_match_extends_to_src_b_end );
307327 tcase_add_test (tc_wolfboot_delta , test_wb_diff_self_match_extends_to_src_b_end );
328+ tcase_add_test (tc_wolfboot_delta , test_wb_diff_preserves_trailing_header_margin_for_escape );
308329 tcase_add_test (tc_wolfboot_delta , test_wb_patch_and_diff );
309330 suite_add_tcase (s , tc_wolfboot_delta );
310331
0 commit comments