Compare commits

...

No commits in common. "c8s" and "c9-beta" have entirely different histories.
c8s ... c9-beta

12 changed files with 468 additions and 9 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/tmux-2.7.tar.gz
SOURCES/tmux-3.2a.tar.gz

View File

@ -1 +1 @@
a12bb094bf0baf0275b6d5cc718c938639712e97 SOURCES/tmux-2.7.tar.gz
519c08880307ef13c799cb6988b4fd11ec5c2b77 SOURCES/tmux-3.2a.tar.gz

View File

@ -0,0 +1,122 @@
From 369627faddc1bba283c6afc4d473d7a495edb9a7 Mon Sep 17 00:00:00 2001
From: Josh Boyer <jwboyer@redhat.com>
Date: Fri, 7 Apr 2023 07:38:21 -0400
Subject: [PATCH 01/12] Fix memory leaks Backport of upstream commits:
4a753dbefc2e67c218cf41141eaa6afab00f774a
3c65475561b25073c3b7dcbb0b6498a0535ecd59
a9ac61469175e45c8ba58ae0360306aa06c0cd59
72d905f32c53ea1304b4b3206383502a23cfc0fd
---
cmd-display-menu.c | 6 +++++-
cmd-source-file.c | 4 +++-
format.c | 4 ++--
key-bindings.c | 5 ++++-
popup.c | 1 +
5 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/cmd-display-menu.c b/cmd-display-menu.c
index de423e68..d61fedbb 100644
--- a/cmd-display-menu.c
+++ b/cmd-display-menu.c
@@ -248,6 +248,7 @@ cmd_display_menu_get_position(struct client *tc, struct cmdq_item *item,
log_debug("%s: -y: %s = %s = %u", __func__, yp, p, *py);
free(p);
+ format_free(ft);
return (1);
}
@@ -391,7 +392,10 @@ cmd_display_popup_exec(struct cmd *self, struct cmdq_item *item)
else if (args_has(args, 'E'))
flags |= POPUP_CLOSEEXIT;
if (popup_display(flags, item, px, py, w, h, shellcmd, argc, argv, cwd,
- tc, s, NULL, NULL) != 0)
+ tc, s, NULL, NULL) != 0) {
+ free(cwd);
return (CMD_RETURN_NORMAL);
+ }
+ free(cwd);
return (CMD_RETURN_WAIT);
}
diff --git a/cmd-source-file.c b/cmd-source-file.c
index c1eeba58..296c31f9 100644
--- a/cmd-source-file.c
+++ b/cmd-source-file.c
@@ -176,15 +176,17 @@ cmd_source_file_exec(struct cmd *self, struct cmdq_item *item)
cmdq_error(item, "%s: %s", path, error);
retval = CMD_RETURN_ERROR;
}
+ globfree(&g);
free(pattern);
continue;
}
- free(expand);
free(pattern);
for (j = 0; j < g.gl_pathc; j++)
cmd_source_file_add(cdata, g.gl_pathv[j]);
+ globfree(&g);
}
+ free(expand);
cdata->after = item;
cdata->retval = retval;
diff --git a/format.c b/format.c
index 512df009..673a6085 100644
--- a/format.c
+++ b/format.c
@@ -3382,12 +3382,12 @@ found:
}
if (modifiers & FORMAT_QUOTE_SHELL) {
saved = found;
- found = xstrdup(format_quote_shell(saved));
+ found = format_quote_shell(saved);
free(saved);
}
if (modifiers & FORMAT_QUOTE_STYLE) {
saved = found;
- found = xstrdup(format_quote_style(saved));
+ found = format_quote_style(saved);
free(saved);
}
return (found);
diff --git a/key-bindings.c b/key-bindings.c
index 467c7f93..4df0cddc 100644
--- a/key-bindings.c
+++ b/key-bindings.c
@@ -187,6 +187,7 @@ key_bindings_add(const char *name, key_code key, const char *note, int repeat,
{
struct key_table *table;
struct key_binding *bd;
+ char *s;
table = key_bindings_get_table(name, 1);
@@ -216,8 +217,10 @@ key_bindings_add(const char *name, key_code key, const char *note, int repeat,
bd->flags |= KEY_BINDING_REPEAT;
bd->cmdlist = cmdlist;
+ s = cmd_list_print(bd->cmdlist, 0);
log_debug("%s: %#llx %s = %s", __func__, bd->key,
- key_string_lookup_key(bd->key, 1), cmd_list_print(bd->cmdlist, 0));
+ key_string_lookup_key(bd->key, 1), s);
+ free(s);
}
void
diff --git a/popup.c b/popup.c
index 509d182d..a98cc42a 100644
--- a/popup.c
+++ b/popup.c
@@ -142,6 +142,7 @@ popup_draw_cb(struct client *c, __unused struct screen_redraw_ctx *ctx0)
tty_draw_line(tty, &s, 0, i, pd->sx, px, py + i,
&grid_default_cell, NULL);
}
+ screen_free(&s);
c->overlay_check = popup_check_cb;
}
--
2.31.1

