diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2018-08-10 00:52:48 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2018-08-10 00:52:48 +0200 |
commit | 1cc2a892f247dd83c915a6d16317a5424d470476 (patch) | |
tree | 0f1591c073b307e7b27cfa982f6c7a46ebb4c3d0 /src/ptunnel.c | |
parent | 7faee4052ffea5f989ca557968d445f33fb02e69 (diff) |
print_last_windows_error(): snprintf: undefined behavior if using variable as param and dest
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'src/ptunnel.c')
-rw-r--r-- | src/ptunnel.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/ptunnel.c b/src/ptunnel.c index 7ac7ecb..c83ee24 100644 --- a/src/ptunnel.c +++ b/src/ptunnel.c @@ -63,11 +63,13 @@ /** Local error string storage */ static char errorstr[255]; static char * print_last_windows_error() { + char last_errorstr[255]; DWORD last_error = GetLastError(); - memset(errorstr, 0, sizeof(errorstr)); + + memset(last_errorstr, 0, sizeof(last_errorstr)); FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, last_error, 0, errorstr, sizeof(errorstr), NULL); - snprintf(errorstr, sizeof(errorstr), "%s (%lu)", errorstr, last_error); + NULL, last_error, 0, last_errorstr, sizeof(last_errorstr), NULL); + snprintf(errorstr, sizeof(errorstr), "%s (%lu)", last_errorstr, last_error); return errorstr; } #define strerror(x) print_last_windows_error() |