summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am6
-rw-r--r--src/common.h2
-rw-r--r--src/core/ignore.c28
-rw-r--r--src/core/ignore.h6
-rw-r--r--src/core/misc.c2
-rw-r--r--src/core/network-openssl.c6
-rw-r--r--src/fe-common/core/completion.c2
-rw-r--r--src/fe-common/core/fe-ignore.c5
-rw-r--r--src/fe-common/core/fe-windows.c227
-rw-r--r--src/fe-common/core/formats.c10
-rw-r--r--src/fe-common/core/hilight-text.c41
-rw-r--r--src/fe-common/core/hilight-text.h6
-rw-r--r--src/fe-common/core/printtext.c2
-rw-r--r--src/fe-common/irc/fe-irc-queries.c7
-rw-r--r--src/fe-common/irc/fe-sasl.c29
-rw-r--r--src/fe-fuzz/Makefile.am25
-rw-r--r--src/fe-fuzz/irssi.c57
-rw-r--r--src/fe-fuzz/tokens.txt143
-rw-r--r--src/fe-text/gui-printtext.c3
-rw-r--r--src/fe-text/gui-windows.c10
-rw-r--r--src/fe-text/statusbar-config.c2
-rw-r--r--src/fe-text/statusbar-items.c24
-rw-r--r--src/fe-text/term-terminfo.c13
-rw-r--r--src/fe-text/textbuffer-view.c15
-rw-r--r--src/fe-text/textbuffer-view.h3
-rw-r--r--src/fe-text/textbuffer.c48
-rw-r--r--src/fe-text/textbuffer.h1
-rw-r--r--src/irc/core/irc-nicklist.c6
-rw-r--r--src/irc/core/irc-queries.c18
-rw-r--r--src/irc/core/irc-servers.h1
-rw-r--r--src/irc/core/modes.c3
-rw-r--r--src/irc/core/sasl.c7
-rw-r--r--src/perl/common/Makefile.PL.in2
-rw-r--r--src/perl/irc/Irc.xs1
-rw-r--r--src/perl/irc/Makefile.PL.in2
-rw-r--r--src/perl/perl-core.c4
-rw-r--r--src/perl/textui/Makefile.PL.in2
-rw-r--r--src/perl/ui/Makefile.PL.in2
38 files changed, 638 insertions, 133 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 76a4af4f..a7fb2ee2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -6,6 +6,10 @@ if BUILD_IRSSIBOT
BOTUI=fe-none
endif
+if BUILD_IRSSIFUZZER
+FUZZERUI=fe-fuzz
+endif
+
if HAVE_PERL
PERLDIR=perl
endif
@@ -14,4 +18,4 @@ pkginc_srcdir=$(pkgincludedir)/src
pkginc_src_HEADERS = \
common.h
-SUBDIRS = lib-config core irc fe-common $(PERLDIR) $(TEXTUI) $(BOTUI)
+SUBDIRS = lib-config core irc fe-common $(PERLDIR) $(TEXTUI) $(BOTUI) $(FUZZERUI)
diff --git a/src/common.h b/src/common.h
index 0a7b72f0..43596580 100644
--- a/src/common.h
+++ b/src/common.h
@@ -6,7 +6,7 @@
#define IRSSI_GLOBAL_CONFIG "irssi.conf" /* config file name in /etc/ */
#define IRSSI_HOME_CONFIG "config" /* config file name in ~/.irssi/ */
-#define IRSSI_ABI_VERSION 6
+#define IRSSI_ABI_VERSION 7
#define DEFAULT_SERVER_ADD_PORT 6667
diff --git a/src/core/ignore.c b/src/core/ignore.c
index 2047dc9d..d4a92e3c 100644
--- a/src/core/ignore.c
+++ b/src/core/ignore.c
@@ -67,11 +67,12 @@ static int ignore_match_pattern(IGNORE_REC *rec, const char *text)
return FALSE;
if (rec->regexp) {
-#ifdef HAVE_REGEX_H
+#ifdef USE_GREGEX
+ return rec->preg != NULL &&
+ g_regex_match(rec->preg, text, 0, NULL);
+#else
return rec->regexp_compiled &&
regexec(&rec->preg, text, 0, NULL, 0) == 0;
-#else
- return FALSE;
#endif
}
@@ -326,12 +327,27 @@ static void ignore_remove_config(IGNORE_REC *rec)
static void ignore_init_rec(IGNORE_REC *rec)
{
-#ifdef HAVE_REGEX_H
+#ifdef USE_GREGEX
+ if (rec->preg != NULL)
+ g_regex_unref(rec->preg);
+
+ if (rec->regexp && rec->pattern != NULL) {
+ GError *re_error = NULL;
+
+ rec->preg = g_regex_new(rec->pattern, G_REGEX_OPTIMIZE | G_REGEX_RAW | G_REGEX_CASELESS, 0, &re_error);
+
+ if (rec->preg == NULL) {
+ g_warning("Failed to compile regexp '%s': %s", rec->pattern, re_error->message);
+ g_error_free(re_error);
+ }
+ }
+#else
char *errbuf;
int errcode, errbuf_len;
if (rec->regexp_compiled) regfree(&rec->preg);
rec->regexp_compiled = FALSE;
+
if (rec->regexp && rec->pattern != NULL) {
errcode = regcomp(&rec->preg, rec->pattern,
REG_EXTENDED|REG_ICASE|REG_NOSUB);
@@ -365,7 +381,9 @@ static void ignore_destroy(IGNORE_REC *rec, int send_signal)
if (send_signal)
signal_emit("ignore destroyed", 1, rec);
-#ifdef HAVE_REGEX_H
+#ifdef USE_GREGEX
+ if (rec->preg != NULL) g_regex_unref(rec->preg);
+#else
if (rec->regexp_compiled) regfree(&rec->preg);
#endif
if (rec->channels != NULL) g_strfreev(rec->channels);
diff --git a/src/core/ignore.h b/src/core/ignore.h
index f889740f..80ae1d12 100644
--- a/src/core/ignore.h
+++ b/src/core/ignore.h
@@ -1,7 +1,7 @@
#ifndef __IGNORE_H
#define __IGNORE_H
-#ifdef HAVE_REGEX_H
+#ifndef USE_GREGEX
# include <regex.h>
#endif
@@ -20,7 +20,9 @@ struct _IGNORE_REC {
unsigned int regexp:1;
unsigned int fullword:1;
unsigned int replies:1; /* ignore replies to nick in channel */
-#ifdef HAVE_REGEX_H
+#ifdef USE_GREGEX
+ GRegex *preg;
+#else
unsigned int regexp_compiled:1; /* should always be TRUE, unless regexp is invalid */
regex_t preg;
#endif
diff --git a/src/core/misc.c b/src/core/misc.c
index 0bb1f7e6..1cfa15b6 100644
--- a/src/core/misc.c
+++ b/src/core/misc.c
@@ -22,7 +22,7 @@
#include "misc.h"
#include "commands.h"
-#ifdef HAVE_REGEX_H
+#ifndef USE_GREGEX
# include <regex.h>
#endif
diff --git a/src/core/network-openssl.c b/src/core/network-openssl.c
index 7a1d6e34..1eb85341 100644
--- a/src/core/network-openssl.c
+++ b/src/core/network-openssl.c
@@ -646,7 +646,11 @@ static void set_server_temporary_key_info(TLS_REC *tls, SSL *ssl)
#ifdef SSL_get_server_tmp_key
// Show ephemeral key information.
EVP_PKEY *ephemeral_key = NULL;
+
+ // OPENSSL_NO_EC is for solaris 11.3 (2016), github ticket #598
+#ifndef OPENSSL_NO_EC
EC_KEY *ec_key = NULL;
+#endif
char *ephemeral_key_algorithm = NULL;
char *cname = NULL;
int nid;
@@ -658,6 +662,7 @@ static void set_server_temporary_key_info(TLS_REC *tls, SSL *ssl)
tls_rec_set_ephemeral_key_size(tls, EVP_PKEY_bits(ephemeral_key));
break;
+#ifndef OPENSSL_NO_EC
case EVP_PKEY_EC:
ec_key = EVP_PKEY_get1_EC_KEY(ephemeral_key);
nid = EC_GROUP_get_curve_name(EC_KEY_get0_group(ec_key));
@@ -670,6 +675,7 @@ static void set_server_temporary_key_info(TLS_REC *tls, SSL *ssl)
g_free_and_null(ephemeral_key_algorithm);
break;
+#endif
default:
tls_rec_set_ephemeral_key_algorithm(tls, "Unknown");
diff --git a/src/fe-common/core/completion.c b/src/fe-common/core/completion.c
index 76dfbb79..914ba80b 100644
--- a/src/fe-common/core/completion.c
+++ b/src/fe-common/core/completion.c
@@ -191,7 +191,7 @@ char *word_complete(WINDOW_REC *window, const char *line, int *pos, int erase, i
g_strdup_printf("%s%c%s",
/* do not accidentally duplicate the word separator */
line == wordstart - 1 ? "" : linestart,
- wordstart[-1], word);
+ old_wordstart[-1], word);
g_free(old);
g_free(word);
diff --git a/src/fe-common/core/fe-ignore.c b/src/fe-common/core/fe-ignore.c
index 52b11e6b..800e881d 100644
--- a/src/fe-common/core/fe-ignore.c
+++ b/src/fe-common/core/fe-ignore.c
@@ -58,7 +58,10 @@ static void ignore_print(int index, IGNORE_REC *rec)
g_string_append(options, "-regexp ");
if (rec->pattern == NULL)
g_string_append(options, "[INVALID! -pattern missing] ");
-#ifdef HAVE_REGEX_H
+#ifdef USE_GREGEX
+ else if (rec->preg == NULL)
+ g_string_append(options, "[INVALID!] ");
+#else
else if (!rec->regexp_compiled)
g_string_append(options, "[INVALID!] ");
#endif
diff --git a/src/fe-common/core/fe-windows.c b/src/fe-common/core/fe-windows.c
index 46c1593b..0afa2914 100644
--- a/src/fe-common/core/fe-windows.c
+++ b/src/fe-common/core/fe-windows.c
@@ -35,30 +35,83 @@
GSList *windows; /* first in the list is the active window,
next is the last active, etc. */
+GSequence *windows_seq;
WINDOW_REC *active_win;
static int daytag;
static int daycheck; /* 0 = don't check, 1 = time is 00:00, check,
2 = time is 00:00, already checked */
+static int window_refnum_lookup(WINDOW_REC *window, void *refnum_p)
+{
+ int refnum = GPOINTER_TO_INT(refnum_p);
+ return window->refnum == refnum ? 0 : window->refnum < refnum ? -1 : 1;
+}
+
+static GSequenceIter *windows_seq_begin(void)
+{
+ return g_sequence_get_begin_iter(windows_seq);
+}
+
+static GSequenceIter *windows_seq_end(void)
+{
+ return g_sequence_get_end_iter(windows_seq);
+}
+
+static GSequenceIter *windows_seq_insert(WINDOW_REC *rec)
+{
+ return g_sequence_insert_sorted(windows_seq, rec, (GCompareDataFunc)window_refnum_cmp, NULL);
+}
+
+static GSequenceIter *windows_seq_refnum_lookup(int refnum)
+{
+ return g_sequence_lookup(windows_seq, GINT_TO_POINTER(refnum), (GCompareDataFunc)window_refnum_lookup, NULL);
+}
+
+static void windows_seq_changed(GSequenceIter *iter)
+{
+ g_sequence_sort_changed(iter, (GCompareDataFunc)window_refnum_cmp, NULL);
+}
+
+static GSequenceIter *windows_seq_window_lookup(WINDOW_REC *rec)
+{
+ return g_sequence_lookup(windows_seq, rec, (GCompareDataFunc)window_refnum_cmp, NULL);
+}
+
+/* search to the numerically right iterator of refnum */
+static GSequenceIter *windows_seq_refnum_search_right(int refnum)
+{
+ return g_sequence_search(windows_seq, GINT_TO_POINTER(refnum), (GCompareDataFunc)window_refnum_lookup, NULL);
+}
+
+/* we want to find the numerically left iterator of refnum, so we
+ search the right of the previous refnum. but we need to figure out
+ the case where the iterator is already at the beginning, i.e
+ iter->refnum >= refnum */
+static GSequenceIter *windows_seq_refnum_search_left(int refnum)
+{
+ GSequenceIter *iter = windows_seq_refnum_search_right(refnum - 1);
+ return iter == windows_seq_begin() ? NULL : g_sequence_iter_prev(iter);
+}
+
static int window_get_new_refnum(void)
{
WINDOW_REC *win;
- GSList *tmp;
+ GSequenceIter *iter, *end;
int refnum;
refnum = 1;
- tmp = windows;
- while (tmp != NULL) {
- win = tmp->data;
+ iter = windows_seq_begin();
+ end = windows_seq_end();
- if (refnum != win->refnum) {
- tmp = tmp->next;
- continue;
- }
+ while (iter != end) {
+ win = g_sequence_get(iter);
+
+ if (refnum != win->refnum)
+ return refnum;
refnum++;
- tmp = windows;
+ iter = g_sequence_iter_next(iter);
}
return refnum;
@@ -73,6 +126,7 @@ WINDOW_REC *window_create(WI_ITEM_REC *item, int automatic)
rec->level = settings_get_level("window_default_level");
windows = g_slist_prepend(windows, rec);
+ windows_seq_insert(rec);
signal_emit("window created", 2, rec, GINT_TO_POINTER(automatic));
if (item != NULL) window_item_add(rec, item, automatic);
@@ -84,6 +138,19 @@ WINDOW_REC *window_create(WI_ITEM_REC *item, int automatic)
return rec;
}
+static void window_set_refnum0(WINDOW_REC *window, int refnum)
+{
+ int old_refnum;
+
+ g_return_if_fail(window != NULL);
+ g_return_if_fail(refnum >= 1);
+ if (window->refnum == refnum) return;
+
+ old_refnum = window->refnum;
+ window->refnum = refnum;
+ signal_emit("window refnum changed", 2, window, GINT_TO_POINTER(old_refnum));
+}
+
/* removed_refnum was removed from the windows list, pack the windows so
there won't be any holes. If there is any holes after removed_refnum,
leave the windows behind it alone. */
@@ -91,23 +158,37 @@ static void windows_pack(int removed_refnum)
{
WINDOW_REC *window;
int refnum;
+ GSequenceIter *iter, *end;
+
+ refnum = removed_refnum + 1;
+ end = windows_seq_end();
+ iter = windows_seq_refnum_lookup(refnum);
+ if (iter == NULL) return;
+
+ while (iter != end) {
+ window = g_sequence_get(iter);
- for (refnum = removed_refnum+1;; refnum++) {
- window = window_find_refnum(refnum);
- if (window == NULL || window->sticky_refnum)
+ if (window == NULL || window->sticky_refnum || window->refnum != refnum)
break;
- window_set_refnum(window, refnum-1);
+ window_set_refnum0(window, refnum - 1);
+ windows_seq_changed(iter);
+
+ refnum++;
+ iter = g_sequence_iter_next(iter);
}
}
void window_destroy(WINDOW_REC *window)
{
+ GSequenceIter *iter;
g_return_if_fail(window != NULL);
if (window->destroying) return;
window->destroying = TRUE;
windows = g_slist_remove(windows, window);
+ iter = windows_seq_window_lookup(window);
+ if (iter != NULL) g_sequence_remove(iter);
if (active_win == window) {
active_win = NULL; /* it's corrupted */
@@ -189,26 +270,32 @@ void window_change_server(WINDOW_REC *window, void *server)
void window_set_refnum(WINDOW_REC *window, int refnum)
{
- GSList *tmp;
+ GSequenceIter *other_iter, *window_iter;
int old_refnum;
g_return_if_fail(window != NULL);
g_return_if_fail(refnum >= 1);
if (window->refnum == refnum) return;
- for (tmp = windows; tmp != NULL; tmp = tmp->next) {
- WINDOW_REC *rec = tmp->data;
+ other_iter = windows_seq_refnum_lookup(refnum);
+ window_iter = windows_seq_refnum_lookup(window->refnum);
- if (rec->refnum == refnum) {
- rec->refnum = window->refnum;
- signal_emit("window refnum changed", 2, rec, GINT_TO_POINTER(refnum));
- break;
- }
+ if (other_iter != NULL) {
+ WINDOW_REC *rec = g_sequence_get(other_iter);
+
+ rec->refnum = window->refnum;
+ signal_emit("window refnum changed", 2, rec, GINT_TO_POINTER(refnum));
}
old_refnum = window->refnum;
window->refnum = refnum;
signal_emit("window refnum changed", 2, window, GINT_TO_POINTER(old_refnum));
+
+ if (window_iter != NULL && other_iter != NULL) {
+ g_sequence_swap(other_iter, window_iter);
+ } else {
+ windows_seq_changed(window_iter);
+ }
}
void window_set_name(WINDOW_REC *window, const char *name)
@@ -346,13 +433,13 @@ WINDOW_REC *window_find_closest(void *server, const char *name, int level)
WINDOW_REC *window_find_refnum(int refnum)
{
- GSList *tmp;
+ GSequenceIter *iter;
- for (tmp = windows; tmp != NULL; tmp = tmp->next) {
- WINDOW_REC *rec = tmp->data;
+ iter = windows_seq_refnum_lookup(refnum);
+ if (iter != NULL) {
+ WINDOW_REC *rec = g_sequence_get(iter);
- if (rec->refnum == refnum)
- return rec;
+ return rec;
}
return NULL;
@@ -400,71 +487,86 @@ WINDOW_REC *window_find_item(SERVER_REC *server, const char *name)
int window_refnum_prev(int refnum, int wrap)
{
- GSList *tmp;
- int prev, max;
+ WINDOW_REC *rec;
+ GSequenceIter *iter, *end;
- max = prev = -1;
- for (tmp = windows; tmp != NULL; tmp = tmp->next) {
- WINDOW_REC *rec = tmp->data;
+ iter = windows_seq_refnum_search_left(refnum);
+ end = windows_seq_end();
- if (rec->refnum < refnum && (prev == -1 || rec->refnum > prev))
- prev = rec->refnum;
- if (wrap && (max == -1 || rec->refnum > max))
- max = rec->refnum;
+ if (iter != NULL) {
+ rec = g_sequence_get(iter);
+ return rec->refnum;
+ }
+
+ if (wrap) {
+ iter = g_sequence_iter_prev(end);
+ if (iter != end) {
+ rec = g_sequence_get(iter);
+ return rec->refnum;
+ }
}
- return prev != -1 ? prev : max;
+ return -1;
}
int window_refnum_next(int refnum, int wrap)
{
- GSList *tmp;
- int min, next;
+ WINDOW_REC *rec;
+ GSequenceIter *iter, *end;
- min = next = -1;
- for (tmp = windows; tmp != NULL; tmp = tmp->next) {
- WINDOW_REC *rec = tmp->data;
+ iter = windows_seq_refnum_search_right(refnum);
+ end = windows_seq_end();
+
+ if (iter != end) {
+ rec = g_sequence_get(iter);
+ return rec->refnum;
+ }
- if (rec->refnum > refnum && (next == -1 || rec->refnum < next))
- next = rec->refnum;
- if (wrap && (min == -1 || rec->refnum < min))
- min = rec->refnum;
+ if (wrap) {
+ iter = windows_seq_begin();
+ if (iter != end) {
+ rec = g_sequence_get(iter);
+ return rec->refnum;
+ }
}
- return next != -1 ? next : min;
+ return -1;
}
int windows_refnum_last(void)
{
- GSList *tmp;
- int max;
-
- max = -1;
- for (tmp = windows; tmp != NULL; tmp = tmp->next) {
- WINDOW_REC *rec = tmp->data;
+ WINDOW_REC *rec;
+ GSequenceIter *end, *iter;
- if (rec->refnum > max)
- max = rec->refnum;
+ end = windows_seq_end();
+ iter = g_sequence_iter_prev(end);
+ if (iter != end) {
+ rec = g_sequence_get(iter);
+ return rec->refnum;
}
- return max;
+ return -1;
}
int window_refnum_cmp(WINDOW_REC *w1, WINDOW_REC *w2)
{
- return w1->refnum < w2->refnum ? -1 : 1;
+ return w1 == w2 ? 0 : w1->refnum < w2->refnum ? -1 : 1;
}
GSList *windows_get_sorted(void)
{
- GSList *tmp, *sorted;
+ GSequenceIter *iter, *begin;
+ GSList *sorted;
sorted = NULL;
- for (tmp = windows; tmp != NULL; tmp = tmp->next) {
- WINDOW_REC *rec = tmp->data;
+ iter = windows_seq_end();
+ begin = windows_seq_begin();
+
+ while (iter != begin) {
+ iter = g_sequence_iter_prev(iter);
+ WINDOW_REC *rec = g_sequence_get(iter);
- sorted = g_slist_insert_sorted(sorted, rec, (GCompareFunc)
- window_refnum_cmp);
+ sorted = g_slist_prepend(sorted, rec);
}
return sorted;
@@ -709,6 +811,7 @@ static void read_settings(void)
void windows_init(void)
{
active_win = NULL;
+ windows_seq = g_sequence_new(NULL);
daycheck = 0; daytag = -1;
settings_add_bool("lookandfeel", "window_auto_change", FALSE);
settings_add_bool("lookandfeel", "windows_auto_renumber", TRUE);
@@ -733,4 +836,6 @@ void windows_deinit(void)
signal_remove("server disconnected", (SIGNAL_FUNC) sig_server_disconnected);
signal_remove("server connect failed", (SIGNAL_FUNC) sig_server_disconnected);
signal_remove("setup changed", (SIGNAL_FUNC) read_settings);
+ g_sequence_free(windows_seq);
+ windows_seq = NULL;
}
diff --git a/src/fe-common/core/formats.c b/src/fe-common/core/formats.c
index a58d839a..17c13a97 100644
--- a/src/fe-common/core/formats.c
+++ b/src/fe-common/core/formats.c
@@ -68,7 +68,7 @@ static void format_expand_code(const char **format, GString *out, int *flags)
if (flags == NULL) {
/* flags are being ignored - skip the code */
- while (**format != ']')
+ while (**format != ']' && **format != '\0')
(*format)++;
return;
}
@@ -246,6 +246,10 @@ int format_expand_styles(GString *out, const char **format, int *flags)
case '[':
/* code */
format_expand_code(format, out, flags);
+ if ((*format)[0] == '\0')
+ /* oops, reached end prematurely */
+ (*format)--;
+
break;
case 'x':
case 'X':
@@ -956,6 +960,7 @@ static const char *get_ansi_color(THEME_REC *theme, const char *str,
str++;
for (num2 = 0; i_isdigit(*str); str++)
num2 = num2*10 + (*str-'0');
+ if (*str == '\0') return start;
switch (num2) {
case 2:
@@ -973,6 +978,8 @@ static const char *get_ansi_color(THEME_REC *theme, const char *str,
for (; i_isdigit(*str); str++)
num2 = (num2&~0xff) |
(((num2&0xff) * 10 + (*str-'0'))&0xff);
+
+ if (*str == '\0') return start;
}
if (i == -1) break;
@@ -1001,6 +1008,7 @@ static const char *get_ansi_color(THEME_REC *theme, const char *str,
str++;
for (num2 = 0; i_isdigit(*str); str++)
num2 = num2*10 + (*str-'0');
+ if (*str == '\0') return start;
if (num == 38) {
flags &= ~GUI_PRINT_FLAG_COLOR_24_FG;
diff --git a/src/fe-common/core/hilight-text.c b/src/fe-common/core/hilight-text.c
index 46b416e6..dd38be87 100644
--- a/src/fe-common/core/hilight-text.c
+++ b/src/fe-common/core/hilight-text.c
@@ -101,7 +101,9 @@ static void hilight_destroy(HILIGHT_REC *rec)
{
g_return_if_fail(rec != NULL);
-#ifdef HAVE_REGEX_H
+#ifdef USE_GREGEX
+ if (rec->preg != NULL) g_regex_unref(rec->preg);
+#else
if (rec->regexp_compiled) regfree(&rec->preg);
#endif
if (rec->channels != NULL) g_strfreev(rec->channels);
@@ -120,7 +122,12 @@ static void hilights_destroy_all(void)
static void hilight_init_rec(HILIGHT_REC *rec)
{
-#ifdef HAVE_REGEX_H
+#ifdef USE_GREGEX
+ if (rec->preg != NULL)
+ g_regex_unref(rec->preg);
+
+ rec->preg = g_regex_new(rec->text, G_REGEX_OPTIMIZE | G_REGEX_RAW | G_REGEX_CASELESS, 0, NULL);
+#else
if (rec->regexp_compiled) regfree(&rec->preg);
if (!rec->regexp)
rec->regexp_compiled = FALSE;
@@ -194,13 +201,24 @@ static HILIGHT_REC *hilight_find(const char *text, char **channels)
return NULL;
}
-static int hilight_match_text(HILIGHT_REC *rec, const char *text,
+static gboolean hilight_match_text(HILIGHT_REC *rec, const char *text,
int *match_beg, int *match_end)
{
- char *match;
+ gboolean ret = FALSE;
if (rec->regexp) {
-#ifdef HAVE_REGEX_H
+#ifdef USE_GREGEX
+ if (rec->preg != NULL) {
+ GMatchInfo *match;
+
+ g_regex_match (rec->preg, text, 0, &match);
+
+ if (g_match_info_matches(match))
+ ret = g_match_info_fetch_pos(match, 0, match_beg, match_end);
+
+ g_match_info_free(match);
+ }
+#else
regmatch_t rmatch[1];
if (rec->regexp_compiled &&
@@ -210,10 +228,12 @@ static int hilight_match_text(HILIGHT_REC *rec, const char *text,
*match_beg = rmatch[0].rm_so;
*match_end = rmatch[0].rm_eo;
}
- return TRUE;
+ ret = TRUE;
}
#endif
} else {
+ char *match;
+
if (rec->case_sensitive) {
match = rec->fullword ?
strstr_full(text, rec->text) :
@@ -228,11 +248,11 @@ static int hilight_match_text(HILIGHT_REC *rec, const char *text,
*match_beg = (int) (match-text);
*match_end = *match_beg + strlen(rec->text);
}
- return TRUE;
+ ret = TRUE;
}
}
- return FALSE;
+ return ret;
}
#define hilight_match_level(rec, level) \
@@ -504,7 +524,10 @@ static void hilight_print(int index, HILIGHT_REC *rec)
if (rec->case_sensitive) g_string_append(options, "-matchcase ");
if (rec->regexp) {
g_string_append(options, "-regexp ");
-#ifdef HAVE_REGEX_H
+#ifdef USE_GREGEX
+ if (rec->preg == NULL)
+ g_string_append(options, "[INVALID!] ");
+#else
if (!rec->regexp_compiled)
g_string_append(options, "[INVALID!] ");
#endif
diff --git a/src/fe-common/core/hilight-text.h b/src/fe-common/core/hilight-text.h
index ae05e1ca..76beec1f 100644
--- a/src/fe-common/core/hilight-text.h
+++ b/src/fe-common/core/hilight-text.h
@@ -1,7 +1,7 @@
#ifndef __HILIGHT_TEXT_H
#define __HILIGHT_TEXT_H
-#ifdef HAVE_REGEX_H
+#ifndef USE_GREGEX
# include <regex.h>
#endif
@@ -24,7 +24,9 @@ struct _HILIGHT_REC {
unsigned int fullword:1; /* match `text' only for full words */
unsigned int regexp:1; /* `text' is a regular expression */
unsigned int case_sensitive:1;/* `text' must match case */
-#ifdef HAVE_REGEX_H
+#ifdef USE_GREGEX
+ GRegex *preg;
+#else
unsigned int regexp_compiled:1; /* should always be TRUE, unless regexp is invalid */
regex_t preg;
#endif
diff --git a/src/fe-common/core/printtext.c b/src/fe-common/core/printtext.c
index ba6f3242..01ef2dcd 100644
--- a/src/fe-common/core/printtext.c
+++ b/src/fe-common/core/printtext.c
@@ -446,7 +446,9 @@ static void sig_print_text(TEXT_DEST_REC *dest, const char *text)
if (dest->window == NULL) {
str = strip_codes(text);
+#ifndef SUPPRESS_PRINTF_FALLBACK
printf("NO WINDOWS: %s\n", str);
+#endif
g_free(str);
return;
}
diff --git a/src/fe-common/irc/fe-irc-queries.c b/src/fe-common/irc/fe-irc-queries.c
index b2faefbc..c928a94a 100644
--- a/src/fe-common/irc/fe-irc-queries.c
+++ b/src/fe-common/irc/fe-irc-queries.c
@@ -78,6 +78,13 @@ static void event_privmsg(SERVER_REC *server, const char *data,
if (!server_has_nick(server, query->name))
query_change_nick(query, nick);
}
+ } else {
+ /* process the changes to the query structure now, before the
+ * privmsg is dispatched. */
+ if (g_strcmp0(query->name, nick) != 0)
+ query_change_nick(query, nick);
+ if (address != NULL && g_strcmp0(query->address, address) != 0)
+ query_change_address(query, address);
}
}
diff --git a/src/fe-common/irc/fe-sasl.c b/src/fe-common/irc/fe-sasl.c
index 331b38b0..fc8105fc 100644
--- a/src/fe-common/irc/fe-sasl.c
+++ b/src/fe-common/irc/fe-sasl.c
@@ -1,7 +1,7 @@
/*
fe-sasl.c : irssi
- Copyright (C) 2015 The Lemon Man
+ Copyright (C) 2015-2017 The Lemon Man
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -22,6 +22,11 @@
#include "module-formats.h"
#include "signals.h"
#include "levels.h"
+#include "misc.h"
+#include "sasl.h"
+
+#include "irc-servers.h"
+#include "settings.h"
#include "printtext.h"
@@ -35,14 +40,36 @@ static void sig_sasl_failure(IRC_SERVER_REC *server, const char *reason)
printformat(server, NULL, MSGLEVEL_CRAP, IRCTXT_SASL_ERROR, reason);
}
+static void sig_cap_end(IRC_SERVER_REC *server)
+{
+ /* The negotiation has now been terminated, if we didn't manage to
+ * authenticate successfully with the server just disconnect. */
+ if (!server->sasl_success &&
+ server->connrec->sasl_mechanism != SASL_MECHANISM_NONE &&
+ settings_get_bool("sasl_disconnect_on_failure")) {
+ /* We can't use server_disconnect() here because we'd end up
+ * freeing the 'server' object and be guilty of a slew of UaF. */
+ server->connection_lost = TRUE;
+ /* By setting connection_lost we make sure the communication is
+ * halted and when the control goes back to irc_parse_incoming
+ * the server object is safely destroyed. */
+ signal_stop();
+ }
+
+}
+
void fe_sasl_init(void)
{
+ settings_add_bool("server", "sasl_disconnect_on_failure", TRUE);
+
signal_add("server sasl success", (SIGNAL_FUNC) sig_sasl_success);
signal_add("server sasl failure", (SIGNAL_FUNC) sig_sasl_failure);
+ signal_add_first("server cap end", (SIGNAL_FUNC) sig_cap_end);
}
void fe_sasl_deinit(void)
{
signal_remove("server sasl success", (SIGNAL_FUNC) sig_sasl_success);
signal_remove("server sasl failure", (SIGNAL_FUNC) sig_sasl_failure);
+ signal_remove("server cap end", (SIGNAL_FUNC) sig_cap_end);
}
diff --git a/src/fe-fuzz/Makefile.am b/src/fe-fuzz/Makefile.am
new file mode 100644
index 00000000..3a547c66
--- /dev/null
+++ b/src/fe-fuzz/Makefile.am
@@ -0,0 +1,25 @@
+bin_PROGRAMS = irssi-fuzz
+
+# Force link with clang++ for libfuzzer support
+CCLD=clang++ $(CXXFLAGS)
+
+AM_CPPFLAGS = \
+ -I$(top_srcdir)/src \
+ -I$(top_srcdir)/src/core/ \
+ -I$(top_srcdir)/src/irc/core/ \
+ -I$(top_srcdir)/src/fe-common/core/ \
+ $(GLIB_CFLAGS)
+
+irssi_fuzz_DEPENDENCIES = @COMMON_LIBS@
+
+irssi_fuzz_LDADD = \
+ @COMMON_LIBS@ \
+ @PROG_LIBS@ \
+ $(FUZZER_LIBS)
+
+irssi_fuzz_SOURCES = \
+ irssi.c \
+ $(top_srcdir)/src/fe-text/module-formats.c
+
+noinst_HEADERS = \
+ $(top_srcdir)/src/fe-text/module-formats.h
diff --git a/src/fe-fuzz/irssi.c b/src/fe-fuzz/irssi.c
new file mode 100644
index 00000000..77892aaf
--- /dev/null
+++ b/src/fe-fuzz/irssi.c
@@ -0,0 +1,57 @@
+/*
+ irssi.c : irssi
+
+ Copyright (C) 2017 Joseph Bisch
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#include "module.h"
+#include "modules-load.h"
+#include "levels.h"
+#include "../fe-text/module-formats.h" // need to explicitly grab from fe-text
+#include "themes.h"
+#include "core.h"
+#include "fe-common-core.h"
+#include "args.h"
+#include "printtext.h"
+
+#include <stddef.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+int LLVMFuzzerInitialize(int *argc, char ***argv) {
+ core_register_options();
+ fe_common_core_register_options();
+ /* no args */
+ args_execute(0, NULL);
+ core_preinit((*argv)[0]);
+ core_init();
+ fe_common_core_init();
+ theme_register(gui_text_formats);
+ module_register("core", "fe-fuzz");
+ printtext_string(NULL, NULL, MSGLEVEL_CLIENTCRAP, "init");
+ return 0;
+}
+
+int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ char *copy = (char *)malloc(sizeof(char)*(size+1));
+ memcpy(copy, data, size);
+ copy[size] = '\0';
+ printtext_string(NULL, NULL, MSGLEVEL_CLIENTCRAP, copy);
+ free(copy);
+ return 0;
+}
diff --git a/src/fe-fuzz/tokens.txt b/src/fe-fuzz/tokens.txt
new file mode 100644
index 00000000..e337b6e9
--- /dev/null
+++ b/src/fe-fuzz/tokens.txt
@@ -0,0 +1,143 @@
+"@%+"
+"*@*!*"
+"001"
+"002"
+"003"
+"004"
+"005"
+"221"
+"254"
+"271"
+"272"
+"281"
+"301"
+"302"
+"303"
+"305"
+"306"
+"311"
+"312"
+"313"
+"314"
+"315"
+"317"
+"318"
+"319"
+"324"
+"326"
+"327"
+"328"
+"329"
+"330"
+"332"
+"333"
+"338"
+"341"
+"344"
+"345"
+"346"
+"347"
+"348"
+"349"
+"352"
+"353"
+"364"
+"365"
+"366"
+"367"
+"368"
+"369"
+"372"
+"375"
+"376"
+"377"
+"378"
+"379"
+"381"
+"386"
+"387"
+"388"
+"389"
+"396"
+"401"
+"403"
+"404"
+"405"
+"407"
+"408"
+"410"
+"421"
+"422"
+"433"
+"436"
+"437"
+"438"
+"439"
+"442"
+"465"
+"470"
+"471"
+"472"
+"473"
+"474"
+"475"
+"476"
+"477"
+"478"
+"479"
+"482"
+"486"
+"489"
+"494"
+"506"
+"707"
+"716"
+"717"
+"728"
+"729"
+"902"
+"903"
+"904"
+"905"
+"906"
+"907"
+":a"
+"+a"
+"ACK"
+"authenticate"
+"away"
+"-b"
+"+b"
+"cap"
+"#chan"
+"connected"
+"empty"
+"error"
+"invite"
+"join"
+"kick"
+"kill"
+"LS"
+"mode"
+"multi-prefix"
+"NAK"
+"network"
+"nick"
+"nicklen"
+"notice"
+"-o"
+"+o"
+"part"
+"ping"
+"pong"
+"prefix"
+"privmsg"
+"quit"
+"sasl"
+"topic"
+"wallops"
+"watch"
+":\x01"
+":\x01ACTION"
+":\x01PING"
+":\x01VERSION"
diff --git a/src/fe-text/gui-printtext.c b/src/fe-text/gui-printtext.c
index 775e6044..a07451fa 100644
--- a/src/fe-text/gui-printtext.c
+++ b/src/fe-text/gui-printtext.c
@@ -169,7 +169,8 @@ static void get_colors(int flags, int *fg, int *bg, int *attr)
if (*bg >= 0) {
*bg = mirc_colors[*bg % 100];
flags &= ~GUI_PRINT_FLAG_COLOR_24_BG;
- if (settings_get_bool("mirc_blink_fix")) {
+ /* ignore mirc color 99 = -1 (reset) */
+ if (*bg != -1 && settings_get_bool("mirc_blink_fix")) {
if (*bg < 16) /* ansi bit flip :-( */
*bg = (*bg&8) | (*bg&4)>>2 | (*bg&2) | (*bg&1)<<2;
*bg = term_color256map[*bg&0xff] & 7;
diff --git a/src/fe-text/gui-windows.c b/src/fe-text/gui-windows.c
index 4213149d..c63c495c 100644
--- a/src/fe-text/gui-windows.c
+++ b/src/fe-text/gui-windows.c
@@ -49,6 +49,7 @@ static GUI_WINDOW_REC *gui_window_init(WINDOW_REC *window,
settings_get_int("indent"),
!settings_get_bool("indent_always"),
get_default_indent_func());
+ textbuffer_view_set_break_wide(gui->view, settings_get_bool("break_wide"));
if (parent->active == window)
textbuffer_view_set_window(gui->view, parent->screen_win);
return gui;
@@ -201,12 +202,14 @@ void gui_windows_reset_settings(void)
for (tmp = windows; tmp != NULL; tmp = tmp->next) {
WINDOW_REC *rec = tmp->data;
- GUI_WINDOW_REC *gui = WINDOW_GUI(rec);
+ GUI_WINDOW_REC *gui = WINDOW_GUI(rec);
- textbuffer_view_set_default_indent(gui->view,
+ textbuffer_view_set_break_wide(gui->view, settings_get_bool("break_wide"));
+
+ textbuffer_view_set_default_indent(gui->view,
settings_get_int("indent"),
!settings_get_bool("indent_always"),
- get_default_indent_func());
+ get_default_indent_func());
textbuffer_view_set_scroll(gui->view,
gui->use_scroll ? gui->scroll :
@@ -281,6 +284,7 @@ void gui_windows_init(void)
settings_add_bool("lookandfeel", "autostick_split_windows", TRUE);
settings_add_int("lookandfeel", "indent", 10);
settings_add_bool("lookandfeel", "indent_always", FALSE);
+ settings_add_bool("lookandfeel", "break_wide", FALSE);
settings_add_bool("lookandfeel", "scroll", TRUE);
window_create_override = -1;
diff --git a/src/fe-text/statusbar-config.c b/src/fe-text/statusbar-config.c
index a47a709e..48f4aa61 100644
--- a/src/fe-text/statusbar-config.c
+++ b/src/fe-text/statusbar-config.c
@@ -194,6 +194,8 @@ static void statusbar_read_group(CONFIG_NODE *node)
STATUSBAR_GROUP_REC *group;
GSList *tmp;
+ g_return_if_fail(is_node_list(node));
+
group = statusbar_group_find(node->key);
if (group == NULL) {
group = statusbar_group_create(node->key);
diff --git a/src/fe-text/statusbar-items.c b/src/fe-text/statusbar-items.c
index 0db4f63a..de4499b4 100644
--- a/src/fe-text/statusbar-items.c
+++ b/src/fe-text/statusbar-items.c
@@ -143,16 +143,34 @@ static char *get_activity_list(MAIN_WINDOW_REC *window, int normal, int hilight)
static void item_act(SBAR_ITEM_REC *item, int get_size_only)
{
char *actlist;
+ int max_size;
+
+ if (get_size_only) {
+ if (activity_list == NULL)
+ item->min_size = item->max_size = 0;
+ /* Skip activity calculation on regular trigger, only
+ set dirty */
+ return;
+ }
actlist = get_activity_list(item->bar->parent_window, TRUE, TRUE);
if (actlist == NULL) {
- if (get_size_only)
- item->min_size = item->max_size = 0;
return;
}
- statusbar_item_default_handler(item, get_size_only,
+ max_size = item->max_size;
+ statusbar_item_default_handler(item, TRUE,
NULL, actlist, FALSE);
+ statusbar_item_default_handler(item, FALSE,
+ NULL, actlist, FALSE);
+ if (max_size != item->max_size) {
+ /* Due to above hack of skipping the calculation, we
+ need to manually trigger the redraw process now or
+ we won't see the item */
+ item->bar->dirty = item->dirty = TRUE;
+ statusbar_redraw(item->bar, TRUE);
+ statusbar_redraw_dirty();
+ }
g_free_not_null(actlist);
}
diff --git a/src/fe-text/term-terminfo.c b/src/fe-text/term-terminfo.c
index b2478c62..3098a4e4 100644
--- a/src/fe-text/term-terminfo.c
+++ b/src/fe-text/term-terminfo.c
@@ -539,9 +539,16 @@ int term_addstr(TERM_WINDOW *window, const char *str)
if (term_type == TERM_TYPE_UTF8) {
while (*ptr != '\0') {
- tmp = g_utf8_get_char(ptr);
- len += unichar_isprint(tmp) ? mk_wcwidth(tmp) : 1;
- ptr = g_utf8_next_char(ptr);
+ tmp = g_utf8_get_char_validated(ptr, -1);
+ /* On utf8 error, treat as single byte and try to
+ continue interpretting rest of string as utf8 */
+ if (tmp == (gunichar)-1 || tmp == (gunichar)-2) {
+ len++;
+ ptr++;
+ } else {
+ len += unichar_isprint(tmp) ? mk_wcwidth(tmp) : 1;
+ ptr = g_utf8_next_char(ptr);
+ }
}
} else
len = raw_len;
diff --git a/src/fe-text/textbuffer-view.c b/src/fe-text/textbuffer-view.c
index e2e3707b..58bd36fb 100644
--- a/src/fe-text/textbuffer-view.c
+++ b/src/fe-text/textbuffer-view.c
@@ -146,6 +146,9 @@ static void update_cmd_color(unsigned char cmd, int *color)
case LINE_CMD_ITALIC:
*color ^= ATTR_ITALIC;
break;
+ case LINE_CMD_MONOSPACE:
+ /* ignored */
+ break;
case LINE_CMD_COLOR0:
*color &= BGATTR;
*color &= ~ATTR_FGCOLOR24;
@@ -307,7 +310,7 @@ view_update_line_cache(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line)
continue;
}
- if (!view->utf8 && char_width > 1) {
+ if (view->break_wide && char_width > 1) {
last_space = xpos;
last_space_ptr = next_ptr;
last_color = color; last_fg24 = fg24; last_bg24 = bg24;
@@ -665,6 +668,16 @@ void textbuffer_view_set_default_indent(TEXT_BUFFER_VIEW_REC *view,
view->default_indent_func = indent_func;
}
+/* Enable breaking of wide chars */
+void textbuffer_view_set_break_wide(TEXT_BUFFER_VIEW_REC *view,
+ gboolean break_wide)
+{
+ if (view->break_wide != break_wide) {
+ view->break_wide = break_wide;
+ view_reset_cache(view);
+ }
+}
+
static void view_unregister_indent_func(TEXT_BUFFER_VIEW_REC *view,
INDENT_FUNC indent_func)
{
diff --git a/src/fe-text/textbuffer-view.h b/src/fe-text/textbuffer-view.h
index 21a9bde6..5e7a9d0a 100644
--- a/src/fe-text/textbuffer-view.h
+++ b/src/fe-text/textbuffer-view.h
@@ -59,6 +59,7 @@ struct _TEXT_BUFFER_VIEW_REC {
unsigned int longword_noindent:1;
unsigned int scroll:1; /* scroll down automatically when at bottom */
unsigned int utf8:1; /* use UTF8 in this view */
+ unsigned int break_wide:1; /* Break wide chars in this view */
TEXT_BUFFER_CACHE_REC *cache;
int ypos; /* cursor position - visible area is 0..height-1 */
@@ -97,6 +98,8 @@ void textbuffer_view_set_default_indent(TEXT_BUFFER_VIEW_REC *view,
int longword_noindent,
INDENT_FUNC indent_func);
void textbuffer_views_unregister_indent_func(INDENT_FUNC indent_func);
+void textbuffer_view_set_break_wide(TEXT_BUFFER_VIEW_REC *view,
+ gboolean break_wide);
void textbuffer_view_set_scroll(TEXT_BUFFER_VIEW_REC *view, int scroll);
void textbuffer_view_set_utf8(TEXT_BUFFER_VIEW_REC *view, int utf8);
diff --git a/src/fe-text/textbuffer.c b/src/fe-text/textbuffer.c
index 24ee62bc..3668f4c7 100644
--- a/src/fe-text/textbuffer.c
+++ b/src/fe-text/textbuffer.c
@@ -27,7 +27,7 @@
#include "textbuffer.h"
-#ifdef HAVE_REGEX_H
+#ifndef USE_GREGEX
# include <regex.h>
#endif
@@ -326,6 +326,10 @@ void textbuffer_line_add_colors(TEXT_BUFFER_REC *buffer, LINE_REC **line,
data[pos++] = 0;
data[pos++] = LINE_CMD_ITALIC;
}
+ if ((flags & GUI_PRINT_FLAG_MONOSPACE) != (buffer->last_flags & GUI_PRINT_FLAG_MONOSPACE)) {
+ data[pos++] = 0;
+ data[pos++] = LINE_CMD_MONOSPACE;
+ }
if (flags & GUI_PRINT_FLAG_INDENT) {
data[pos++] = 0;
data[pos++] = LINE_CMD_INDENT;
@@ -509,6 +513,10 @@ void textbuffer_line2text(LINE_REC *line, int coloring, GString *str)
g_string_append_printf(str, "\004%c",
FORMAT_STYLE_ITALIC);
break;
+ case LINE_CMD_MONOSPACE:
+ g_string_append_printf(str, "\004%c",
+ FORMAT_STYLE_MONOSPACE);
+ break;
case LINE_CMD_COLOR0:
g_string_append_printf(str, "\004%c%c",
'0', FORMAT_COLOR_NOCHANGE);
@@ -537,7 +545,9 @@ GList *textbuffer_find_text(TEXT_BUFFER_REC *buffer, LINE_REC *startline,
int before, int after,
int regexp, int fullword, int case_sensitive)
{
-#ifdef HAVE_REGEX_H
+#ifdef USE_GREGEX
+ GRegex *preg;
+#else
regex_t preg;
#endif
LINE_REC *line, *pre_line;
@@ -549,16 +559,23 @@ GList *textbuffer_find_text(TEXT_BUFFER_REC *buffer, LINE_REC *startline,
g_return_val_if_fail(buffer != NULL, NULL);
g_return_val_if_fail(text != NULL, NULL);
+#ifdef USE_GREGEX
+ preg = NULL;
+
+ if (regexp) {
+ preg = g_regex_new(text, G_REGEX_RAW | (case_sensitive ? 0 : G_REGEX_CASELESS), 0, NULL);
+
+ if (preg == NULL)
+ return NULL;
+ }
+#else
if (regexp) {
-#ifdef HAVE_REGEX_H
int flags = REG_EXTENDED | REG_NOSUB |
(case_sensitive ? 0 : REG_ICASE);
if (regcomp(&preg, text, flags) != 0)
return NULL;
-#else
- return NULL;
-#endif
}
+#endif
matches = NULL; match_after = 0;
str = g_string_new(NULL);
@@ -577,12 +594,15 @@ GList *textbuffer_find_text(TEXT_BUFFER_REC *buffer, LINE_REC *startline,
if (*text != '\0') {
textbuffer_line2text(line, FALSE, str);
- if (line_matched)
- line_matched =
-#ifdef HAVE_REGEX_H
- regexp ? regexec(&preg, str->str, 0, NULL, 0) == 0 :
+ if (line_matched) {
+ line_matched = regexp ?
+#ifdef USE_GREGEX
+ g_regex_match(preg, str->str, 0, NULL)
+#else
+ regexec(&preg, str->str, 0, NULL, 0) == 0
#endif
- match_func(str->str, text) != NULL;
+ : match_func(str->str, text) != NULL;
+ }
}
if (line_matched) {
@@ -610,7 +630,11 @@ GList *textbuffer_find_text(TEXT_BUFFER_REC *buffer, LINE_REC *startline,
matches = g_list_append(matches, NULL);
}
}
-#ifdef HAVE_REGEX_H
+
+#ifdef USE_GREGEX
+ if (preg != NULL)
+ g_regex_unref(preg);
+#else
if (regexp) regfree(&preg);
#endif
g_string_free(str, TRUE);
diff --git a/src/fe-text/textbuffer.h b/src/fe-text/textbuffer.h
index eacfd447..303789a3 100644
--- a/src/fe-text/textbuffer.h
+++ b/src/fe-text/textbuffer.h
@@ -18,6 +18,7 @@ enum {
LINE_CMD_BLINK, /* enable/disable blink */
LINE_CMD_BOLD, /* enable/disable bold */
LINE_CMD_ITALIC, /* enable/disable italic */
+ LINE_CMD_MONOSPACE, /* enable/disable monospace (gui only) */
LINE_COLOR_EXT, /* extended color */
LINE_COLOR_EXT_BG, /* extended bg */
#ifdef TERM_TRUECOLOR
diff --git a/src/irc/core/irc-nicklist.c b/src/irc/core/irc-nicklist.c
index b22f3269..1cb1f3e9 100644
--- a/src/irc/core/irc-nicklist.c
+++ b/src/irc/core/irc-nicklist.c
@@ -314,7 +314,11 @@ static void event_whois_ircop(SERVER_REC *server, const char *data)
static void event_nick_invalid(IRC_SERVER_REC *server, const char *data)
{
if (!server->connected)
- server_disconnect((SERVER_REC *) server);
+ /* we used to call server_disconnect but that crashes
+ irssi because of undefined memory access. instead,
+ indicate that the connection should be dropped and
+ let the irc method to the clean-up. */
+ server->connection_lost = server->no_reconnect = TRUE;
}
static void event_nick_in_use(IRC_SERVER_REC *server, const char *data)
diff --git a/src/irc/core/irc-queries.c b/src/irc/core/irc-queries.c
index 12861744..64995ead 100644
--- a/src/irc/core/irc-queries.c
+++ b/src/irc/core/irc-queries.c
@@ -45,6 +45,8 @@ QUERY_REC *irc_query_find(IRC_SERVER_REC *server, const char *nick)
{
GSList *tmp;
+ g_return_val_if_fail(nick != NULL, NULL);
+
for (tmp = server->queries; tmp != NULL; tmp = tmp->next) {
QUERY_REC *rec = tmp->data;
@@ -79,20 +81,6 @@ static void check_query_changes(IRC_SERVER_REC *server, const char *nick,
}
}
-static void event_privmsg(IRC_SERVER_REC *server, const char *data,
- const char *nick, const char *address)
-{
- char *params, *target, *msg;
-
- g_return_if_fail(data != NULL);
- if (nick == NULL)
- return;
-
- params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg);
- check_query_changes(server, nick, address, target);
- g_free(params);
-}
-
static void ctcp_action(IRC_SERVER_REC *server, const char *msg,
const char *nick, const char *address,
const char *target)
@@ -117,14 +105,12 @@ static void event_nick(SERVER_REC *server, const char *data,
void irc_queries_init(void)
{
- signal_add_last("event privmsg", (SIGNAL_FUNC) event_privmsg);
signal_add_last("ctcp action", (SIGNAL_FUNC) ctcp_action);
signal_add("event nick", (SIGNAL_FUNC) event_nick);
}
void irc_queries_deinit(void)
{
- signal_remove("event privmsg", (SIGNAL_FUNC) event_privmsg);
signal_remove("ctcp action", (SIGNAL_FUNC) ctcp_action);
signal_remove("event nick", (SIGNAL_FUNC) event_nick);
}
diff --git a/src/irc/core/irc-servers.h b/src/irc/core/irc-servers.h
index bb100f86..09f3f81d 100644
--- a/src/irc/core/irc-servers.h
+++ b/src/irc/core/irc-servers.h
@@ -68,6 +68,7 @@ struct _IRC_SERVER_REC {
unsigned int motd_got:1; /* We've received MOTD */
unsigned int isupport_sent:1; /* Server has sent us an isupport reply */
unsigned int cap_complete:1; /* We've done the initial CAP negotiation */
+ unsigned int sasl_success:1; /* Did we authenticate successfully ? */
int max_kicks_in_cmd; /* max. number of people to kick with one /KICK command */
int max_modes_in_cmd; /* max. number of mode changes in one /MODE command */
diff --git a/src/irc/core/modes.c b/src/irc/core/modes.c
index 207461cc..cc3d0faf 100644
--- a/src/irc/core/modes.c
+++ b/src/irc/core/modes.c
@@ -743,6 +743,7 @@ static char *get_nicks(IRC_SERVER_REC *server, WI_ITEM_REC *item,
g_hash_table_lookup(optlist, "yes") == NULL) {
/* too many matches */
g_string_free(str, TRUE);
+ g_strfreev(matches);
cmd_params_free(free_arg);
signal_emit("error command", 1,
@@ -756,7 +757,7 @@ static char *get_nicks(IRC_SERVER_REC *server, WI_ITEM_REC *item,
if (str->len > 0) g_string_truncate(str, str->len-1);
ret = str->str;
g_string_free(str, FALSE);
-
+ g_strfreev(matches);
cmd_params_free(free_arg);
*ret_channel = channel;
diff --git a/src/irc/core/sasl.c b/src/irc/core/sasl.c
index a1c16cdd..1021bea4 100644
--- a/src/irc/core/sasl.c
+++ b/src/irc/core/sasl.c
@@ -48,6 +48,7 @@ static gboolean sasl_timeout(IRC_SERVER_REC *server)
cap_finish_negotiation(server);
server->sasl_timeout = 0;
+ server->sasl_success = FALSE;
signal_emit("server sasl failure", 2, server, "The authentication timed out");
@@ -84,6 +85,8 @@ static void sasl_fail(IRC_SERVER_REC *server, const char *data, const char *from
params = event_get_params(data, 2, NULL, &error);
+ server->sasl_success = FALSE;
+
signal_emit("server sasl failure", 2, server, error);
/* Terminate the negotiation */
@@ -99,6 +102,8 @@ static void sasl_already(IRC_SERVER_REC *server, const char *data, const char *f
server->sasl_timeout = 0;
}
+ server->sasl_success = TRUE;
+
signal_emit("server sasl success", 1, server);
/* We're already authenticated, do nothing */
@@ -112,6 +117,8 @@ static void sasl_success(IRC_SERVER_REC *server, const char *data, const char *f
server->sasl_timeout = 0;
}
+ server->sasl_success = TRUE;
+
signal_emit("server sasl success", 1, server);
/* The authentication succeeded, time to finish the CAP negotiation */
diff --git a/src/perl/common/Makefile.PL.in b/src/perl/common/Makefile.PL.in
index 84a80403..70b1d258 100644
--- a/src/perl/common/Makefile.PL.in
+++ b/src/perl/common/Makefile.PL.in
@@ -1,4 +1,4 @@
-use ExtUtils::MakeMaker;our $AM_DEFAULT_VERBOSITY='@AM_DEFAULT_VERBOSITY@';require "../Makefile_silent.pm";
+use ExtUtils::MakeMaker;our $AM_DEFAULT_VERBOSITY='@AM_DEFAULT_VERBOSITY@';require "@top_srcdir@/src/perl/Makefile_silent.pm";
WriteMakefile('NAME' => 'Irssi',
'LIBS' => '',
diff --git a/src/perl/irc/Irc.xs b/src/perl/irc/Irc.xs
index 8b3b0c45..41690010 100644
--- a/src/perl/irc/Irc.xs
+++ b/src/perl/irc/Irc.xs
@@ -32,6 +32,7 @@ static void perl_irc_server_fill_hash(HV *hv, IRC_SERVER_REC *server)
(void) hv_store(hv, "isupport_sent", 13, newSViv(server->isupport_sent), 0);
(void) hv_store(hv, "cap_complete", 12, newSViv(server->cap_complete), 0);
+ (void) hv_store(hv, "sasl_success", 12, newSViv(server->sasl_success), 0);
av = newAV();
for (tmp = server->cap_supported; tmp != NULL; tmp = tmp->next)
diff --git a/src/perl/irc/Makefile.PL.in b/src/perl/irc/Makefile.PL.in
index 0fbc5241..582160a0 100644
--- a/src/perl/irc/Makefile.PL.in
+++ b/src/perl/irc/Makefile.PL.in
@@ -1,4 +1,4 @@
-use ExtUtils::MakeMaker;our $AM_DEFAULT_VERBOSITY='@AM_DEFAULT_VERBOSITY@';require "../Makefile_silent.pm";
+use ExtUtils::MakeMaker;our $AM_DEFAULT_VERBOSITY='@AM_DEFAULT_VERBOSITY@';require "@top_srcdir@/src/perl/Makefile_silent.pm";
WriteMakefile('NAME' => 'Irssi::Irc',
'LIBS' => '',
diff --git a/src/perl/perl-core.c b/src/perl/perl-core.c
index 2c61df70..e4bde559 100644
--- a/src/perl/perl-core.c
+++ b/src/perl/perl-core.c
@@ -41,7 +41,7 @@ GSList *perl_scripts;
PerlInterpreter *my_perl;
static int print_script_errors;
-static char *perl_args[] = {"", "-e", "0"};
+static char *perl_args[] = {"", "-e", "0", NULL};
#define IS_PERL_SCRIPT(file) \
(strlen(file) > 3 && g_strcmp0(file+strlen(file)-3, ".pl") == 0)
@@ -123,7 +123,7 @@ void perl_scripts_init(void)
my_perl = perl_alloc();
perl_construct(my_perl);
- perl_parse(my_perl, xs_init, G_N_ELEMENTS(perl_args), perl_args, NULL);
+ perl_parse(my_perl, xs_init, G_N_ELEMENTS(perl_args)-1, perl_args, NULL);
#if PERL_STATIC_LIBS == 1
perl_eval_pv("Irssi::Core::->boot_Irssi_Core(0.9);", TRUE);
#endif
diff --git a/src/perl/textui/Makefile.PL.in b/src/perl/textui/Makefile.PL.in
index 3541f75c..ffdda21a 100644
--- a/src/perl/textui/Makefile.PL.in
+++ b/src/perl/textui/Makefile.PL.in
@@ -1,4 +1,4 @@
-use ExtUtils::MakeMaker;our $AM_DEFAULT_VERBOSITY='@AM_DEFAULT_VERBOSITY@';require "../Makefile_silent.pm";
+use ExtUtils::MakeMaker;our $AM_DEFAULT_VERBOSITY='@AM_DEFAULT_VERBOSITY@';require "@top_srcdir@/src/perl/Makefile_silent.pm";
WriteMakefile('NAME' => 'Irssi::TextUI',
'LIBS' => '',
diff --git a/src/perl/ui/Makefile.PL.in b/src/perl/ui/Makefile.PL.in
index ed87d528..ceed51c3 100644
--- a/src/perl/ui/Makefile.PL.in
+++ b/src/perl/ui/Makefile.PL.in
@@ -1,4 +1,4 @@
-use ExtUtils::MakeMaker;our $AM_DEFAULT_VERBOSITY='@AM_DEFAULT_VERBOSITY@';require "../Makefile_silent.pm";
+use ExtUtils::MakeMaker;our $AM_DEFAULT_VERBOSITY='@AM_DEFAULT_VERBOSITY@';require "@top_srcdir@/src/perl/Makefile_silent.pm";
WriteMakefile('NAME' => 'Irssi::UI',
'LIBS' => '',