View File

@ -0,0 +1,32 @@
From b4ae1931b2170d783f9a946e6f1983e3d0976107 Mon Sep 17 00:00:00 2001
From: Josh Boyer <jwboyer@redhat.com>
Date: Fri, 7 Apr 2023 11:33:56 -0400
Subject: [PATCH 02/12] Close file stream on error
---
file.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/file.c b/file.c
index 974c8a37..9368b4f4 100644
--- a/file.c
+++ b/file.c
@@ -391,6 +391,7 @@ file_read(struct client *c, const char *path, client_file_cb cb, void *cbdata)
size = fread(buffer, 1, sizeof buffer, f);
if (evbuffer_add(cf->buffer, buffer, size) != 0) {
cf->error = ENOMEM;
+ fclose(f);
goto done;
}
if (size != sizeof buffer)
@@ -398,6 +399,7 @@ file_read(struct client *c, const char *path, client_file_cb cb, void *cbdata)
}
if (ferror(f)) {
cf->error = EIO;
+ fclose(f);
goto done;
}
fclose(f);
--
2.31.1

View File

@ -0,0 +1,32 @@
From 5e83beff72bed8f8e96fbfe63b7a814d34205354 Mon Sep 17 00:00:00 2001
From: Josh Boyer <jwboyer@redhat.com>
Date: Fri, 7 Apr 2023 11:54:51 -0400
Subject: [PATCH 03/12] Fix memory leak with time_format
---
format.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/format.c b/format.c
index 673a6085..01204b8a 100644
--- a/format.c
+++ b/format.c
@@ -4416,6 +4416,7 @@ done:
free(sub);
format_free_modifiers(list, count);
free(copy0);
+ free(time_format);
return (0);
fail:
@@ -4424,6 +4425,7 @@ fail:
free(sub);
format_free_modifiers(list, count);
free(copy0);
+ free(time_format);
return (-1);
}
--
2.31.1

View File

@ -0,0 +1,33 @@
From 777edc3d865ac52837072da904748a6f70d36b8b Mon Sep 17 00:00:00 2001
From: Josh Boyer <jwboyer@redhat.com>
Date: Fri, 7 Apr 2023 12:22:06 -0400
Subject: [PATCH 04/12] Fix memory leak with condition on error path
---
format.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/format.c b/format.c
index 01204b8a..6f057b5e 100644
--- a/format.c
+++ b/format.c
@@ -4019,7 +4019,7 @@ format_replace(struct format_expand_state *es, const char *key, size_t keylen,
struct window_pane *wp = ft->wp;
const char *errstr, *copy, *cp, *marker = NULL;
const char *time_format = NULL;
- char *copy0, *condition, *found, *new;
+ char *copy0, *condition = NULL, *found, *new;
char *value, *left, *right, c;
size_t valuelen;
int modifiers = 0, limit = 0, width = 0;
@@ -4425,6 +4425,7 @@ fail:
free(sub);
format_free_modifiers(list, count);
free(copy0);
+ free(condition);
free(time_format);
return (-1);
}
--
2.31.1

View File

