Fix double batch on HISTORY #channel.

Reported by k4be in https://bugs.unrealircd.org/view.php?id=5709
This commit is contained in:
Bram Matthys 2020-07-14 19:25:07 +02:00
parent 70496acfbe
commit 3894aeba97
No known key found for this signature in database
GPG key ID: BF8116B163EAAE98

View file

@ -277,17 +277,34 @@ int lr_packet(Client *from, Client *to, Client *intended_to, char **msg, int *le
char *batchstr = gen_start_batch();
int more_tags_one = currentcmd.firstbuf[0] == '@';
int more_tags_two = **msg == '@';
snprintf(packet, sizeof(packet),
"%s\r\n"
"@batch=%s%s%s\r\n"
"@batch=%s%s%s",
batchstr,
currentcmd.batch,
more_tags_one ? ";" : " ",
more_tags_one ? currentcmd.firstbuf+1 : currentcmd.firstbuf,
currentcmd.batch,
more_tags_two ? ";" : " ",
more_tags_two ? *msg+1 : *msg);
if (!strncmp(*msg, "@batch", 6))
{
/* Special case: current message (*msg) already contains a batch */
snprintf(packet, sizeof(packet),
"%s\r\n"
"@batch=%s%s%s\r\n"
"%s",
batchstr,
currentcmd.batch,
more_tags_one ? ";" : " ",
more_tags_one ? currentcmd.firstbuf+1 : currentcmd.firstbuf,
*msg);
} else
{
/* Regular case: current message (*msg) contains no batch yet, add one.. */
snprintf(packet, sizeof(packet),
"%s\r\n"
"@batch=%s%s%s\r\n"
"@batch=%s%s%s",
batchstr,
currentcmd.batch,
more_tags_one ? ";" : " ",
more_tags_one ? currentcmd.firstbuf+1 : currentcmd.firstbuf,
currentcmd.batch,
more_tags_two ? ";" : " ",
more_tags_two ? *msg+1 : *msg);
}
*msg = packet;
*len = strlen(*msg);
} else {