0002-Fix-elf_cvt_gunhash-if-dest-and-src-are-same.patch 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. From f8e4118b60a9b54950437006a82b4047f38f5347 Mon Sep 17 00:00:00 2001
  2. From: Hongxu Jia <hongxu.jia@windriver.com>
  3. Date: Tue, 15 Aug 2017 17:13:59 +0800
  4. Subject: [PATCH] Fix elf_cvt_gunhash if dest and src are same.
  5. Upstream-Status: Pending
  6. The 'dest' and 'src' can be same, we need to save the value of src32[2]
  7. before swaping it.
  8. Signed-off-by: Baoshan Pang <BaoShan.Pang@windriver.com>
  9. Rebase to 0.170
  10. Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
  11. ---
  12. libelf/gnuhash_xlate.h | 3 ++-
  13. 1 file changed, 2 insertions(+), 1 deletion(-)
  14. diff --git a/libelf/gnuhash_xlate.h b/libelf/gnuhash_xlate.h
  15. index 6faf113..04d9ca1 100644
  16. --- a/libelf/gnuhash_xlate.h
  17. +++ b/libelf/gnuhash_xlate.h
  18. @@ -40,6 +40,7 @@ elf_cvt_gnuhash (void *dest, const void *src, size_t len, int encode)
  19. words. We must detangle them here. */
  20. Elf32_Word *dest32 = dest;
  21. const Elf32_Word *src32 = src;
  22. + Elf32_Word save_src32_2 = src32[2]; // dest could be equal to src
  23. /* First four control words, 32 bits. */
  24. for (unsigned int cnt = 0; cnt < 4; ++cnt)
  25. @@ -50,7 +51,7 @@ elf_cvt_gnuhash (void *dest, const void *src, size_t len, int encode)
  26. len -= 4;
  27. }
  28. - Elf32_Word bitmask_words = encode ? src32[2] : dest32[2];
  29. + Elf32_Word bitmask_words = encode ? save_src32_2 : dest32[2];
  30. /* Now the 64 bit words. */
  31. Elf64_Xword *dest64 = (Elf64_Xword *) &dest32[4];