@ -0,0 +1,24 @@
From 47d2223dd090b365246709f9c20ce8684259590e Mon Sep 17 00:00:00 2001
From: Josh Boyer <jwboyer@redhat.com>
Date: Fri, 7 Apr 2023 12:36:06 -0400
Subject: [PATCH 05/12] Free s even if there is no expanded format
---
menu.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/menu.c b/menu.c
index 48c9ed2f..137c8c8d 100644
--- a/menu.c
+++ b/menu.c
@@ -78,6 +78,7 @@ menu_add_item(struct menu *menu, const struct menu_item *item,
s = format_single(qitem, item->name, c, NULL, NULL, NULL);
if (*s == '\0') { /* no item if empty after format expanded */
menu->count--;
+ free(s);
return;
}
if (*s != '-' && item->key != KEYC_UNKNOWN && item->key != KEYC_NONE) {
--
2.31.1

View File

@ -0,0 +1,32 @@
From 8a6f2d39bf883a05145651e04ae1bdb2fbba8c34 Mon Sep 17 00:00:00 2001
From: Josh Boyer <jwboyer@redhat.com>
Date: Fri, 7 Apr 2023 12:50:51 -0400
Subject: [PATCH 06/12] Fix spm memory leak
---
status.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/status.c b/status.c
index f4418500..116b28c0 100644
--- a/status.c
+++ b/status.c
@@ -1628,6 +1628,7 @@ status_prompt_complete_window_menu(struct client *c, struct session *s,
}
if (size == 0) {
menu_free(menu);
+ free(spm);
return (NULL);
}
if (size == 1) {
@@ -1638,6 +1639,7 @@ status_prompt_complete_window_menu(struct client *c, struct session *s,
} else
tmp = list[0];
free(list);
+ free(spm);
return (tmp);
}
if (height > size)
--
2.31.1

View File

@ -0,0 +1,27 @@
From 43f00a273beaf63778cb34c925489f0f003ebef7 Mon Sep 17 00:00:00 2001
From: Josh Boyer <jwboyer@redhat.com>
Date: Fri, 7 Apr 2023 13:02:37 -0400
Subject: [PATCH 07/12] Don't leak the original value memory
---
window-customize.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/window-customize.c b/window-customize.c
index 34a13f73..50cfbdf7 100644
--- a/window-customize.c
+++ b/window-customize.c
@@ -806,6 +806,10 @@ window_customize_draw_option(struct window_customize_modedata *data,
break;
}
}
+
+ free(value);
+ value = NULL;
+
if (wo != NULL && options_owner(o) != wo) {
parent = options_get_only(wo, name);
if (parent != NULL) {
--
2.31.1

View File

@ -0,0 +1,41 @@
From c4860205ea28136a75bfbfb5f70a793770c73c82 Mon Sep 17 00:00:00 2001
From: Josh Boyer <jwboyer@redhat.com>
Date: Fri, 7 Apr 2023 13:05:09 -0400
Subject: [PATCH 08/12] Don't leak expanded
---
window-customize.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/window-customize.c b/window-customize.c
index 50cfbdf7..7d3cbb18 100644
--- a/window-customize.c
+++ b/window-customize.c
@@ -658,7 +658,7 @@ window_customize_draw_option(struct window_customize_modedata *data,
struct grid_cell gc;
const char **choice, *text, *name;
const char *space = "", *unit = "";
- char *value = NULL, *expanded;
+ char *value = NULL, *expanded = NULL;
char *default_value = NULL;
char choices[256] = "";
struct cmd_find_state fs;
@@ -745,6 +745,7 @@ window_customize_draw_option(struct window_customize_modedata *data,
goto out;
}
free(expanded);
+ expanded = NULL;
}
if (oe != NULL && oe->type == OPTIONS_TABLE_CHOICE) {
for (choice = oe->choices; *choice != NULL; choice++) {
@@ -835,6 +836,7 @@ window_customize_draw_option(struct window_customize_modedata *data,
out:
free(value);
free(default_value);
+ free(expanded);
format_free(ft);
}
--
2.31.1

View File

@ -0,0 +1,26 @@
From aea74c289c6000b86964ad0bb9ac1a05bba2456a Mon Sep 17 00:00:00 2001
From: Josh Boyer <jwboyer@redhat.com>
Date: Fri, 7 Apr 2023 16:29:55 -0400
Subject: [PATCH 09/12] Fix buf memory leak
---
cmd-capture-pane.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cmd-capture-pane.c b/cmd-capture-pane.c
index 6f37bc8f..341d1048 100644
--- a/cmd-capture-pane.c
+++ b/cmd-capture-pane.c
@@ -226,8 +226,8 @@ cmd_capture_pane_exec(struct cmd *self, struct cmdq_item *item)
}
file_print_buffer(c, buf, len);
file_print(c, "\n");
- free(buf);
}
+ free(buf);
} else {
bufname = NULL;
if (args_has(args, 'b'))
--
2.31.1

View File

@ -1,11 +1,10 @@
%global _hardened_build 1
Name: tmux
Version: 2.7
Release: 1%{?dist}
Version: 3.2a
Release: 5%{?dist}
Summary: A terminal multiplexer
Group: Applications/System
# Most of the source is ISC licensed; some of the files in compat/ are 2 and
# 3 clause BSD licensed.
License: ISC and BSD
@ -13,10 +12,25 @@ URL: https://tmux.github.io/
Source0: https://github.com/tmux/%{name}/releases/download/%{version}/%{name}-%{version}.tar.gz
# Examples has been removed - so include the bash_completion here
Source1: bash_completion_tmux.sh
Patch1: 0001-Fix-memory-leaks.patch
Patch2: 0002-Close-file-stream-on-error.patch
Patch3: 0003-Fix-memory-leak-with-time_format.patch
Patch4: 0004-Fix-memory-leak-with-condition-on-error-path.patch
Patch5: 0005-Free-s-even-if-there-is-no-expanded-format.patch
Patch6: 0006-Fix-spm-memory-leak.patch
Patch7: 0007-Don-t-leak-the-original-value-memory.patch
Patch8: 0008-Don-t-leak-expanded.patch
Patch9: 0009-Fix-buf-memory-leak.patch
BuildRequires: make
BuildRequires: gcc
BuildRequires: ncurses-devel
BuildRequires: libevent-devel
BuildRequires: bison
BuildRequires: automake
BuildRequires: autoconf
BuildRequires: pkgconfig(libevent)
BuildRequires: pkgconfig(tinfo)
BuildRequires: pkgconfig(ncurses)
BuildRequires: pkgconfig(ncursesw)
BuildRequires: libutempter-devel
%description
@ -26,9 +40,12 @@ intended to be a simple, modern, BSD-licensed alternative to programs such
as GNU Screen.
%prep
%autosetup
%setup
%autopatch
%build
autoreconf -f -i -v
%configure
%make_build
@ -58,12 +75,85 @@ if [ "$1" = 0 ] && [ -f %{_sysconfdir}/shells ] ; then
fi
%files
%doc CHANGES TODO
%doc CHANGES
%doc example_tmux.conf
%{_bindir}/tmux
%{_mandir}/man1/tmux.1.*
%{_datadir}/bash-completion/completions/tmux
%changelog
* Mon Apr 10 2023 Josh Boyer <jwboyer@redhat.com> - 3.2a-5
- Backport a number of memory leak fixes
Resolves: rhbz#1938885
* Fri Dec 03 2021 David Cantrell <dcantrell@redhat.com> - 3.2a-4
- Rebuild
Resolves: rhbz#2003007
* Mon Sep 27 2021 David Cantrell <dcantrell@redhat.com> - 3.2a-3
- Rebuild
Related: rhbz#1910707
* Wed Sep 22 2021 David Cantrell <dcantrell@redhat.com> - 3.2a-2
- Ensure gating test files are present in the source repo
Related: rhbz#1910707
* Wed Sep 01 2021 David Cantrell <dcantrell@redhat.com> - 3.2a-1
- Upgrade to tmux-3.2a (CVE-2020-27347)
Resolves: rhbz#1910707
* Tue Aug 10 2021 Mohan Boddu <mboddu@redhat.com> - 3.1c-4
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 3.1c-3
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.1c-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Mon Jan 4 2021 Filipe Rosset <rosset.filipe@gmail.com> - 3.1c-1
- Update to 3.1c
* Wed Sep 16 2020 David Cantrell <dcantrell@redhat.com> - 3.1-3
- Rebuild for new libevent
* Fri Jul 17 2020 Andrew Spiers <andrew@andrewspiers.net> - 3.1-2
- Include upstream example config file
Resolves: rhbz#1741836
* Wed Apr 29 2020 Filipe Rosset <rosset.filipe@gmail.com> - 3.1-1
- Update to 3.1 fixes rhbz#1715313
* Fri Jan 31 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.0a-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Tue Dec 03 2019 Brian C. Lane <bcl@redhat.com> - 3.0a-1
- New upstream release v3.0a
Resolves: rhbz#1715313
* Sat Jul 27 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.9a-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Sun May 12 2019 Filipe Rosset <rosset.filipe@gmail.com> - 2.9a-2
- update to version 2.9a, fixes rhbz #1692933
- ChangeLog https://raw.githubusercontent.com/tmux/tmux/2.9/CHANGES
- removed upstreamed patch
* Sun Feb 03 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.8-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Thu Nov 22 2018 Filipe Rosset <rosset.filipe@gmail.com> - 2.8-2
- fixes rhbz #1652128 CVE-2018-19387
- tmux: NULL Pointer Dereference in format_cb_pane_tabs in format.c
* Fri Oct 19 2018 Filipe Rosset <rosset.filipe@gmail.com> - 2.8-1
- update to version 2.8
- ChangeLog https://raw.githubusercontent.com/tmux/tmux/2.8/CHANGES
* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.7-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Thu Apr 19 2018 Filipe Rosset <rosset.filipe@gmail.com> - 2.7-1
- update to version 2.7, fixes rhbz #1486507
- removed upstreamed patches + spec modernization