From 5c1fa6b14567a6d4938a9c610427e26bd2d5edd2 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Thu, 16 Apr 2020 11:49:43 +0200 Subject: [PATCH] Fix Win32 error formatting. --- libmariadb/win32_errmsg.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libmariadb/win32_errmsg.c b/libmariadb/win32_errmsg.c index ede2202e..eaa5872f 100644 --- a/libmariadb/win32_errmsg.c +++ b/libmariadb/win32_errmsg.c @@ -93,12 +93,17 @@ void ma_format_win32_error(char* buf, size_t buflen, DWORD code, _Printf_format_ ENTRY(SEC_I_CONTEXT_EXPIRED, "The context has expired and can no longer be used"), ENTRY(SEC_E_ALGORITHM_MISMATCH, "no cipher match"), ENTRY(SEC_E_NO_CREDENTIALS, "no credentials"), - ENTRY(SEC_E_INVALID_TOKEN, "The token supplied to function is invalid") + ENTRY(SEC_E_INVALID_TOKEN, "The token supplied to function is invalid"), + ENTRY(SEC_E_UNSUPPORTED_FUNCTION,"The function requested is not supported") }; struct map_entry* entry = NULL; - strncpy_s(cur,end-cur, ". ", _TRUNCATE); - cur += 2; + + if (cur > buf && cur[-1] != ' ' && cur[-1] != '.') + { + strncpy_s(cur,end-cur, ". ", _TRUNCATE); + cur += 2; + } for (size_t i = 0; i < sizeof(map) / sizeof(map[0]); i++) {