]> source.dussan.org Git - tigervnc.git/commitdiff
Avoid using insecure variable length arrays
authorPierre Ossman <ossman@cendio.se>
Thu, 26 Mar 2020 07:50:04 +0000 (08:50 +0100)
committerPierre Ossman <ossman@cendio.se>
Thu, 26 Mar 2020 07:50:04 +0000 (08:50 +0100)
common/rdr/Exception.cxx

index 9b6096b66da65af05ed95252b08e58cc6ac8b6b2..f4e238369f36de05eb8794896b440b934064d4db 100644 (file)
@@ -57,10 +57,11 @@ GAIException::GAIException(const char* s, int err)
 {
   strncat(str_, ": ", len-1-strlen(str_));
 #ifdef _WIN32
-  wchar_t currStr[len-strlen(str_)];
+  wchar_t *currStr = new wchar_t[len-strlen(str_)];
   wcsncpy(currStr, gai_strerrorW(err), len-1-strlen(str_));
   WideCharToMultiByte(CP_UTF8, 0, currStr, -1, str_+strlen(str_),
                       len-1-strlen(str_), 0, 0);
+  delete [] currStr;
 #else
   //FIXME: perhaps print the error number (NNNN)
   strncat(str_, gai_strerror(err), len-1-strlen(str_));