1
0
mirror of https://github.com/moparisthebest/hexchat synced 2024-11-22 17:22:18 -05:00

Fixed possible overflow in create_mask().

This commit is contained in:
Diogo Sousa 2013-06-08 02:56:36 +01:00
parent 951292abe1
commit f84476cf87

View File

@ -487,19 +487,19 @@ create_mask (session * sess, char *mask, char *mode, char *typestr, int deop)
switch (type) switch (type)
{ {
case 0: case 0:
snprintf (tbuf, TBUFSIZE, "%s%s *!*@%s.*", mode, p2, domain); snprintf (tbuf, sizeof (tbuf), "%s%s *!*@%s.*", mode, p2, domain);
break; break;
case 1: case 1:
snprintf (tbuf, TBUFSIZE, "%s%s *!*@%s", mode, p2, fullhost); snprintf (tbuf, sizeof (tbuf), "%s%s *!*@%s", mode, p2, fullhost);
break; break;
case 2: case 2:
snprintf (tbuf, TBUFSIZE, "%s%s *!%s@%s.*", mode, p2, username, domain); snprintf (tbuf, sizeof (tbuf), "%s%s *!%s@%s.*", mode, p2, username, domain);
break; break;
case 3: case 3:
snprintf (tbuf, TBUFSIZE, "%s%s *!%s@%s", mode, p2, username, fullhost); snprintf (tbuf, sizeof (tbuf), "%s%s *!%s@%s", mode, p2, username, fullhost);
break; break;
} }
} else } else
@ -507,26 +507,26 @@ create_mask (session * sess, char *mask, char *mode, char *typestr, int deop)
switch (type) switch (type)
{ {
case 0: case 0:
snprintf (tbuf, TBUFSIZE, "%s%s *!*@*%s", mode, p2, domain); snprintf (tbuf, sizeof (tbuf), "%s%s *!*@*%s", mode, p2, domain);
break; break;
case 1: case 1:
snprintf (tbuf, TBUFSIZE, "%s%s *!*@%s", mode, p2, fullhost); snprintf (tbuf, sizeof (tbuf), "%s%s *!*@%s", mode, p2, fullhost);
break; break;
case 2: case 2:
snprintf (tbuf, TBUFSIZE, "%s%s *!%s@*%s", mode, p2, username, domain); snprintf (tbuf, sizeof (tbuf), "%s%s *!%s@*%s", mode, p2, username, domain);
break; break;
case 3: case 3:
snprintf (tbuf, TBUFSIZE, "%s%s *!%s@%s", mode, p2, username, fullhost); snprintf (tbuf, sizeof (tbuf), "%s%s *!%s@%s", mode, p2, username, fullhost);
break; break;
} }
} }
} else } else
{ {
snprintf (tbuf, TBUFSIZE, "%s %s", mode, mask); snprintf (tbuf, sizeof (tbuf), "%s %s", mode, mask);
} }
return g_strdup (tbuf); return g_strdup (tbuf);