# HG changeset patch # User Mikael Berthe # Date 1254674267 -7200 # Node ID 5411897a1e7b85b6bed783029d66c90dfcb3a93c # Parent 0a1f59dc503d328521e6f9c6dff233da1dfac915 Avoid strcat() This patch removes strcat() and prevents possible buffer overflow introduced in the previous changeset. diff -r 0a1f59dc503d -r 5411897a1e7b mcabber/src/commands.c --- a/mcabber/src/commands.c Wed Jul 29 03:13:04 2009 +0400 +++ b/mcabber/src/commands.c Sun Oct 04 18:37:47 2009 +0200 @@ -1861,17 +1861,13 @@ } else if (style == style_compact) { enum imrole role = buddy_getrole(bud, p_res->data); enum imaffiliation affil = buddy_getaffil(bud, p_res->data); - - snprintf(buffer, 4095, "[%c] %s (", imstatus2char[rstatus], - (char*)p_res->data); - - if (affil != affil_none) { - strcat(buffer, straffil[affil]); - strcat(buffer, "/"); - } - strcat(buffer, strrole[role]); - strcat(buffer, ")"); - + bool showaffil = (affil != affil_none); + + snprintf(buffer, 4095, "[%c] %s (%s%s%s)", + imstatus2char[rstatus], (char*)p_res->data, + showaffil ? straffil[affil] : "\0", + showaffil ? "/" : "\0", + strrole[role]); scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO, 0); } else { // (Style "normal", "detail" or "quiet")