1
0
mirror of https://github.com/irssi/irssi.git synced 2024-09-29 04:45:57 -04:00

Merge branch 'security' into 'master'

See merge request !7
This commit is contained in:
ailin-nemui 2017-01-03 13:44:58 +01:00
parent eb20a6c846
commit 6c6c42e3d1
4 changed files with 26 additions and 5 deletions

View File

@ -68,7 +68,7 @@ static void format_expand_code(const char **format, GString *out, int *flags)
if (flags == NULL) { if (flags == NULL) {
/* flags are being ignored - skip the code */ /* flags are being ignored - skip the code */
while (**format != ']') while (**format != ']' && **format != '\0')
(*format)++; (*format)++;
return; return;
} }
@ -246,6 +246,10 @@ int format_expand_styles(GString *out, const char **format, int *flags)
case '[': case '[':
/* code */ /* code */
format_expand_code(format, out, flags); format_expand_code(format, out, flags);
if ((*format)[0] == '\0')
/* oops, reached end prematurely */
(*format)--;
break; break;
case 'x': case 'x':
case 'X': case 'X':
@ -972,6 +976,7 @@ static const char *get_ansi_color(THEME_REC *theme, const char *str,
str++; str++;
for (num2 = 0; i_isdigit(*str); str++) for (num2 = 0; i_isdigit(*str); str++)
num2 = num2*10 + (*str-'0'); num2 = num2*10 + (*str-'0');
if (*str == '\0') return start;
switch (num2) { switch (num2) {
case 2: case 2:
@ -989,6 +994,8 @@ static const char *get_ansi_color(THEME_REC *theme, const char *str,
for (; i_isdigit(*str); str++) for (; i_isdigit(*str); str++)
num2 = (num2&~0xff) | num2 = (num2&~0xff) |
(((num2&0xff) * 10 + (*str-'0'))&0xff); (((num2&0xff) * 10 + (*str-'0'))&0xff);
if (*str == '\0') return start;
} }
if (i == -1) break; if (i == -1) break;
@ -1017,6 +1024,7 @@ static const char *get_ansi_color(THEME_REC *theme, const char *str,
str++; str++;
for (num2 = 0; i_isdigit(*str); str++) for (num2 = 0; i_isdigit(*str); str++)
num2 = num2*10 + (*str-'0'); num2 = num2*10 + (*str-'0');
if (*str == '\0') return start;
if (num == 38) { if (num == 38) {
flags &= ~GUI_PRINT_FLAG_COLOR_24_FG; flags &= ~GUI_PRINT_FLAG_COLOR_24_FG;

View File

@ -539,10 +539,17 @@ int term_addstr(TERM_WINDOW *window, const char *str)
if (term_type == TERM_TYPE_UTF8) { if (term_type == TERM_TYPE_UTF8) {
while (*ptr != '\0') { while (*ptr != '\0') {
tmp = g_utf8_get_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; len += unichar_isprint(tmp) ? mk_wcwidth(tmp) : 1;
ptr = g_utf8_next_char(ptr); ptr = g_utf8_next_char(ptr);
} }
}
} else } else
len = raw_len; len = raw_len;

View File

@ -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) static void event_nick_invalid(IRC_SERVER_REC *server, const char *data)
{ {
if (!server->connected) 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) static void event_nick_in_use(IRC_SERVER_REC *server, const char *data)

View File

@ -45,6 +45,8 @@ QUERY_REC *irc_query_find(IRC_SERVER_REC *server, const char *nick)
{ {
GSList *tmp; GSList *tmp;
g_return_val_if_fail(nick != NULL, NULL);
for (tmp = server->queries; tmp != NULL; tmp = tmp->next) { for (tmp = server->queries; tmp != NULL; tmp = tmp->next) {
QUERY_REC *rec = tmp->data; QUERY_REC *rec = tmp->data;