[Liblas-commits] hg: throw an error if the WKT or GeoTIFF GeoAsciiParamsTag gets ...

liblas-commits at liblas.org liblas-commits at liblas.org
Wed Dec 15 12:56:06 EST 2010


changeset 99419472707b in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=99419472707b
summary: throw an error if the WKT or GeoTIFF GeoAsciiParamsTag gets larger than 64k

diffstat:

 src/lasspatialreference.cpp |  24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diffs (41 lines):

diff -r f8621a69bd83 -r 99419472707b src/lasspatialreference.cpp
--- a/src/lasspatialreference.cpp	Wed Dec 15 11:05:08 2010 -0600
+++ b/src/lasspatialreference.cpp	Wed Dec 15 11:55:57 2010 -0600
@@ -374,6 +374,18 @@
              data.push_back(v[0]);
          }
          record.SetData(data);
+
+        if (data.size() > std::numeric_limits<boost::uint16_t>::max())
+        {
+            std::ostringstream oss;
+            std::vector<uint8_t>::size_type overrun = data.size() - static_cast<std::vector<uint8_t>::size_type>(std::numeric_limits<boost::uint16_t>::max());
+            oss << "The size of the GeoTIFF GeoAsciiParamsTag, " << data.size() << ", is " << overrun 
+                << " bytes too large to fit inside the maximum size of a VLR which is " 
+                << std::numeric_limits<boost::uint16_t>::max() << " bytes.";
+            throw std::runtime_error(oss.str());
+
+        }
+
          m_vlrs.push_back(record);
     }
 #endif // ndef HAVE_LIBGEOTIFF
@@ -400,6 +412,18 @@
 
         data.push_back( '\0' );
 
+        if (data.size() > std::numeric_limits<boost::uint16_t>::max())
+        {
+            std::ostringstream oss;
+            std::vector<uint8_t>::size_type overrun = data.size() - static_cast<std::vector<uint8_t>::size_type>(std::numeric_limits<boost::uint16_t>::max());
+            oss << "The size of the wkt, " << data.size() << ", is " << overrun 
+                << " bytes too large to fit inside the maximum size of a VLR which is " 
+                << std::numeric_limits<boost::uint16_t>::max() << " bytes.";
+            throw std::runtime_error(oss.str());
+
+        }
+
+
         wkt_record.SetRecordLength( data.size() );
         wkt_record.SetData(data);
 


More information about the Liblas-commits mailing list