Cleanup crypt_msg(). Use strlcat rather than sprintf and strmcat.

git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@388 13b04d17-f746-0410-82c6-800466cd88b0
This commit is contained in:
Tim Cava
2013-10-13 20:20:52 +00:00
parent e4e2c11429
commit 4f529d214f

View File

@@ -214,21 +214,21 @@ static char *do_crypt(char *str, char *key, int flag)
*/ */
char *crypt_msg(char *str, char *key) char *crypt_msg(char *str, char *key)
{ {
char buffer[CRYPT_BUFFER_SIZE + 1]; char thing[6] = { CTCP_DELIM_CHAR, 0 };
char thing[6] = ""; char buffer[CRYPT_BUFFER_SIZE];
char *ptr; char *ptr;
sprintf(thing, "%cSED ", CTCP_DELIM_CHAR); strlcat(thing, "SED ", sizeof thing);
*buffer = (char) 0; *buffer = 0;
if ((ptr = do_crypt(str, key, 1))) if ((ptr = do_crypt(str, key, 1)))
{ {
strmcat(buffer, thing, CRYPT_BUFFER_SIZE); strlcat(buffer, thing, sizeof buffer);
strmcat(buffer, ptr, CRYPT_BUFFER_SIZE-1); strlcat(buffer, ptr, sizeof buffer);
strmcat(buffer, CTCP_DELIM_STR, CRYPT_BUFFER_SIZE); strlcat(buffer, CTCP_DELIM_STR, sizeof buffer);
new_free(&ptr); new_free(&ptr);
} }
else else
strmcat(buffer, str, CRYPT_BUFFER_SIZE); strlcat(buffer, str, sizeof buffer);
return (m_strdup(buffer)); return (m_strdup(buffer));
} }