Convert sprintf calls to snprintf. From pvaldes.

git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@455 13b04d17-f746-0410-82c6-800466cd88b0
This commit is contained in:
Tim Cava
2013-11-11 21:28:55 +00:00
parent 1bafc85e23
commit c9d059cee6

View File

@@ -2521,9 +2521,9 @@ char buffer[BIG_BUFFER_SIZE+1];
if (old && *old) if (old && *old)
{ {
if (strchr(completes[0], ' ')) if (strchr(completes[0], ' '))
sprintf(buffer, "%s%s\"%s\"", inp, space, i ? completes[0] : old); snprintf(buffer, sizeof buffer, "%s%s\"%s\"", inp, space, i ? completes[0] : old);
else else
sprintf(buffer, "%s%s%s", inp, space, i ? completes[0] : old); snprintf(buffer, sizeof buffer, "%s%s%s", inp, space, i ? completes[0] : old);
} }
else else
strcpy(buffer, completes[0]); strcpy(buffer, completes[0]);
@@ -2684,13 +2684,13 @@ do_more_tab:
else if (suggested && *suggested) else if (suggested && *suggested)
p = m_3dup("/", suggested, ""); p = m_3dup("/", suggested, "");
if (type == TABKEY_COMPLETION) if (type == TABKEY_COMPLETION)
snprintf(buffer, BIG_BUFFER_SIZE, "%s %s%s%s ", (p && *p == '/') ? p : "/m", get, (p && (*p != '/'))?space:empty_string, (p && (*p != '/'))?p:empty_string); snprintf(buffer, sizeof buffer, "%s %s%s%s ", (p && *p == '/') ? p : "/m", get, (p && (*p != '/'))?space:empty_string, (p && (*p != '/'))?p:empty_string);
else else
{ {
if (wcount == 1 && got_space) if (wcount == 1 && got_space)
snprintf(buffer, BIG_BUFFER_SIZE, "%s %s ", get_input(), get); snprintf(buffer, sizeof buffer, "%s %s ", get_input(), get);
else else
snprintf(buffer, BIG_BUFFER_SIZE, "%s%s%s ", p ? p : get, p ? space : empty_string, p ? get : empty_string); snprintf(buffer, sizeof buffer, "%s%s%s ", p ? p : get, p ? space : empty_string, p ? get : empty_string);
} }
if ((type == CDCC_COMPLETION || type == LOAD_COMPLETION || type == FILE_COMPLETION || type == DCC_COMPLETION) || ((type == EXEC_COMPLETION) && (get[strlen(get)-1] == '/'))) if ((type == CDCC_COMPLETION || type == LOAD_COMPLETION || type == FILE_COMPLETION || type == DCC_COMPLETION) || ((type == EXEC_COMPLETION) && (get[strlen(get)-1] == '/')))
chop(buffer, 1); chop(buffer, 1);