Mercurial > hg
changeset 1588:5411897a1e7b
Avoid strcat()
This patch removes strcat() and prevents possible buffer overflow introduced
in the previous changeset.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sun, 04 Oct 2009 18:37:47 +0200 |
parents | 0a1f59dc503d |
children | 23c08d4f1d1e |
files | mcabber/src/commands.c |
diffstat | 1 files changed, 7 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- 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")