You've already forked mariadb-connector-c
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:
@@ -117,7 +117,7 @@ void ma_format_win32_error(char* buf, size_t buflen, DWORD code, _Printf_format_
|
|||||||
return;
|
return;
|
||||||
if (entry)
|
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
|
else
|
||||||
{
|
{
|
||||||
@@ -131,7 +131,8 @@ void ma_format_win32_error(char* buf, size_t buflen, DWORD code, _Printf_format_
|
|||||||
cur++;
|
cur++;
|
||||||
*cur = 0;
|
*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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user