summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--NEWS2
-rw-r--r--configure.ac41
-rw-r--r--m4/glib-2.0.m42
-rw-r--r--src/Makefile.am6
-rw-r--r--src/fe-common/core/hilight-text.c15
-rw-r--r--src/fe-common/core/printtext.c2
-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-windows.c10
-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.c8
-rw-r--r--src/fe-text/textbuffer.h1
15 files changed, 317 insertions, 17 deletions
diff --git a/.gitignore b/.gitignore
index 945b6cf6..9af0c4b1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -32,6 +32,7 @@ docs/help/[a-z]*
docs/help/in/Makefile.am
src/fe-text/irssi
+src/fe-fuzz/irssi-fuzz
src/fe-common/irc/irc-modules.c
src/irc/irc.c
@@ -46,6 +47,9 @@ src/perl/ui/*.c
src/perl/*/MYMETA.*
src/perl/*/Makefile.old
+src/fe-fuzz/crash-*
+src/fe-fuzz/oom-*
+
*.a
*.bs
*.la
diff --git a/NEWS b/NEWS
index f2af5810..2553d0da 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,5 @@
+v1.1-head 2017-xx-xx The Irssi team <staff@irssi.org>
+
v1.0.1 2017-02-03 The Irssi team <staff@irssi.org>
- Fix Perl compilation in object dir. By Martijn Dekker (#602, #623).
- Disable EC cryptography on Solaris to fix build (#604, #598).
diff --git a/configure.ac b/configure.ac
index 4a96920c..8d1ba706 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT(irssi, 1.0.1)
+AC_INIT(irssi, 1.1-head)
AC_CONFIG_SRCDIR([src])
AC_CONFIG_AUX_DIR(build-aux)
AC_PREREQ(2.50)
@@ -52,6 +52,19 @@ AC_ARG_WITH(bot,
fi,
want_irssibot=no)
+AC_ARG_WITH(fuzzer,
+[ --with-fuzzer Build irssi-fuzzer],
+ if test x$withval = xno; then
+ want_irssifuzzer=no
+ else
+ want_irssifuzzer=yes
+ fi,
+ want_irssifuzzer=no)
+
+AC_ARG_WITH(fuzzer-lib,
+[ --with-fuzzer-lib Specify path to fuzzer library],
+ fuzzerlibpath="$withval")
+
AC_ARG_WITH(proxy,
[ --with-proxy Build irssi-proxy],
if test x$withval = xno; then
@@ -298,6 +311,30 @@ if test "x$want_textui" != "xno"; then
fi
dnl **
+dnl ** irssifuzzer checks
+dnl **
+
+if test "$want_irssifuzzer" != "no"; then
+ dnl * we need to build with -fsanitize-coverage=trace-pc-guard
+ dnl * otherwise fuzzer won't be very successful at finding bugs :)
+ if test -z "$SANFLAGS"; then
+ SANFLAGS="-g -fsanitize=address -fsanitize-coverage=trace-pc-guard"
+ fi
+ CFLAGS="$CFLAGS $SANFLAGS"
+ CXXFLAGS="$CXXFLAGS $SANFLAGS"
+
+ AC_MSG_CHECKING(for fuzzer library)
+
+ if test -z "$fuzzerlibpath"; then
+ AC_MSG_RESULT([not found, building without fuzzer front end])
+ want_irssifuzzer=no
+ else
+ FUZZER_LIBS="$fuzzerlibpath"
+ AC_SUBST(FUZZER_LIBS)
+ fi
+fi
+
+dnl **
dnl ** perl checks
dnl **
@@ -456,6 +493,7 @@ fi
dnl ** check what we want to build
AM_CONDITIONAL(BUILD_TEXTUI, test "$want_textui" = "yes")
AM_CONDITIONAL(BUILD_IRSSIBOT, test "$want_irssibot" = "yes")
+AM_CONDITIONAL(BUILD_IRSSIFUZZER, test "$want_irssifuzzer" = "yes")
AM_CONDITIONAL(BUILD_IRSSIPROXY, test "$want_irssiproxy" = "yes")
AM_CONDITIONAL(HAVE_PERL, test "$want_perl" != "no")
@@ -572,6 +610,7 @@ src/fe-common/core/Makefile
src/fe-common/irc/Makefile
src/fe-common/irc/dcc/Makefile
src/fe-common/irc/notifylist/Makefile
+src/fe-fuzz/Makefile
src/fe-none/Makefile
src/fe-text/Makefile
src/lib-config/Makefile
diff --git a/m4/glib-2.0.m4 b/m4/glib-2.0.m4
index 2c8760b7..5b7c84c0 100644
--- a/m4/glib-2.0.m4
+++ b/m4/glib-2.0.m4
@@ -43,7 +43,7 @@ AC_ARG_ENABLE(glibtest, [ --disable-glibtest do not try to compile and run
min_glib_version=ifelse([$1], ,2.0.0,$1)
AC_MSG_CHECKING(for GLIB - version >= $min_glib_version)
- if test x$PKG_CONFIG != xno ; then
+ if test "x$PKG_CONFIG" != xno ; then
## don't try to run the test against uninstalled libtool libs
if $PKG_CONFIG --uninstalled $pkg_config_args; then
echo "Will use uninstalled version of GLib found in PKG_CONFIG_PATH"
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/fe-common/core/hilight-text.c b/src/fe-common/core/hilight-text.c
index 037cde5c..dd38be87 100644
--- a/src/fe-common/core/hilight-text.c
+++ b/src/fe-common/core/hilight-text.c
@@ -399,34 +399,29 @@ static void sig_print_text(TEXT_DEST_REC *dest, const char *text,
char *middle;
int pos, color_pos, color_len;
- tmp = g_string_new(NULL);
-
/* start of the line */
pos = strip_real_length(text, hilight_start, NULL, NULL);
- g_string_append(tmp, text);
- g_string_truncate(tmp, pos);
+ tmp = g_string_new_len(text, pos);
/* color */
g_string_append(tmp, color);
/* middle of the line, stripped */
- middle = strip_codes(text+pos);
- pos = tmp->len;
- g_string_append(tmp, middle);
- g_string_truncate(tmp, pos+hilight_len);
+ middle = strip_codes(text + pos);
+ g_string_append_len(tmp, middle, hilight_len);
g_free(middle);
/* end of the line */
pos = strip_real_length(text, hilight_end,
&color_pos, &color_len);
if (color_pos > 0)
- g_string_append_len(tmp, text+color_pos, color_len);
+ g_string_append_len(tmp, text + color_pos, color_len);
else {
/* no colors in line, change back to default */
g_string_append_c(tmp, 4);
g_string_append_c(tmp, FORMAT_STYLE_DEFAULTS);
}
- g_string_append(tmp, text+pos);
+ g_string_append(tmp, text + pos);
newstr = tmp->str;
g_string_free(tmp, FALSE);
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-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-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/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 ae4636a5..3668f4c7 100644
--- a/src/fe-text/textbuffer.c
+++ b/src/fe-text/textbuffer.c
@@ -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);
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