[weechat] fix bz#875181
Paul Komkoff
stingray at fedoraproject.org
Fri Nov 9 17:57:42 UTC 2012
commit 9fdb9456f73453f51ff7b75516231f7574e7a46b
Author: Paul P. Komkoff <i at stingr.net>
Date: Fri Nov 9 21:57:32 2012 +0400
fix bz#875181
weechat-fix-0.patch | 142 +++++++++++++++++++++++++++++++++++++++++++++++++++
weechat.spec | 7 ++-
2 files changed, 148 insertions(+), 1 deletions(-)
---
diff --git a/weechat-fix-0.patch b/weechat-fix-0.patch
new file mode 100644
index 0000000..5ad3d9a
--- /dev/null
+++ b/weechat-fix-0.patch
@@ -0,0 +1,142 @@
+From 9453e81baa7935db82a0b765a47cba772aba730d Mon Sep 17 00:00:00 2001
+From: Sebastien Helleu <flashcode at flashtux.org>
+Date: Fri, 09 Nov 2012 17:10:42 +0000
+Subject: irc: fix crash when decoding IRC colors in strings (bug #37704)
+
+---
+diff --git a/src/plugins/irc/irc-color.c b/src/plugins/irc/irc-color.c
+index 3693241..6e72fd3 100644
+--- a/src/plugins/irc/irc-color.c
++++ b/src/plugins/irc/irc-color.c
+@@ -62,13 +62,15 @@ char *irc_color_to_weechat[IRC_NUM_COLORS] =
+ char *
+ irc_color_decode (const char *string, int keep_colors)
+ {
+- unsigned char *out, *ptr_string;
+- int out_length, length, out_pos;
+- char str_fg[3], str_bg[3], str_color[128], str_key[128];
++ unsigned char *out, *out2, *ptr_string;
++ int out_length, length, out_pos, length_to_add;
++ char str_fg[3], str_bg[3], str_color[128], str_key[128], str_to_add[128];
+ const char *remapped_color;
+ int fg, bg, bold, reverse, italic, underline, rc;
+
+ out_length = (strlen (string) * 2) + 1;
++ if (out_length < 128)
++ out_length = 128;
+ out = malloc (out_length);
+ if (!out)
+ return NULL;
+@@ -80,20 +82,27 @@ irc_color_decode (const char *string, int keep_colors)
+
+ ptr_string = (unsigned char *)string;
+ out[0] = '\0';
++ out_pos = 0;
+ while (ptr_string && ptr_string[0])
+ {
++ str_to_add[0] = '\0';
+ switch (ptr_string[0])
+ {
+ case IRC_COLOR_BOLD_CHAR:
+ if (keep_colors)
+- strcat ((char *)out,
+- weechat_color((bold) ? "-bold" : "bold"));
++ {
++ snprintf (str_to_add, sizeof (str_to_add), "%s",
++ weechat_color ((bold) ? "-bold" : "bold"));
++ }
+ bold ^= 1;
+ ptr_string++;
+ break;
+ case IRC_COLOR_RESET_CHAR:
+ if (keep_colors)
+- strcat ((char *)out, weechat_color("reset"));
++ {
++ snprintf (str_to_add, sizeof (str_to_add), "%s",
++ weechat_color ("reset"));
++ }
+ bold = 0;
+ reverse = 0;
+ italic = 0;
+@@ -106,22 +115,28 @@ irc_color_decode (const char *string, int keep_colors)
+ case IRC_COLOR_REVERSE_CHAR:
+ case IRC_COLOR_REVERSE2_CHAR:
+ if (keep_colors)
+- strcat ((char *)out,
+- weechat_color((reverse) ? "-reverse" : "reverse"));
++ {
++ snprintf (str_to_add, sizeof (str_to_add), "%s",
++ weechat_color ((reverse) ? "-reverse" : "reverse"));
++ }
+ reverse ^= 1;
+ ptr_string++;
+ break;
+ case IRC_COLOR_ITALIC_CHAR:
+ if (keep_colors)
+- strcat ((char *)out,
+- weechat_color((italic) ? "-italic" : "italic"));
++ {
++ snprintf (str_to_add, sizeof (str_to_add), "%s",
++ weechat_color ((italic) ? "-italic" : "italic"));
++ }
+ italic ^= 1;
+ ptr_string++;
+ break;
+ case IRC_COLOR_UNDERLINE_CHAR:
+ if (keep_colors)
+- strcat ((char *)out,
+- weechat_color((underline) ? "-underline" : "underline"));
++ {
++ snprintf (str_to_add, sizeof (str_to_add), "%s",
++ weechat_color ((underline) ? "-underline" : "underline"));
++ }
+ underline ^= 1;
+ ptr_string++;
+ break;
+@@ -194,22 +209,39 @@ irc_color_decode (const char *string, int keep_colors)
+ (bg >= 0) ? "," : "",
+ (bg >= 0) ? irc_color_to_weechat[bg] : "");
+ }
+- strcat ((char *)out, weechat_color(str_color));
++ snprintf (str_to_add, sizeof (str_to_add), "%s",
++ weechat_color (str_color));
+ }
+ else
+- strcat ((char *)out, weechat_color("resetcolor"));
++ {
++ snprintf (str_to_add, sizeof (str_to_add), "%s",
++ weechat_color ("resetcolor"));
++ }
+ }
+ break;
+ default:
+ length = weechat_utf8_char_size ((char *)ptr_string);
+ if (length == 0)
+ length = 1;
+- out_pos = strlen ((char *)out);
+- memcpy (out + out_pos, ptr_string, length);
+- out[out_pos + length] = '\0';
++ memcpy (str_to_add, ptr_string, length);
++ str_to_add[length] = '\0';
+ ptr_string += length;
+ break;
+ }
++ if (str_to_add[0])
++ {
++ length_to_add = strlen (str_to_add);
++ if (out_pos + length_to_add >= out_length)
++ {
++ out_length *= 2;
++ out2 = realloc (out, out_length);
++ if (!out2)
++ return (char *)out;
++ out = out2;
++ }
++ memcpy (out + out_pos, str_to_add, length_to_add + 1);
++ out_pos += length_to_add;
++ }
+ }
+
+ return (char *)out;
+--
+cgit v0.9.0.2
diff --git a/weechat.spec b/weechat.spec
index 6a4bedd..2e25556 100644
--- a/weechat.spec
+++ b/weechat.spec
@@ -1,9 +1,10 @@
Name: weechat
Summary: Portable, fast, light and extensible IRC client
Version: 0.3.8
-Release: 2%{?dist}
+Release: 3%{?dist}
Source: http://weechat.org/files/src/%{name}-%{version}.tar.bz2
Patch0: weechat-combined.patch
+Patch1: weechat-fix-0.patch
URL: http://weechat.org
Group: Applications/Communications
License: GPLv3
@@ -33,6 +34,7 @@ This package contains include files and pc file for weechat.
%prep
%setup -q -n %{name}-%{version}
%patch0 -p1
+%patch1 -p1
%build
%cmake .
@@ -67,6 +69,9 @@ rm -rf $RPM_BUILD_ROOT
%{_libdir}/pkgconfig/*.pc
%changelog
+* Fri Nov 09 2012 Paul P. Komkoff Jr <i at stingr.net> - 0.3.8-3
+- fix bz#875181
+
* Sun Jul 22 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.3.8-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
More information about the scm-commits
mailing list