1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2025-11-13 20:08:26 -06:00

Windows: replace insecure wcscpy/wcscat/strcpy runtime functions with secure equivalents

This fixed failure to build driver for ARM64 with latest VS 2019
This commit is contained in:
Mounir IDRASSI
2021-07-13 21:59:48 +02:00
parent dce6d76b81
commit c374782436
11 changed files with 58 additions and 44 deletions

View File

@@ -12,6 +12,7 @@
#if !defined(_UEFI)
#include <windows.h>
#include <stdio.h>
#include <strsafe.h>
#else
#include "Tcdefs.h"
#pragma warning( disable : 4706 ) // assignment within conditional expression
@@ -185,26 +186,30 @@ char *XmlQuoteText (const char *textSrc, char *textDst, int textDstMaxSize)
case '&':
if (textDst + 6 > textDstLast)
return NULL;
strcpy (textDst, "&amp;");
StringCchCopyA (textDst, textDstMaxSize, "&amp;");
textDst += 5;
textDstMaxSize -= 5;
continue;
case '>':
if (textDst + 5 > textDstLast)
return NULL;
strcpy (textDst, "&gt;");
StringCchCopyA (textDst, textDstMaxSize, "&gt;");
textDst += 4;
textDstMaxSize -= 4;
continue;
case '<':
if (textDst + 5 > textDstLast)
return NULL;
strcpy (textDst, "&lt;");
StringCchCopyA (textDst, textDstMaxSize, "&lt;");
textDst += 4;
textDstMaxSize -= 4;
continue;
default:
*textDst++ = c;
textDstMaxSize--;
}
}
@@ -230,26 +235,30 @@ wchar_t *XmlQuoteTextW (const wchar_t *textSrc, wchar_t *textDst, int textDstMax
case L'&':
if (textDst + 6 > textDstLast)
return NULL;
wcscpy (textDst, L"&amp;");
StringCchCopyW (textDst, textDstMaxSize, L"&amp;");
textDst += 5;
textDstMaxSize -= 5;
continue;
case L'>':
if (textDst + 5 > textDstLast)
return NULL;
wcscpy (textDst, L"&gt;");
StringCchCopyW (textDst, textDstMaxSize, L"&gt;");
textDst += 4;
textDstMaxSize -= 4;
continue;
case L'<':
if (textDst + 5 > textDstLast)
return NULL;
wcscpy (textDst, L"&lt;");
StringCchCopyW (textDst, textDstMaxSize, L"&lt;");
textDst += 4;
textDstMaxSize -= 4;
continue;
default:
*textDst++ = c;
textDstMaxSize--;
}
}