[mapguide-commits] r10090 - branches/4.0/MgDev/Web/src/HttpHandler
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Tue Jul 30 07:43:42 PDT 2024
Author: jng
Date: 2024-07-30 07:43:41 -0700 (Tue, 30 Jul 2024)
New Revision: 10090
Modified:
branches/4.0/MgDev/Web/src/HttpHandler/OgcServer.cpp
branches/4.0/MgDev/Web/src/HttpHandler/OgcWfsException.cpp
branches/4.0/MgDev/Web/src/HttpHandler/OgcWmsException.cpp
Log:
#2878: Lock in these size assumptions with compile-time static_assert
Modified: branches/4.0/MgDev/Web/src/HttpHandler/OgcServer.cpp
===================================================================
--- branches/4.0/MgDev/Web/src/HttpHandler/OgcServer.cpp 2024-07-29 16:00:13 UTC (rev 10089)
+++ branches/4.0/MgDev/Web/src/HttpHandler/OgcServer.cpp 2024-07-30 14:43:41 UTC (rev 10090)
@@ -268,7 +268,7 @@
SZBUF szTypeAttribute[64] = { 0 };
// Rudimentary buffer overrun check.
ASSERT(szlen(this->Type()) + 8 /* "type=''" + EOS */ < char_sizeof(szTypeAttribute));
-
+ static_assert(char_sizeof(szTypeAttribute) <= 64, "char size overflow");
szsprintf(szTypeAttribute,char_sizeof(szTypeAttribute),kpszAttributeTypeFormat,this->Type());
MgXmlElementEmitter Error(Response,this->ElementName(),szTypeAttribute);
@@ -853,6 +853,7 @@
{
// Stringify the number; we almost always need this.
SZBUF szInteger[32] = { 0 };
+ static_assert(char_sizeof(szInteger) <= 32, "char size overflow");
szsprintf(szInteger,char_sizeof(szInteger),_("%d"),iNum);
// Let's be optimistic. Will it be in the set? Probably.
@@ -1461,6 +1462,7 @@
bool MgOgcServer::AddDefinition(CPSZ pszItem,int iValue)
{
SZBUF szInteger[32] = { 0 };
+ static_assert(char_sizeof(szInteger) <= 32, "char size overflow");
szsprintf(szInteger,char_sizeof(szInteger),_("%d"),iValue);
return AddDefinition(pszItem,szInteger);
}
Modified: branches/4.0/MgDev/Web/src/HttpHandler/OgcWfsException.cpp
===================================================================
--- branches/4.0/MgDev/Web/src/HttpHandler/OgcWfsException.cpp 2024-07-29 16:00:13 UTC (rev 10089)
+++ branches/4.0/MgDev/Web/src/HttpHandler/OgcWfsException.cpp 2024-07-30 14:43:41 UTC (rev 10090)
@@ -29,7 +29,8 @@
void MgOgcWfsException::WriteTo(CStream& Response) const
{
- SZBUF szTypeAttribute[64];
+ SZBUF szTypeAttribute[64] = { 0 };
+ static_assert(char_sizeof(szTypeAttribute) <= 64, "char size overflow");
// Rudimentary buffer overrun check.
ASSERT(szlen(this->Type()) + 8 /* "type=''" + EOS */ < char_sizeof(szTypeAttribute));
Modified: branches/4.0/MgDev/Web/src/HttpHandler/OgcWmsException.cpp
===================================================================
--- branches/4.0/MgDev/Web/src/HttpHandler/OgcWmsException.cpp 2024-07-29 16:00:13 UTC (rev 10089)
+++ branches/4.0/MgDev/Web/src/HttpHandler/OgcWmsException.cpp 2024-07-30 14:43:41 UTC (rev 10090)
@@ -47,6 +47,7 @@
void MgOgcWmsException::WriteTo(CStream& Response) const
{
SZBUF szTypeAttribute[64] = { 0 };
+ static_assert(char_sizeof(szTypeAttribute) <= 64, "char size overflow");
// Rudimentary buffer overrun check.
ASSERT(szlen(this->Type()) + 8 /* "type=''" + EOS */ < char_sizeof(szTypeAttribute));
More information about the mapguide-commits
mailing list