1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-08-08 14:02:17 +03:00

MENT-1263 : ma_format_win32_error could cause invalid parameter exception

If the formatted message was too long, for the buffer, sprintf_s used
in this function raises invalid parameter.

replace sprintf_s with snprintf to fix.
This commit is contained in:
Vladislav Vaintroub
2021-07-19 13:33:51 +02:00
parent 07a15f23a2
commit e9f02c9ea6

View File

@@ -117,7 +117,7 @@ void ma_format_win32_error(char* buf, size_t buflen, DWORD code, _Printf_format_
return;
if (entry)
{
sprintf_s(cur, end - cur, "%s. Error 0x%08lX(%s)", entry->msg, code, entry->sym);
snprintf(cur, end - cur, "%s. Error 0x%08lX(%s)", entry->msg, code, entry->sym);
}
else
{
@@ -131,7 +131,8 @@ void ma_format_win32_error(char* buf, size_t buflen, DWORD code, _Printf_format_
cur++;
*cur = 0;
}
sprintf_s(cur, end - cur, ". Error %lu/0x%08lX", code, code);
snprintf(cur, end - cur, ". Error %lu/0x%08lX", code, code);
}
end[-1] = 0;
}