0001-allocate-space-for-buf-on-heap.patch 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. From d4a405f87fc215c14e610a25b5a6b14060c1ef15 Mon Sep 17 00:00:00 2001
  2. From: Khem Raj <raj.khem@gmail.com>
  3. Date: Wed, 25 Dec 2019 13:53:52 -0800
  4. Subject: [PATCH] allocate space for buf on heap
  5. Avoids
  6. | src/epggrab/module/xmltv.c:204:47: error: '%s' directive output may be truncated writing between 2 and 2147483645 bytes into a region of size 115 [-Werror=format-truncation=]
  7. | 204 | snprintf(buf, sizeof(buf)-1, "ddprogid://%s/%s", mod->id, s);
  8. | | ^~
  9. Upstream-Status: Submitted [https://github.com/tvheadend/tvheadend/pull/1324]
  10. Signed-off-by: Khem Raj <raj.khem@gmail.com>
  11. ---
  12. src/epggrab/module/xmltv.c | 6 ++++--
  13. 1 file changed, 4 insertions(+), 2 deletions(-)
  14. diff --git a/src/epggrab/module/xmltv.c b/src/epggrab/module/xmltv.c
  15. index 34ab05bdb..b1a956614 100644
  16. --- a/src/epggrab/module/xmltv.c
  17. +++ b/src/epggrab/module/xmltv.c
  18. @@ -197,11 +197,12 @@ static void parse_xmltv_dd_progid
  19. (epggrab_module_t *mod, const char *s, char **uri, char **suri,
  20. epg_episode_num_t *epnum)
  21. {
  22. - char buf[128];
  23. if (strlen(s) < 2) return;
  24. + char* buf = (char *)malloc(strlen(s) + strlen(mod->id) + 13);
  25. + buf[strlen(s) + strlen(mod->id) + 12] = '\0';
  26. /* Raw URI */
  27. - snprintf(buf, sizeof(buf)-1, "ddprogid://%s/%s", mod->id, s);
  28. + snprintf(buf, strlen(s) + strlen(mod->id) + 12, "ddprogid://%s/%s", mod->id, s);
  29. /* SH - series without episode id so ignore */
  30. if (strncmp("SH", s, 2))
  31. @@ -219,6 +220,7 @@ static void parse_xmltv_dd_progid
  32. if (buf[e+1]) sscanf(&buf[e+1], "%hu", &(epnum->e_num));
  33. }
  34. }
  35. + free(buf);
  36. }
  37. /**
  38. --
  39. 2.24.1