mirror of
https://github.com/weechat/weechat.git
synced 2026-06-28 13:56:37 +02:00
irc: fix integer overflow in loops (issue #2178)
This commit is contained in:
@@ -1291,14 +1291,14 @@ void
|
||||
irc_channel_join_smart_filtered_unmask (struct t_irc_channel *channel,
|
||||
const char *nick)
|
||||
{
|
||||
int i, unmask_delay, length_tags, nick_found, join, account;
|
||||
int unmask_delay, length_tags, nick_found, join, account;
|
||||
int chghost, setname, nick_changed, smart_filtered, remove_smart_filter;
|
||||
time_t *ptr_time, date_min;
|
||||
struct t_hdata *hdata_line, *hdata_line_data;
|
||||
struct t_gui_line *own_lines;
|
||||
struct t_gui_line *line;
|
||||
struct t_gui_line_data *line_data;
|
||||
const char **tags, *irc_nick1, *irc_nick2;
|
||||
const char **tags, *irc_nick1, *irc_nick2, **ptr_tag;
|
||||
char *new_tags, *nick_to_search;
|
||||
struct t_hashtable *hashtable;
|
||||
|
||||
@@ -1375,30 +1375,30 @@ irc_channel_join_smart_filtered_unmask (struct t_irc_channel *channel,
|
||||
irc_nick1 = NULL;
|
||||
irc_nick2 = NULL;
|
||||
smart_filtered = 0;
|
||||
for (i = 0; tags[i]; i++)
|
||||
for (ptr_tag = tags; *ptr_tag; ptr_tag++)
|
||||
{
|
||||
if (strncmp (tags[i], "nick_", 5) == 0)
|
||||
if (strncmp (*ptr_tag, "nick_", 5) == 0)
|
||||
{
|
||||
if (strcmp (tags[i] + 5, nick_to_search) == 0)
|
||||
if (strcmp (*ptr_tag + 5, nick_to_search) == 0)
|
||||
nick_found = 1;
|
||||
}
|
||||
else if (strcmp (tags[i], "irc_join") == 0)
|
||||
else if (strcmp (*ptr_tag, "irc_join") == 0)
|
||||
join = 1;
|
||||
else if (strcmp (tags[i], "irc_account") == 0)
|
||||
else if (strcmp (*ptr_tag, "irc_account") == 0)
|
||||
account = 1;
|
||||
else if (strcmp (tags[i], "irc_chghost") == 0)
|
||||
else if (strcmp (*ptr_tag, "irc_chghost") == 0)
|
||||
chghost = 1;
|
||||
else if (strcmp (tags[i], "irc_setname") == 0)
|
||||
else if (strcmp (*ptr_tag, "irc_setname") == 0)
|
||||
setname = 1;
|
||||
else if (strcmp (tags[i], "irc_nick") == 0)
|
||||
else if (strcmp (*ptr_tag, "irc_nick") == 0)
|
||||
nick_changed = 1;
|
||||
else if (strncmp (tags[i], "irc_nick1_", 10) == 0)
|
||||
irc_nick1 = tags[i] + 10;
|
||||
else if (strncmp (tags[i], "irc_nick2_", 10) == 0)
|
||||
irc_nick2 = tags[i] + 10;
|
||||
else if (strcmp (tags[i], "irc_smart_filter") == 0)
|
||||
else if (strncmp (*ptr_tag, "irc_nick1_", 10) == 0)
|
||||
irc_nick1 = *ptr_tag + 10;
|
||||
else if (strncmp (*ptr_tag, "irc_nick2_", 10) == 0)
|
||||
irc_nick2 = *ptr_tag + 10;
|
||||
else if (strcmp (*ptr_tag, "irc_smart_filter") == 0)
|
||||
smart_filtered = 1;
|
||||
length_tags += strlen (tags[i]) + 1;
|
||||
length_tags += strlen (*ptr_tag) + 1;
|
||||
}
|
||||
|
||||
/* check if we must remove tag "irc_smart_filter" in line */
|
||||
@@ -1430,13 +1430,13 @@ irc_channel_join_smart_filtered_unmask (struct t_irc_channel *channel,
|
||||
{
|
||||
/* build a string with all tags, except "irc_smart_filter" */
|
||||
new_tags[0] = '\0';
|
||||
for (i = 0; tags[i]; i++)
|
||||
for (ptr_tag = tags; *ptr_tag; ptr_tag++)
|
||||
{
|
||||
if (strcmp (tags[i], "irc_smart_filter") != 0)
|
||||
if (strcmp (*ptr_tag, "irc_smart_filter") != 0)
|
||||
{
|
||||
if (new_tags[0])
|
||||
strcat (new_tags, ",");
|
||||
strcat (new_tags, tags[i]);
|
||||
strcat (new_tags, *ptr_tag);
|
||||
}
|
||||
}
|
||||
hashtable = weechat_hashtable_new (4,
|
||||
|
||||
@@ -422,8 +422,8 @@ char *
|
||||
irc_server_eval_fingerprint (struct t_irc_server *server)
|
||||
{
|
||||
const char *ptr_fingerprint;
|
||||
char *fingerprint_eval, **fingerprints, *str_sizes;
|
||||
int i, j, rc, algo, length;
|
||||
char *fingerprint_eval, **fingerprints, *str_sizes, **ptr;
|
||||
int i, rc, algo, length;
|
||||
|
||||
if (!server)
|
||||
return NULL;
|
||||
@@ -460,18 +460,18 @@ irc_server_eval_fingerprint (struct t_irc_server *server)
|
||||
return fingerprint_eval;
|
||||
|
||||
rc = 0;
|
||||
for (i = 0; fingerprints[i]; i++)
|
||||
for (ptr = fingerprints; *ptr; ptr++)
|
||||
{
|
||||
length = strlen (fingerprints[i]);
|
||||
length = strlen (*ptr);
|
||||
algo = irc_server_fingerprint_search_algo_with_size (length * 4);
|
||||
if (algo < 0)
|
||||
{
|
||||
rc = -1;
|
||||
break;
|
||||
}
|
||||
for (j = 0; j < length; j++)
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
if (!isxdigit ((unsigned char)fingerprints[i][j]))
|
||||
if (!isxdigit ((unsigned char)((*ptr)[i])))
|
||||
{
|
||||
rc = -2;
|
||||
break;
|
||||
@@ -4954,7 +4954,7 @@ irc_server_check_certificate_fingerprint (struct t_irc_server *server,
|
||||
const char *good_fingerprints)
|
||||
{
|
||||
unsigned char *fingerprint_server[IRC_FINGERPRINT_NUM_ALGOS];
|
||||
char **fingerprints;
|
||||
char **fingerprints, **ptr_fingerprint;
|
||||
int i, rc, algo;
|
||||
size_t size_bits, size_bytes;
|
||||
|
||||
@@ -4974,9 +4974,9 @@ irc_server_check_certificate_fingerprint (struct t_irc_server *server,
|
||||
|
||||
rc = 0;
|
||||
|
||||
for (i = 0; fingerprints[i]; i++)
|
||||
for (ptr_fingerprint = fingerprints; *ptr_fingerprint; ptr_fingerprint++)
|
||||
{
|
||||
size_bits = strlen (fingerprints[i]) * 4;
|
||||
size_bits = strlen (*ptr_fingerprint) * 4;
|
||||
size_bytes = size_bits / 8;
|
||||
|
||||
algo = irc_server_fingerprint_search_algo_with_size (size_bits);
|
||||
@@ -5018,7 +5018,7 @@ irc_server_check_certificate_fingerprint (struct t_irc_server *server,
|
||||
if (fingerprint_server[algo])
|
||||
{
|
||||
/* check if the fingerprint matches */
|
||||
if (irc_server_compare_fingerprints (fingerprints[i],
|
||||
if (irc_server_compare_fingerprints (*ptr_fingerprint,
|
||||
fingerprint_server[algo],
|
||||
size_bytes) == 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user