summaryrefslogtreecommitdiff
path: root/compat/winansi.c
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2015-09-24 17:06:08 -0400
committerLibravatar Junio C Hamano <gitster@pobox.com>2015-09-25 10:18:18 -0700
commit5096d4909f9b13c7a650d9dbb7c9702ea7413566 (patch)
tree07229a8952f2d6782f3064d9dfd1e7855e8e5269 /compat/winansi.c
parentcompat/inet_ntop: fix off-by-one in inet_ntop4 (diff)
downloadtgif-5096d4909f9b13c7a650d9dbb7c9702ea7413566.tar.xz
convert trivial sprintf / strcpy calls to xsnprintf
We sometimes sprintf into fixed-size buffers when we know that the buffer is large enough to fit the input (either because it's a constant, or because it's numeric input that is bounded in size). Likewise with strcpy of constant strings. However, these sites make it hard to audit sprintf and strcpy calls for buffer overflows, as a reader has to cross-reference the size of the array with the input. Let's use xsnprintf instead, which communicates to a reader that we don't expect this to overflow (and catches the mistake in case we do). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'compat/winansi.c')
-rw-r--r--compat/winansi.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/compat/winansi.c b/compat/winansi.c
index efc5bb3a4b..ceff55bd67 100644
--- a/compat/winansi.c
+++ b/compat/winansi.c
@@ -539,7 +539,7 @@ void winansi_init(void)
return;
/* create a named pipe to communicate with the console thread */
- sprintf(name, "\\\\.\\pipe\\winansi%lu", GetCurrentProcessId());
+ xsnprintf(name, sizeof(name), "\\\\.\\pipe\\winansi%lu", GetCurrentProcessId());
hwrite = CreateNamedPipe(name, PIPE_ACCESS_OUTBOUND,
PIPE_TYPE_BYTE | PIPE_WAIT, 1, BUFFER_SIZE, 0, 0, NULL);
if (hwrite == INVALID_HANDLE_VALUE)