logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git

0009-Avoid-index-ranges.patch (1923B)


  1. From 0663a21f8a5d9d9ffd8e79bfb0c326365d98e384 Mon Sep 17 00:00:00 2001
  2. From: Michael Forney <mforney@mforney.org>
  3. Date: Thu, 30 Jan 2020 22:32:50 -0800
  4. Subject: [PATCH] Avoid index ranges
  5. The change in print_mac.c is not functionally the same, but we
  6. ignore this for now.
  7. ---
  8. src/print_mac.c | 4 +---
  9. src/util.c | 8 ++++----
  10. 2 files changed, 5 insertions(+), 7 deletions(-)
  11. diff --git a/src/print_mac.c b/src/print_mac.c
  12. index cad1013a8..73d7bbe28 100644
  13. --- a/src/print_mac.c
  14. +++ b/src/print_mac.c
  15. @@ -17,8 +17,6 @@
  16. DIAG_PUSH_IGNORE_OVERRIDE_INIT
  17. static uint8_t hwaddr_sizes[] = {
  18. - [0 ... ARPHRD_VSOCKMON] = 255,
  19. -
  20. [ARPHRD_NETROM] = 7 /* AX25_ADDR_LEN */,
  21. [ARPHRD_ETHER] = 6 /* ETH_ALEN */,
  22. /* ARPHRD_EETHER - no actual devices in Linux */
  23. @@ -129,7 +127,7 @@ print_mac_addr(const char *prefix, const uint8_t addr[], size_t size)
  24. static const char *
  25. sprint_hwaddr(const uint8_t hwaddr[], size_t size, uint32_t devtype)
  26. {
  27. - uint8_t sz = (devtype < ARRAY_SIZE(hwaddr_sizes))
  28. + uint8_t sz = (devtype < ARRAY_SIZE(hwaddr_sizes) && hwaddr_sizes[devtype])
  29. ? hwaddr_sizes[devtype] : 255;
  30. return sprint_mac_addr(hwaddr, MIN(size, sz));
  31. diff --git a/src/util.c b/src/util.c
  32. index eb5896eec..e92a25264 100644
  33. --- a/src/util.c
  34. +++ b/src/util.c
  35. @@ -1660,16 +1660,16 @@ dumpstr(struct tcb *const tcp, const kernel_ulong_t addr,
  36. ? 1 + ilog2_klong(len - 1) / HEX_BIT : DUMPSTR_OFFS_MIN_CHARS;
  37. kernel_ulong_t i = 0;
  38. const unsigned char *src;
  39. + char outbuf[DUMPSTR_WIDTH_CHARS + 1];
  40. +
  41. + memset(outbuf, ' ', DUMPSTR_WIDTH_CHARS);
  42. + outbuf[DUMPSTR_WIDTH_CHARS] = '\0';
  43. while (i < len) {
  44. /*
  45. * It is important to overwrite all the byte values, as we
  46. * re-use the buffer in order to avoid its re-initialisation.
  47. */
  48. - static char outbuf[] = {
  49. - [0 ... DUMPSTR_WIDTH_CHARS - 1] = ' ',
  50. - '\0'
  51. - };
  52. char *dst = outbuf;
  53. /* Fetching data from tracee. */
  54. --
  55. 2.44.0