tmux-CVE-2022-40716.patch 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. From 94da0240d2ba4ad4be2a02adee5d297941aa4acc Mon Sep 17 00:00:00 2001
  2. From: Thomas Gerbet <thomas@gerbet.me>
  3. Date: Sat, 28 Jan 2023 00:24:50 +0100
  4. Subject: [PATCH] tmux: apply patch for CVE-2022-47016
  5. Upstream issues:
  6. https://github.com/tmux/tmux/issues/3312
  7. https://github.com/tmux/tmux/issues/3447
  8. Upstream patch does not apply cleanly on top of 3.3a.
  9. ---
  10. pkgs/tools/misc/tmux/CVE-2022-47016.patch | 72 +++++++++++++++++++++++
  11. pkgs/tools/misc/tmux/default.nix | 5 ++
  12. 2 files changed, 77 insertions(+)
  13. create mode 100644 pkgs/tools/misc/tmux/CVE-2022-47016.patch
  14. diff --git a/control.c b/control.c
  15. index 73286e00..6183a006 100644
  16. --- a/control.c
  17. +++ b/control.c
  18. @@ -775,6 +775,8 @@ control_start(struct client *c)
  19. cs->read_event = bufferevent_new(c->fd, control_read_callback,
  20. control_write_callback, control_error_callback, c);
  21. + if (cs->read_event == NULL)
  22. + fatalx("out of memory");
  23. bufferevent_enable(cs->read_event, EV_READ);
  24. if (c->flags & CLIENT_CONTROLCONTROL)
  25. @@ -782,6 +784,8 @@ control_start(struct client *c)
  26. else {
  27. cs->write_event = bufferevent_new(c->out_fd, NULL,
  28. control_write_callback, control_error_callback, c);
  29. + if (cs->write_event == NULL)
  30. + fatalx("out of memory");
  31. }
  32. bufferevent_setwatermark(cs->write_event, EV_WRITE, CONTROL_BUFFER_LOW,
  33. 0);
  34. diff --git a/file.c b/file.c
  35. index b2f155fe..04a907bf 100644
  36. --- a/file.c
  37. +++ b/file.c
  38. @@ -585,6 +585,8 @@ file_write_open(struct client_files *files, struct tmuxpeer *peer,
  39. cf->event = bufferevent_new(cf->fd, NULL, file_write_callback,
  40. file_write_error_callback, cf);
  41. + if (cf->event == NULL)
  42. + fatalx("out of memory");
  43. bufferevent_enable(cf->event, EV_WRITE);
  44. goto reply;
  45. @@ -744,6 +746,8 @@ file_read_open(struct client_files *files, struct tmuxpeer *peer,
  46. cf->event = bufferevent_new(cf->fd, file_read_callback, NULL,
  47. file_read_error_callback, cf);
  48. + if (cf->event == NULL)
  49. + fatalx("out of memory");
  50. bufferevent_enable(cf->event, EV_READ);
  51. return;
  52. diff --git a/window.c b/window.c
  53. index c0cd9bdc..294a1f08 100644
  54. --- a/window.c
  55. +++ b/window.c
  56. @@ -1042,6 +1042,8 @@ window_pane_set_event(struct window_pane *wp)
  57. wp->event = bufferevent_new(wp->fd, window_pane_read_callback,
  58. NULL, window_pane_error_callback, wp);
  59. + if (wp->event == NULL)
  60. + fatalx("out of memory");
  61. wp->ictx = input_init(wp, wp->event, &wp->palette);
  62. bufferevent_enable(wp->event, EV_READ|EV_WRITE);
  63. --
  64. 2.39.1