Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/commands.c @ 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 | 1802b926e3fa |
comparison
equal
deleted
inserted
replaced
1587:0a1f59dc503d | 1588:5411897a1e7b |
---|---|
1859 rst_msg ? " -- " : "", rst_msg ? rst_msg : ""); | 1859 rst_msg ? " -- " : "", rst_msg ? rst_msg : ""); |
1860 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO, 0); | 1860 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO, 0); |
1861 } else if (style == style_compact) { | 1861 } else if (style == style_compact) { |
1862 enum imrole role = buddy_getrole(bud, p_res->data); | 1862 enum imrole role = buddy_getrole(bud, p_res->data); |
1863 enum imaffiliation affil = buddy_getaffil(bud, p_res->data); | 1863 enum imaffiliation affil = buddy_getaffil(bud, p_res->data); |
1864 | 1864 bool showaffil = (affil != affil_none); |
1865 snprintf(buffer, 4095, "[%c] %s (", imstatus2char[rstatus], | 1865 |
1866 (char*)p_res->data); | 1866 snprintf(buffer, 4095, "[%c] %s (%s%s%s)", |
1867 | 1867 imstatus2char[rstatus], (char*)p_res->data, |
1868 if (affil != affil_none) { | 1868 showaffil ? straffil[affil] : "\0", |
1869 strcat(buffer, straffil[affil]); | 1869 showaffil ? "/" : "\0", |
1870 strcat(buffer, "/"); | 1870 strrole[role]); |
1871 } | |
1872 strcat(buffer, strrole[role]); | |
1873 strcat(buffer, ")"); | |
1874 | |
1875 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO, 0); | 1871 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO, 0); |
1876 } else { | 1872 } else { |
1877 // (Style "normal", "detail" or "quiet") | 1873 // (Style "normal", "detail" or "quiet") |
1878 snprintf(buffer, 4095, "[%c] %s", imstatus2char[rstatus], | 1874 snprintf(buffer, 4095, "[%c] %s", imstatus2char[rstatus], |
1879 (char*)p_res->data); | 1875 (char*)p_res->data); |