From 7c63b666f989358aa3911bddaee1966d44e319df Mon Sep 17 00:00:00 2001 From: artemp Date: Wed, 24 Jul 2013 11:02:06 +0100 Subject: [PATCH 1/5] cast toff_t to std::streamoff remove 'C' style comments!! --- include/mapnik/tiff_io.hpp | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/include/mapnik/tiff_io.hpp b/include/mapnik/tiff_io.hpp index 9303aab5a..d3c52a5c4 100644 --- a/include/mapnik/tiff_io.hpp +++ b/include/mapnik/tiff_io.hpp @@ -2,7 +2,7 @@ * * This file is part of Mapnik (c++ mapping toolkit) * - * Copyright (C) 2011 Artem Pavlenko + * Copyright (C) 2013 Artem Pavlenko * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -86,7 +86,7 @@ static toff_t tiff_seek_proc(thandle_t fd, toff_t off, int whence) // grow std::stringstream buffer (re: libtiff/tif_stream.cxx) std::ios::pos_type pos = out->tellp(); // second check needed for clang (libcxx doesn't set failbit when seeking beyond the current buffer size - if( out->fail() || off != pos) + if( out->fail() || static_cast(off) != pos) { std::ios::iostate old_state; std::ios::pos_type origin; @@ -146,16 +146,16 @@ static toff_t tiff_size_proc(thandle_t fd) return (toff_t)len; } -static tsize_t tiff_dummy_read_proc(thandle_t /*fd*/, tdata_t /*buf*/, tsize_t /*size*/) +static tsize_t tiff_dummy_read_proc(thandle_t , tdata_t , tsize_t) { return 0; } -static void tiff_dummy_unmap_proc(thandle_t /*fd*/, tdata_t /*base*/, toff_t /*size*/) +static void tiff_dummy_unmap_proc(thandle_t , tdata_t , toff_t) { } -static int tiff_dummy_map_proc(thandle_t /*fd*/, tdata_t* /*pbase*/, toff_t* /*psize*/) +static int tiff_dummy_map_proc(thandle_t , tdata_t*, toff_t* ) { return 0; } @@ -193,17 +193,16 @@ void save_as_tiff(T1 & file, T2 const& image) // TODO - handle palette images // std::vector const& palette - /* - unsigned short r[256], g[256], b[256]; - for (int i = 0; i < (1 << 24); ++i) - { - r[i] = (unsigned short)palette[i * 3 + 0] << 8; - g[i] = (unsigned short)palette[i * 3 + 1] << 8; - b[i] = (unsigned short)palette[i * 3 + 2] << 8; - } - TIFFSetField(output, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_PALETTE); - TIFFSetField(output, TIFFTAG_COLORMAP, r, g, b); - */ + + // unsigned short r[256], g[256], b[256]; + // for (int i = 0; i < (1 << 24); ++i) + // { + // r[i] = (unsigned short)palette[i * 3 + 0] << 8; + // g[i] = (unsigned short)palette[i * 3 + 1] << 8; + // b[i] = (unsigned short)palette[i * 3 + 2] << 8; + // } + // TIFFSetField(output, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_PALETTE); + // TIFFSetField(output, TIFFTAG_COLORMAP, r, g, b); #ifdef HAVE_GEOTIFF GTIF* geotiff = GTIFNew(output); From eaeccc3c3a87db70b8ab53866956cb9a5cecc8d6 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 24 Jul 2013 14:24:33 -0400 Subject: [PATCH 2/5] enforce valid hsla values - refs #1954 --- include/mapnik/image_filter_types.hpp | 14 +++++++++++++- .../data/broken_maps/invalid-scale-hsla-filter.xml | 4 ++++ ...er-with-background-image-and-hsla-transform.xml | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 tests/data/broken_maps/invalid-scale-hsla-filter.xml diff --git a/include/mapnik/image_filter_types.hpp b/include/mapnik/image_filter_types.hpp index e5f0b5db6..f6918dccd 100644 --- a/include/mapnik/image_filter_types.hpp +++ b/include/mapnik/image_filter_types.hpp @@ -26,13 +26,17 @@ // mapnik #include #include +#include + // boost #include + // stl #include #include #include // for std::back_insert_iterator + namespace mapnik { namespace filter { struct blur {}; @@ -66,7 +70,15 @@ struct scale_hsla l0(_l0), l1(_l1), a0(_a0), - a1(_a1) {} + a1(_a1) { + if (h0 < 0 || h1 > 1 || + s0 < 0 || s1 > 1 || + l0 < 0 || l1 > 1 || + a0 < 0 || a1 > 1) + { + throw config_error("scale-hsla values must be between 0 and 1"); + } + } inline bool is_identity() const { return (h0 == 0 && h1 == 1 && diff --git a/tests/data/broken_maps/invalid-scale-hsla-filter.xml b/tests/data/broken_maps/invalid-scale-hsla-filter.xml new file mode 100644 index 000000000..fec9d9eb0 --- /dev/null +++ b/tests/data/broken_maps/invalid-scale-hsla-filter.xml @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/tests/visual_tests/styles/marker-with-background-image-and-hsla-transform.xml b/tests/visual_tests/styles/marker-with-background-image-and-hsla-transform.xml index 4d691fbaa..96a0756a3 100644 --- a/tests/visual_tests/styles/marker-with-background-image-and-hsla-transform.xml +++ b/tests/visual_tests/styles/marker-with-background-image-and-hsla-transform.xml @@ -1,7 +1,7 @@