Hello community, here is the log from the commit of package python-imread for openSUSE:Leap:15.2 checked in at 2020-04-30 18:51:32 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Leap:15.2/python-imread (Old) and /work/SRC/openSUSE:Leap:15.2/.python-imread.new.2738 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-imread" Thu Apr 30 18:51:32 2020 rev:4 rq:794276 version:0.7.4 Changes: -------- --- /work/SRC/openSUSE:Leap:15.2/python-imread/python-imread.changes 2020-03-09 18:06:28.664850643 +0100 +++ /work/SRC/openSUSE:Leap:15.2/.python-imread.new.2738/python-imread.changes 2020-04-30 18:51:34.224614762 +0200 @@ -1,0 +2,7 @@ +Tue Apr 14 12:26:14 UTC 2020 - Marketa Calabkova <[email protected]> + +- update to 0.7.4 + * Add missing data to distribution + * Fix several memory access bugs in parsers (reported by Robert Scott) + +------------------------------------------------------------------- Old: ---- imread-0.7.1.tar.gz New: ---- imread-0.7.4.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-imread.spec ++++++ --- /var/tmp/diff_new_pack.puJJLC/_old 2020-04-30 18:51:34.564615487 +0200 +++ /var/tmp/diff_new_pack.puJJLC/_new 2020-04-30 18:51:34.568615495 +0200 @@ -1,7 +1,7 @@ # # spec file for package python-imread # -# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2020 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,12 +18,12 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-imread -Version: 0.7.1 +Version: 0.7.4 Release: 0 Summary: Image reading library License: MIT Group: Development/Languages/Python -Url: http://luispedro.org/software/imread +URL: http://luispedro.org/software/imread Source: https://files.pythonhosted.org/packages/source/i/imread/imread-%{version}.tar.gz BuildRequires: %{python_module devel} BuildRequires: %{python_module numpy-devel} @@ -32,6 +32,7 @@ BuildRequires: fdupes BuildRequires: giflib-devel BuildRequires: libtiff-devel +BuildRequires: pkgconfig BuildRequires: python-rpm-macros BuildRequires: pkgconfig(libjpeg) BuildRequires: pkgconfig(libpng) @@ -39,8 +40,7 @@ # SECTION test requirements BuildRequires: %{python_module nose} # /SECTION -BuildRequires: python-numpy -BuildRoot: %{_tmppath}/%{name}-%{version}-build +Requires: python-numpy %python_subpackages %description @@ -70,7 +70,6 @@ %python_exec setup.py test %files %{python_files} -%defattr(-,root,root,-) %doc ChangeLog README.rst %license COPYING.MIT %{python_sitearch}/* ++++++ imread-0.7.1.tar.gz -> imread-0.7.4.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/ChangeLog new/imread-0.7.4/ChangeLog --- old/imread-0.7.1/ChangeLog 2019-05-09 06:53:41.000000000 +0200 +++ new/imread-0.7.4/ChangeLog 2020-04-13 12:35:20.000000000 +0200 @@ -1,3 +1,12 @@ +Version 0.7.4 2020-04-14 by luispedro + * Add missing header files to distribution + +Version 0.7.3 2020-04-09 by luispedro + * Add missing test data to distribution + +Version 0.7.2 2020-03-24 by luispedro + * Fix several memory access bugs in parsers (reported by Robert Scott) + Version 0.7.1 2019-05-09 by luispedro * Fix 16-bit RGB/RGBA TIFF write (patch by Tomi Aarnio) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/MANIFEST.in new/imread-0.7.4/MANIFEST.in --- old/imread-0.7.1/MANIFEST.in 2013-02-13 14:40:58.000000000 +0100 +++ new/imread-0.7.4/MANIFEST.in 2020-04-13 12:34:00.000000000 +0200 @@ -1,6 +1,7 @@ include README.rst include ChangeLog include COPYING.MIT -include imread/lib/*cpp +include imread/lib/*.cpp +include imread/lib/*.h include docs/source/*.rst -include imread/tests/data/* +recursive-include imread/tests/data *tiff *lsm *bmp diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/PKG-INFO new/imread-0.7.4/PKG-INFO --- old/imread-0.7.1/PKG-INFO 2019-05-09 07:14:42.000000000 +0200 +++ new/imread-0.7.4/PKG-INFO 2020-04-13 13:17:07.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: imread -Version: 0.7.1 +Version: 0.7.4 Summary: imread: Image reading library Home-page: http://luispedro.org/software/imread Author: Luis Pedro Coelho @@ -10,8 +10,8 @@ mahotas-imread: Read Image Files ================================ - .. image:: https://api.travis-ci.org/luispedro/imread.png - :target: https://travis-ci.org/luispedro/imread + .. image:: https://api.travis-ci.com/luispedro/imread.png + :target: https://travis-ci.com/luispedro/imread .. image:: https://anaconda.org/conda-forge/imread/badges/license.svg :target: http://opensource.org/licenses/MIT .. image:: https://anaconda.org/conda-forge/imread/badges/installer/conda.svg @@ -140,6 +140,14 @@ History ~~~~~~~ + Version 0.7.3 (2020-04-09) + -------------------------- + - Add missing test data to distribution + + Version 0.7.2 (2020-03-24) + -------------------------- + - Fix several memory access bugs in parsers (reported by Robert Scott) + Version 0.7.1 (2019-05-09) -------------------------- - Fix 16-bit RGB/RGBA TIFF write (patch by Tomi Aarnio) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/README.rst new/imread-0.7.4/README.rst --- old/imread-0.7.1/README.rst 2019-05-09 07:00:05.000000000 +0200 +++ new/imread-0.7.4/README.rst 2020-04-09 16:33:46.000000000 +0200 @@ -2,8 +2,8 @@ mahotas-imread: Read Image Files ================================ -.. image:: https://api.travis-ci.org/luispedro/imread.png - :target: https://travis-ci.org/luispedro/imread +.. image:: https://api.travis-ci.com/luispedro/imread.png + :target: https://travis-ci.com/luispedro/imread .. image:: https://anaconda.org/conda-forge/imread/badges/license.svg :target: http://opensource.org/licenses/MIT .. image:: https://anaconda.org/conda-forge/imread/badges/installer/conda.svg @@ -132,6 +132,14 @@ History ~~~~~~~ +Version 0.7.3 (2020-04-09) +-------------------------- +- Add missing test data to distribution + +Version 0.7.2 (2020-03-24) +-------------------------- +- Fix several memory access bugs in parsers (reported by Robert Scott) + Version 0.7.1 (2019-05-09) -------------------------- - Fix 16-bit RGB/RGBA TIFF write (patch by Tomi Aarnio) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/docs/source/history.rst new/imread-0.7.4/docs/source/history.rst --- old/imread-0.7.1/docs/source/history.rst 2019-05-09 06:54:29.000000000 +0200 +++ new/imread-0.7.4/docs/source/history.rst 2020-04-13 12:35:41.000000000 +0200 @@ -2,6 +2,18 @@ History ======= +Version 0.7.3 (2020-04-09) +-------------------------- +- Add missing header files to distribution + +Version 0.7.3 (2020-04-09) +-------------------------- +- Add missing test data to distribution + +Version 0.7.2 (2020-03-24) +-------------------------- +- Fix several memory access bugs in parsers (reported by Robert Scott) + Version 0.7.1 (2019-05-09) -------------------------- - Fix 16-bit RGB/RGBA TIFF write (patch by Tomi Aarnio) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/imread/_imread.cpp new/imread-0.7.4/imread/_imread.cpp --- old/imread-0.7.1/imread/_imread.cpp 2019-05-09 06:52:45.000000000 +0200 +++ new/imread-0.7.4/imread/_imread.cpp 2019-05-12 17:44:29.000000000 +0200 @@ -1,4 +1,4 @@ -// Copyright 2012-2016 Luis Pedro Coelho <[email protected]> +// Copyright 2012-2019 Luis Pedro Coelho <[email protected]> // License: MIT (see COPYING.MIT file) @@ -89,7 +89,7 @@ return res; } -std::auto_ptr<byte_source> get_input(PyObject* filename_or_blob_object, const bool is_blob) { +std::unique_ptr<byte_source> get_input(PyObject* filename_or_blob_object, const bool is_blob) { if (is_blob) { size_t len; const char* data = get_blob(filename_or_blob_object, len); @@ -97,7 +97,7 @@ PyErr_SetString(PyExc_TypeError, "Expected blob of bytes"); throw py_exception_set(); } - return std::auto_ptr<byte_source>(new memory_source(reinterpret_cast<const byte*>(data), len)); + return std::unique_ptr<byte_source>(new memory_source(reinterpret_cast<const byte*>(data), len)); } else { const char* filename = get_cstring(filename_or_blob_object); if (!filename) throw py_exception_set(); @@ -114,7 +114,7 @@ PyErr_SetString(PyExc_OSError, ss.str().c_str()); throw py_exception_set(); } - return std::auto_ptr<byte_source>(new fd_source_sink(fd)); + return std::unique_ptr<byte_source>(new fd_source_sink(fd)); } } @@ -131,7 +131,7 @@ } try { - std::auto_ptr<byte_source> input = get_input(filename_or_blob_object, is_blob); + std::unique_ptr<byte_source> input = get_input(filename_or_blob_object, is_blob); const char* format = magic_format(&*input); if (!format) Py_RETURN_NONE; #if PY_MAJOR_VERSION >= 3 @@ -177,7 +177,7 @@ options_map opts = parse_options(optsDict); try { - std::auto_ptr<ImageFormat> format(get_format(formatstr)); + std::unique_ptr<ImageFormat> format(get_format(formatstr)); if (!format.get()) { std::stringstream ss; ss << "This format (" << formatstr << ") is unknown to imread"; @@ -201,9 +201,9 @@ } NumpyFactory factory; - std::auto_ptr<byte_source> input = get_input(filename_or_blob_object, is_blob); + std::unique_ptr<byte_source> input = get_input(filename_or_blob_object, is_blob); if (is_multi) { - std::auto_ptr<image_list> images = format->read_multi(input.get(), &factory, opts); + std::unique_ptr<image_list> images = format->read_multi(input.get(), &factory, opts); PyObject* output = PyList_New(images->size()); if (!output) return NULL; std::vector<Image*> pages = images->release(); @@ -213,7 +213,7 @@ } return output; } else { - std::auto_ptr<Image> output = format->read(input.get(), &factory, opts); + std::unique_ptr<Image> output = format->read(input.get(), &factory, opts); PyObject* final = PyTuple_New(2); if (!final) return NULL; PyTuple_SET_ITEM(final, 0, static_cast<NumpyImage&>(*output).releasePyObject()); @@ -266,7 +266,7 @@ } try { options_map opts = parse_options(optsDict); - std::auto_ptr<ImageFormat> format(get_format(formatstr)); + std::unique_ptr<ImageFormat> format(get_format(formatstr)); if (!format.get()) { std::stringstream ss; ss << "Handler not found for format '" << formatstr << "'"; @@ -290,7 +290,7 @@ throw CannotWriteError(ss.str()); } - std::auto_ptr<byte_sink> output(new fd_source_sink(fd)); + std::unique_ptr<byte_sink> output(new fd_source_sink(fd)); if (is_multi) { image_list array_list; @@ -304,7 +304,7 @@ // ~NumpyImage() will decrease the count Py_INCREF(array); NumpyImage* input = new NumpyImage(array); - array_list.push_back(std::auto_ptr<Image>(input)); + array_list.push_back(std::unique_ptr<Image>(input)); } format->write_multi(&array_list, output.get(), opts); } else { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/imread/imread_version.py new/imread-0.7.4/imread/imread_version.py --- old/imread-0.7.1/imread/imread_version.py 2019-05-09 06:53:57.000000000 +0200 +++ new/imread-0.7.4/imread/imread_version.py 2020-04-13 12:34:10.000000000 +0200 @@ -1 +1 @@ -__version__ = '0.7.1' +__version__ = '0.7.4' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/imread/lib/_bmp.cpp new/imread-0.7.4/imread/lib/_bmp.cpp --- old/imread-0.7.1/imread/lib/_bmp.cpp 2019-05-09 06:52:45.000000000 +0200 +++ new/imread-0.7.4/imread/lib/_bmp.cpp 2020-03-23 13:07:36.000000000 +0100 @@ -1,4 +1,4 @@ -// Copyright 2012-2013 Luis Pedro Coelho <[email protected]> +// Copyright 2012-2020 Luis Pedro Coelho <[email protected]> // License: MIT (see COPYING.MIT file) #define NO_IMPORT_ARRAY @@ -25,6 +25,9 @@ // awkward, but works correctly std::vector<byte>::const_iterator pbegin = color_table.begin(); for (int i = w-1; i >= 0; --i) { + if (color_table.size() < 4*row[i] + 3) { + throw CannotReadError("Malformed BMP file: color table is too small"); + } std::copy(pbegin + 4*row[i], pbegin + 4*row[i] + 3, row + 3*i); } } @@ -35,7 +38,7 @@ } } -std::auto_ptr<Image> BMPFormat::read(byte_source* src, ImageFactory* factory, const options_map&) { +std::unique_ptr<Image> BMPFormat::read(byte_source* src, ImageFactory* factory, const options_map&) { char magick[2]; if (src->read(reinterpret_cast<byte*>(magick), 2) != 2) { throw CannotReadError("imread.bmp: File is empty"); @@ -78,13 +81,13 @@ } const int depth = (bitsppixel == 16 ? -1 : 3); const int nbits = (bitsppixel == 16 ? 16 : 8); - std::auto_ptr<Image> output(factory->create(nbits, height, width, depth)); + std::unique_ptr<Image> output(factory->create(nbits, height, width, depth)); std::vector<byte> color_table; if (bitsppixel <= 8) { const uint32_t table_size = (n_colours == 0 ? pow2(bitsppixel) : n_colours); color_table.resize(table_size*4); - src->read_check(&color_table[0], table_size*4); + src->read_check(color_table.data(), table_size*4); } src->seek_absolute(offset); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/imread/lib/_bmp.h new/imread-0.7.4/imread/lib/_bmp.h --- old/imread-0.7.1/imread/lib/_bmp.h 2019-05-09 06:52:45.000000000 +0200 +++ new/imread-0.7.4/imread/lib/_bmp.h 2019-05-12 17:44:29.000000000 +0200 @@ -1,4 +1,4 @@ -// Copyright 2012 Luis Pedro Coelho <[email protected]> +// Copyright 2012-2019 Luis Pedro Coelho <[email protected]> // License: MIT (see COPYING.MIT file) #ifndef LPC_BMP_H_INCLUDE_GUARD_THU_OCT_25_20_16_30_WEST_2012 @@ -11,7 +11,7 @@ bool can_read() const { return true; } bool can_write() const { return false; } - std::auto_ptr<Image> read(byte_source* src, ImageFactory* factory, const options_map& opts); + std::unique_ptr<Image> read(byte_source* src, ImageFactory* factory, const options_map& opts); }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/imread/lib/_jpeg.cpp new/imread-0.7.4/imread/lib/_jpeg.cpp --- old/imread-0.7.1/imread/lib/_jpeg.cpp 2019-05-09 06:52:45.000000000 +0200 +++ new/imread-0.7.4/imread/lib/_jpeg.cpp 2019-05-12 17:44:29.000000000 +0200 @@ -1,4 +1,4 @@ -// Copyright 2012-2014 Luis Pedro Coelho <[email protected]> +// Copyright 2012-2019 Luis Pedro Coelho <[email protected]> // License: MIT (see COPYING.MIT file) #include "base.h" #include "_jpeg.h" @@ -145,7 +145,7 @@ } // namespace -std::auto_ptr<Image> JPEGFormat::read(byte_source* src, ImageFactory* factory, const options_map&) { +std::unique_ptr<Image> JPEGFormat::read(byte_source* src, ImageFactory* factory, const options_map&) { jpeg_source_adaptor adaptor(src); jpeg_decompress_holder c; @@ -165,7 +165,7 @@ const int h = c.info.output_height; const int w = c.info.output_width; const int d = c.info.output_components; - std::auto_ptr<Image> output(factory->create(8, h, w, d)); + std::unique_ptr<Image> output(factory->create(8, h, w, d)); for (int r = 0; r != h; ++r) { byte* rowp = output->rowp_as<byte>(r); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/imread/lib/_jpeg.h new/imread-0.7.4/imread/lib/_jpeg.h --- old/imread-0.7.1/imread/lib/_jpeg.h 2019-05-09 06:52:45.000000000 +0200 +++ new/imread-0.7.4/imread/lib/_jpeg.h 2019-05-12 17:44:29.000000000 +0200 @@ -1,4 +1,4 @@ -// Copyright 2012-2014 Luis Pedro Coelho <[email protected]> +// Copyright 2012-2019 Luis Pedro Coelho <[email protected]> // License: MIT (see COPYING.MIT file) #ifndef LPC_JPEG_H_INCLUDE_GUARD_THU_FEB__2_18_14_07_WET_2012 @@ -13,7 +13,7 @@ static bool match_format(byte_source* src) { return match_magic(src, "\xff\xd8\xff", 3); } - std::auto_ptr<Image> read(byte_source* src, ImageFactory* factory, const options_map& opts); + std::unique_ptr<Image> read(byte_source* src, ImageFactory* factory, const options_map& opts); void write(Image* input, byte_sink* output, const options_map& opts); }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/imread/lib/_lsm.cpp new/imread-0.7.4/imread/lib/_lsm.cpp --- old/imread-0.7.1/imread/lib/_lsm.cpp 2019-05-09 06:52:45.000000000 +0200 +++ new/imread-0.7.4/imread/lib/_lsm.cpp 2020-03-23 13:10:55.000000000 +0100 @@ -5,7 +5,7 @@ This is an open-source copyright as follows: Copyright (c) 2004-2008 BioImageXD Development Team - Copyright (C) 2012 Luis Pedro Coelho + Copyright (C) 2012-2020 Luis Pedro Coelho All rights reserved. @@ -154,7 +154,7 @@ ~LSMReader(); void PrintSelf(std::ostream& os, const char* indent=""); - std::auto_ptr<Image> read(ImageFactory* factory, const options_map&); + std::unique_ptr<Image> read(ImageFactory* factory, const options_map&); void readHeader(); int GetChannelColorComponent(int,int); @@ -167,10 +167,10 @@ private: + static int FindChannelNameStart(const byte *, int); + static int ReadChannelName(const byte *, int, byte *); + unsigned long ReadImageDirectory(byte_source *,unsigned long); - void SetChannelName(const char *,int); - int FindChannelNameStart(const char *, int); - int ReadChannelName(const char *, int, char *); int ReadChannelDataTypes(byte_source*, unsigned long); int ReadChannelColorsAndNames(byte_source *,unsigned long); int ReadTimeStampInformation(byte_source *,unsigned long); @@ -232,45 +232,51 @@ }; -int ReadFile(byte_source* s, unsigned long *pos,int size,void *buf,bool swap=false) +int ReadFile(byte_source* s, unsigned long *pos, int size, void *buf, bool swap=false) { - s->seek_absolute(*pos); - const unsigned ret = s->read(reinterpret_cast<byte*>(buf), size); + s->seek_absolute(*pos); + const unsigned ret = s->read(reinterpret_cast<byte*>(buf), size); #ifdef VTK_WORDS_BIGENDIAN if(swap) { vtkByteSwap::SwapLERange(buf,size); } #endif - *pos += ret; - return ret; + *pos += ret; + return ret; } -int ReadData(byte_source* s, unsigned long *pos,int size,char *buf) { - return ReadFile(s,pos,size,buf,1); -} - std::string read_str(byte_source* s, unsigned long* pos, const unsigned long len) { char* buf = new char[len]; - ReadData(s, pos, len, buf); + ReadFile(s, pos, len, buf, 1); std::string res(buf, len); delete [] buf; return res; } -unsigned char CharPointerToUnsignedChar(char *buf) -{ - return *((unsigned char*)(buf)); -} int CharPointerToInt(char *buf) { return *((int*)(buf)); } -unsigned int CharPointerToUnsignedInt(char *buf) -{ - return *((unsigned int*)(buf)); + +uint32_t parse_uint32_t(const byte *buf) { +#ifdef VTK_WORDS_BIGENDIAN + char buf2[4]; + ::memcpy(buf2, buf, 4); + vtkByteSwap::Swap4LE(buf2); + return *reinterpret_cast<const uint32_t*>(buf2); +#else + return *reinterpret_cast<const uint32_t*>(buf); +#endif +} + +uint32_t parse_uint32_t(const std::vector<byte> &buf) { + if (buf.size() < 4) { + throw CannotReadError("Malformed LSM file: expected 4 Bytes, cannot parse uint32_t"); + } + return parse_uint32_t(buf.data()); } short CharPointerToShort(char *buf) @@ -278,9 +284,22 @@ return *((short*)(buf)); } -unsigned short CharPointerToUnsignedShort(char *buf) -{ - return *((unsigned short*)(buf)); + +uint16_t parse_uint16_t(const byte *buf) { +#ifdef VTK_WORDS_BIGENDIAN + char buf2[2]; + buf2[0] = buf[1]; + buf2[1] = buf[0]; + return *reinterpret_cast<const uint16_t*>(buf2); +#else + return *reinterpret_cast<const uint16_t*>(buf); +#endif +} +uint16_t parse_uint16_t(const std::vector<byte>& buf) { + if (buf.size() < 2) { + throw CannotReadError("Failed to read short (size(vec) < 2)"); + } + return parse_uint16_t(buf.data()); } double CharPointerToDouble(char *buf) @@ -298,14 +317,10 @@ return CharPointerToInt(buff); } -unsigned int ReadUnsignedInt(byte_source* s, unsigned long *pos) -{ - char buff[4]; - ReadFile(s,pos,4,buff); -#ifdef VTK_WORDS_BIGENDIAN - vtkByteSwap::Swap4LE((unsigned int*)buff); -#endif - return CharPointerToUnsignedInt(buff); +unsigned int ReadUnsignedInt(byte_source* s, unsigned long *pos) { + byte buff[4]; + ReadFile(s, pos, 4, buff); + return parse_uint32_t(buff); } short ReadShort(byte_source* s, unsigned long *pos) @@ -318,14 +333,10 @@ return CharPointerToShort(buff); } -unsigned short ReadUnsignedShort(byte_source* s, unsigned long *pos) -{ - char buff[2]; - ReadFile(s,pos,2,buff); -#ifdef VTK_WORDS_BIGENDIAN - vtkByteSwap::Swap2LE((unsigned short*)buff); -#endif - return CharPointerToUnsignedShort(buff); +uint16_t ReadUnsignedShort(byte_source* s, unsigned long *pos) { + byte buff[2]; + ReadFile(s,pos,2,buff); + return parse_uint16_t(buff); } double ReadDouble(byte_source* s, unsigned long *pos) @@ -436,23 +447,15 @@ return this->channel_names_[chNum]; } -void LSMReader::SetChannelName(const char * name, const int chNum) -{ - const int n_channels = this->dimensions_[4]; - if(!name || chNum > n_channels) return; - this->channel_names_.resize(n_channels); - this->channel_names_[chNum] = std::string(name); -} -int LSMReader::FindChannelNameStart(const char *buf, const int length) { +int LSMReader::FindChannelNameStart(const byte *buf, const int length) { for (int i = 0; i < length; ++i) { - char ch = buf[i]; - if (ch > 32) return i; + if (buf[i] > 32) return i; } return length; } -int LSMReader::ReadChannelName(const char *nameBuff, const int length, char *buffer) { +int LSMReader::ReadChannelName(const byte *nameBuff, const int length, byte *buffer) { for (int i = 0; i < length; ++i) { buffer[i] = nameBuff[i]; if (!buffer[i]) return i; @@ -472,67 +475,64 @@ return 0; } -int LSMReader::ReadChannelColorsAndNames(byte_source* s, unsigned long start) -{ - int colNum,nameNum,sizeOfStructure,sizeOfNames,nameLength, nameSkip; - unsigned long colorOffset,nameOffset,pos; - char *nameBuff,*name,*tempBuff; - unsigned char component; - - pos = start; +int LSMReader::ReadChannelColorsAndNames(byte_source* s, const unsigned long start) { + unsigned long pos = start; // Read size of structure - sizeOfStructure = ReadInt(s,&pos); + const int sizeOfStructure = ReadInt(s, &pos); // Read number of colors - colNum = ReadInt(s,&pos); + const int n_cols = ReadInt(s, &pos); // Read number of names - nameNum = ReadInt(s,&pos); - sizeOfNames = sizeOfStructure - ( (10*4) + (colNum*4) ); - - nameBuff = new char[sizeOfNames+1]; - name = new char[sizeOfNames+1]; + const int n_names = ReadInt(s, &pos); + const int sizeOfNames = sizeOfStructure - ( (10*4) + (n_cols*4) ); - if(colNum != this->dimensions_[4]) { - // not great + if(n_cols != this->dimensions_[4]) { + throw CannotReadError("LSM file seems malformed (n_cols != dimensions_[4])"); } - if(nameNum != this->dimensions_[4]) { - // not great + if(n_names != this->dimensions_[4]) { + throw CannotReadError("LSM file seems malformed (n_names != dimensions_[4])"); } // Read offset to color info - colorOffset = ReadInt(s,&pos) + start; + unsigned long colorOffset = ReadInt(s, &pos) + start; // Read offset to name info - nameOffset = ReadInt(s,&pos) + start; + unsigned long nameOffset = ReadInt(s, &pos) + start; - this->channel_colors_.resize( 3 * (colNum+1)); + this->channel_colors_.resize( 3 * (n_cols+1)); // Read the colors for(int j = 0; j < this->dimensions_[4]; ++j) { char colorBuff[5]; - ReadFile(s,&colorOffset,4,colorBuff,1); + ReadFile(s, &colorOffset, 4, colorBuff, 1); for(int i=0;i<3;i++) { - component = CharPointerToUnsignedChar(colorBuff+i); - this->channel_colors_[i + 3*j] = component; + this->channel_colors_[i + 3*j] = static_cast<unsigned char>(colorBuff[i]); } } - ReadFile(s,&nameOffset,sizeOfNames,nameBuff,1); - nameLength = nameSkip = 0; - tempBuff = nameBuff; + std::vector<byte> nameBuff; + nameBuff.resize(sizeOfNames + 1); + std::vector<byte> name; + name.resize(sizeOfNames + 1); + + ReadFile(s, &nameOffset, sizeOfNames, nameBuff.data(), 1); + + this->channel_names_.resize(this->dimensions_[4]); + int nameStart = 0; for(int i = 0; i < this->dimensions_[4]; i++) { - nameSkip = this->FindChannelNameStart(tempBuff,sizeOfNames-nameSkip); - nameLength = this->ReadChannelName(tempBuff+nameSkip,sizeOfNames-nameSkip,name); + nameStart += FindChannelNameStart(nameBuff.data() + nameStart, + sizeOfNames-nameStart); + if (nameStart >= sizeOfNames) { + throw CannotReadError("LSM file malformed"); + } + const int nameLength = ReadChannelName(nameBuff.data()+nameStart, sizeOfNames-nameStart, name.data()); + nameStart += nameLength; - tempBuff += nameSkip + nameLength; - this->SetChannelName(name,i); + this->channel_names_[i] = std::string(reinterpret_cast<const char*>(name.data())); } - delete [] nameBuff; - delete [] name; return 0; } -int LSMReader::ReadTimeStampInformation(byte_source* s, unsigned long offset) -{ +int LSMReader::ReadTimeStampInformation(byte_source* s, unsigned long offset) { // position is 0 for non-timeseries files! if( offset == 0 ) return 0; @@ -551,9 +551,7 @@ * * */ -int LSMReader::ReadLSMSpecificInfo(byte_source* s, unsigned long pos) -{ - unsigned long offset; +int LSMReader::ReadLSMSpecificInfo(byte_source* s, unsigned long pos) { pos += 2 * 4; // skip over the start of the LSMInfo // first 4 byte entry if magic number @@ -645,7 +643,7 @@ // SKip Zeiss Vision KS-3D speific data pos += 4; // Read timestamp information - offset = ReadUnsignedInt(s,&pos); + unsigned long offset = ReadUnsignedInt(s, &pos); this->ReadTimeStampInformation(s,offset); return 1; @@ -765,156 +763,111 @@ } while (subblocksOpen); return 0; } -int LSMReader::AnalyzeTag(byte_source* s, unsigned long startPos) -{ - int value, dataSize; - char tempValue[4],tempValue2[4]; - char *actualValue = NULL; - const unsigned short tag = ReadUnsignedShort(s,&startPos); - const unsigned short type = ReadUnsignedShort(s,&startPos); - const unsigned short length = ReadUnsignedInt(s,&startPos); - ReadFile(s,&startPos,4,tempValue); - - for(int i=0;i<4;i++)tempValue2[i]=tempValue[i]; -#ifdef VTK_WORDS_BIGENDIAN - vtkByteSwap::Swap4LE((unsigned int*)tempValue2); -#endif - value = CharPointerToUnsignedInt(tempValue2); - - // if there is more than 4 bytes in value, - // value is an offset to the actual data - dataSize = TIFF_BYTES(type); - const unsigned long readSize = dataSize*length; - if(readSize > 4 && tag != TIF_CZ_LSMINFO) - { - actualValue = new char[readSize]; - startPos = value; - if(tag == TIF_STRIPOFFSETS ||tag == TIF_STRIPBYTECOUNTS) { - if( !ReadFile(s,&startPos,readSize,actualValue) ) { - throw CannotReadError("Failed to get strip offsets\n"); +int LSMReader::AnalyzeTag(byte_source* s, unsigned long startPos) { + std::vector<byte> valueData; + const unsigned short tag = ReadUnsignedShort(s, &startPos); + const unsigned short type = ReadUnsignedShort(s, &startPos); + const unsigned short length = ReadUnsignedInt(s, &startPos); + + valueData.resize(4); + ReadFile(s, &startPos, 4, valueData.data()); + + const int value = parse_uint32_t(valueData); + + // if there is more than 4 bytes in value, + // value is an offset to the actual data + const int dataSize = TIFF_BYTES(type); + const unsigned long readSize = dataSize*length; + if(readSize > 4 && tag != TIF_CZ_LSMINFO) { + valueData.resize(readSize); + startPos = value; + if(tag == TIF_STRIPOFFSETS ||tag == TIF_STRIPBYTECOUNTS) { + if( !ReadFile(s, &startPos, readSize, valueData.data()) ) { + throw CannotReadError("Failed to get strip offsets\n"); + } } } - } - else - { - actualValue = new char[4]; - for(int o=0;o<4;o++)actualValue[o] = tempValue[o]; - } - switch(tag) - { - case TIF_NEWSUBFILETYPE: - this->NewSubFileType = value; - break; - - case TIF_IMAGEWIDTH: -#ifdef VTK_WORDS_BIGENDIAN - vtkByteSwap::Swap4LE((unsigned int*)actualValue); -#endif - //this->dimensions_[0] = this->CharPointerToUnsignedInt(actualValue); - //this->dimensions_[0] = value; - break; - - case TIF_IMAGELENGTH: -#ifdef VTK_WORDS_BIGENDIAN - vtkByteSwap::Swap4LE((unsigned int*)actualValue); - //this->dimensions_[1] = this->CharPointerToUnsignedInt(actualValue); -#endif - //this->dimensions_[1] = value; - break; - - case TIF_BITSPERSAMPLE: -#ifdef VTK_WORDS_BIGENDIAN - vtkByteSwap::Swap2LE((unsigned short*)actualValue); -#endif - this->bits_per_sample_.resize(length); - unsigned short bits_per_sample_; - for(int i=0;i<length;i++) - { - bits_per_sample_ = CharPointerToUnsignedShort(actualValue + TIFF_BYTES(TIFF_SHORT)*i); - this->bits_per_sample_[i] = bits_per_sample_; - } - break; - - case TIF_COMPRESSION: -#ifdef VTK_WORDS_BIGENDIAN - vtkByteSwap::Swap2LE((unsigned short*)actualValue); -#endif - this->compression_ = CharPointerToUnsignedShort(actualValue); - break; - - case TIF_PHOTOMETRICINTERPRETATION: -#ifdef VTK_WORDS_BIGENDIAN - vtkByteSwap::Swap2LE((unsigned short*)actualValue); -#endif - this->PhotometricInterpretation = CharPointerToUnsignedShort(actualValue); - break; - - case TIF_STRIPOFFSETS: - this->strip_offset_.resize(length); -#ifdef VTK_WORDS_BIGENDIAN - vtkByteSwap::Swap4LERange((unsigned int*)actualValue,length); -#endif - if(length>1) { - for(int i=0;i<length;++i) - { - unsigned int* offsets = (unsigned int*)actualValue; - this->strip_offset_[i] = offsets[i]; + switch(tag) { + case TIF_NEWSUBFILETYPE: + this->NewSubFileType = value; + break; + + case TIF_IMAGEWIDTH: + //this->dimensions_[0] = parse_uint32_t(valueData); + //this->dimensions_[0] = value; + break; + + case TIF_IMAGELENGTH: + //this->dimensions_[1] = parse_uint32_t(valueData); + //this->dimensions_[1] = value; + break; + + case TIF_BITSPERSAMPLE: + if (valueData.size() < TIFF_BYTES(TIFF_SHORT) * length) { + throw CannotReadError("LSM file is malformed (TIF_BITSPERSAMPLE field is too short)"); } - } else { - this->strip_offset_[0] = value; - } - break; + this->bits_per_sample_.resize(length); + for(int i=0;i<length;i++) { + this->bits_per_sample_[i] = parse_uint16_t(valueData.data() + TIFF_BYTES(TIFF_SHORT)*i); + } + break; - case TIF_SAMPLESPERPIXEL: -#ifdef VTK_WORDS_BIGENDIAN - vtkByteSwap::Swap4LE((unsigned int*)actualValue); -#endif - this->sample_per_pixel_ = CharPointerToUnsignedInt(actualValue); - break; + case TIF_COMPRESSION: + this->compression_ = parse_uint16_t(valueData); + break; + + case TIF_PHOTOMETRICINTERPRETATION: + this->PhotometricInterpretation = parse_uint16_t(valueData); + break; + + case TIF_STRIPOFFSETS: + this->strip_offset_.resize(length); + if(length>1) { + if (length * sizeof(uint32_t) > valueData.size()) { + throw CannotReadError("LSM file is malformed (TIF_STRIPOFFSETS field is too short)"); + } + for(int i=0;i<length;++i) { + this->strip_offset_[i] = parse_uint32_t(valueData.data() + sizeof(uint32_t) * i); + } + } else { + this->strip_offset_[0] = value; + } + break; - case TIF_STRIPBYTECOUNTS: -#ifdef VTK_WORDS_BIGENDIAN - vtkByteSwap::Swap4LERange((unsigned int*)actualValue,length); -#endif - this->strip_byte_count_.resize(length); - if (length > 1) { - for(int i=0; i<length; ++i) { - this->strip_byte_count_[i] = CharPointerToUnsignedInt(actualValue + TIFF_BYTES(TIFF_LONG)*i); + case TIF_SAMPLESPERPIXEL: + this->sample_per_pixel_ = parse_uint32_t(valueData); + break; + + case TIF_STRIPBYTECOUNTS: + this->strip_byte_count_.resize(length); + if (length > 1) { + for(int i=0; i<length; ++i) { + if (valueData.size() < TIFF_BYTES(TIFF_LONG) * i + 4) { + throw CannotReadError(); + } + this->strip_byte_count_[i] = parse_uint32_t(valueData.data() + TIFF_BYTES(TIFF_LONG)*i); + } + } else { + this->strip_byte_count_[0] = value; } - } else { - this->strip_byte_count_[0] = value; - } - break; - case TIF_PLANARCONFIGURATION: -#ifdef VTK_WORDS_BIGENDIAN - vtkByteSwap::Swap2LE((unsigned short*)actualValue); -#endif - this->PlanarConfiguration = CharPointerToUnsignedShort(actualValue); - break; - case TIF_PREDICTOR: -#ifdef VTK_WORDS_BIGENDIAN - vtkByteSwap::Swap2LE((unsigned short*)actualValue); -#endif - this->Predictor = CharPointerToUnsignedShort(actualValue); - break; - case TIF_COLORMAP: -#ifdef VTK_WORDS_BIGENDIAN - vtkByteSwap::Swap4LE((unsigned int*)actualValue); -#endif - //this->ColorMapOffset = CharPointerToUnsignedInt(actualValue); - break; - case TIF_CZ_LSMINFO: + break; + case TIF_PLANARCONFIGURATION: + this->PlanarConfiguration = parse_uint16_t(valueData); + break; + case TIF_PREDICTOR: + this->Predictor = parse_uint16_t(valueData); + break; + case TIF_COLORMAP: + //this->ColorMapOffset = parse_uint32_t(valueData); + break; + case TIF_CZ_LSMINFO: - this->LSMSpecificInfoOffset = value; - break; + this->LSMSpecificInfoOffset = value; + break; } - if(actualValue) - { - delete [] actualValue; - } - return 0; + return 0; } @@ -1017,8 +970,8 @@ std::vector<unsigned char> decoded = lzw_decode(buffer, size); unsigned char* outbufp = &decoded[0]; - int width = this->dimensions_[0]; - int lines = size / (width*bytes); + const int width = this->dimensions_[0]; + const int lines = size / (width*bytes); for(int line = 0; line < lines; line++) { if(this->Predictor == 2) { @@ -1136,12 +1089,12 @@ } } -std::auto_ptr<Image> LSMReader::read(ImageFactory* factory, const options_map&) { +std::unique_ptr<Image> LSMReader::read(ImageFactory* factory, const options_map&) { this->readHeader(); const int dataType = this->GetDataTypeForChannel(0); // This could vary by channel! - std::auto_ptr<Image> output = factory->create( + std::unique_ptr<Image> output = factory->create( BYTES_BY_DATA_TYPE(dataType)*8, this->dimensions_[2], this->dimensions_[3], @@ -1178,7 +1131,7 @@ } // namespace -std::auto_ptr<Image> LSMFormat::read(byte_source* s, ImageFactory* factory, const options_map& opts) { +std::unique_ptr<Image> LSMFormat::read(byte_source* s, ImageFactory* factory, const options_map& opts) { LSMReader reader(s); return reader.read(factory, opts); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/imread/lib/_lsm.h new/imread-0.7.4/imread/lib/_lsm.h --- old/imread-0.7.1/imread/lib/_lsm.h 2019-05-09 06:52:45.000000000 +0200 +++ new/imread-0.7.4/imread/lib/_lsm.h 2019-05-12 17:44:29.000000000 +0200 @@ -64,7 +64,7 @@ public: bool can_read() const { return true; } - std::auto_ptr<Image> read(byte_source* src, ImageFactory* factory, const options_map& opts); + std::unique_ptr<Image> read(byte_source* src, ImageFactory* factory, const options_map& opts); }; #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/imread/lib/_png.cpp new/imread-0.7.4/imread/lib/_png.cpp --- old/imread-0.7.1/imread/lib/_png.cpp 2019-05-09 06:52:45.000000000 +0200 +++ new/imread-0.7.4/imread/lib/_png.cpp 2019-05-12 17:44:29.000000000 +0200 @@ -89,7 +89,7 @@ } } -std::auto_ptr<Image> PNGFormat::read(byte_source* src, ImageFactory* factory, const options_map& opts) { +std::unique_ptr<Image> PNGFormat::read(byte_source* src, ImageFactory* factory, const options_map& opts) { png_holder p(png_holder::read_mode); png_set_read_fn(p.png_ptr, src, read_from_source); p.create_info(); @@ -141,7 +141,7 @@ } } - std::auto_ptr<Image> output(factory->create(bit_depth, h, w, d)); + std::unique_ptr<Image> output(factory->create(bit_depth, h, w, d)); std::vector<png_bytep> rowps = allrows<png_byte>(*output); png_read_image(p.png_ptr, &rowps[0]); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/imread/lib/_png.h new/imread-0.7.4/imread/lib/_png.h --- old/imread-0.7.1/imread/lib/_png.h 2019-05-09 06:52:45.000000000 +0200 +++ new/imread-0.7.4/imread/lib/_png.h 2019-05-12 17:44:29.000000000 +0200 @@ -1,4 +1,4 @@ -// Copyright 2012-2014 Luis Pedro Coelho <[email protected]> +// Copyright 2012-2019 Luis Pedro Coelho <[email protected]> // License: MIT (see COPYING.MIT file) #ifndef LPC_PNG_H_INCLUDE_GUARD_WED_FEB__1_16_34_50_WET_2012 @@ -9,7 +9,7 @@ bool can_write() const { return true; } static bool match_format(byte_source* src) { return match_magic(src, "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A", 8); } - std::auto_ptr<Image> read(byte_source* src, ImageFactory* factory, const options_map& opts); + std::unique_ptr<Image> read(byte_source* src, ImageFactory* factory, const options_map& opts); void write(Image* input, byte_sink* output, const options_map& opts); }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/imread/lib/_tiff.cpp new/imread-0.7.4/imread/lib/_tiff.cpp --- old/imread-0.7.1/imread/lib/_tiff.cpp 2019-05-09 06:52:45.000000000 +0200 +++ new/imread-0.7.4/imread/lib/_tiff.cpp 2020-03-22 23:42:05.000000000 +0100 @@ -1,4 +1,4 @@ -// Copyright 2012-2015 Luis Pedro Coelho <[email protected]> +// Copyright 2012-2019 Luis Pedro Coelho <[email protected]> // License: MIT (see COPYING.MIT file) #define NO_IMPORT_ARRAY @@ -8,6 +8,7 @@ #include <sstream> #include <iostream> +#include <utility> #include <cstdio> #include <cstring> @@ -81,7 +82,11 @@ struct tif_holder { tif_holder(TIFF* tif) :tif(tif) - { } + { + if (!tif) { + throw CannotReadError(); + } + } ~tif_holder() { TIFFClose(tif); @@ -215,13 +220,13 @@ } // namespace -std::auto_ptr<image_list> STKFormat::read_multi(byte_source* src, ImageFactory* factory) { +std::unique_ptr<image_list> STKFormat::read_multi(byte_source* src, ImageFactory* factory) { shift_source moved(src); stk_extend ext; tiff_warn_error twe; tif_holder t = read_client(&moved); - std::auto_ptr<image_list> images(new image_list); + std::unique_ptr<image_list> images(new image_list); const uint32 h = tiff_get<uint32>(t, TIFFTAG_IMAGELENGTH); const uint32 w = tiff_get<uint32>(t, TIFFTAG_IMAGEWIDTH); @@ -242,7 +247,7 @@ // Monkey patch strip offsets. This is very hacky, but it seems to work! moved.shift(z * raw_strip_size); - std::auto_ptr<Image> output(factory->create(bits_per_sample, h, w, depth)); + std::unique_ptr<Image> output(factory->create(bits_per_sample, h, w, depth)); uint8_t* start = output->rowp_as<uint8_t>(0); for (int st = 0; st != n_strips; ++st) { const int offset = TIFFReadEncodedStrip(t.tif, st, start, strip_size); @@ -251,15 +256,15 @@ } start += offset; } - images->push_back(output); + images->push_back(std::move(output)); } return images; } -std::auto_ptr<image_list> TIFFFormat::do_read(byte_source* src, ImageFactory* factory, bool is_multi) { +std::unique_ptr<image_list> TIFFFormat::do_read(byte_source* src, ImageFactory* factory, bool is_multi) { tiff_warn_error twe; tif_holder t = read_client(src); - std::auto_ptr<image_list> images(new image_list); + std::unique_ptr<image_list> images(new image_list); do { const uint32 h = tiff_get<uint32>(t, TIFFTAG_IMAGELENGTH); const uint32 w = tiff_get<uint32>(t, TIFFTAG_IMAGEWIDTH); @@ -267,7 +272,7 @@ const uint16 bits_per_sample = tiff_get<uint16>(t, TIFFTAG_BITSPERSAMPLE); const int depth = nr_samples > 1 ? nr_samples : -1; - std::auto_ptr<Image> output = factory->create(bits_per_sample, h, w, depth); + std::unique_ptr<Image> output = factory->create(bits_per_sample, h, w, depth); if (ImageWithMetadata* metaout = dynamic_cast<ImageWithMetadata*>(output.get())) { std::string description = tiff_get<std::string>(t, TIFFTAG_IMAGEDESCRIPTION, ""); metaout->set_meta(description); @@ -277,7 +282,7 @@ throw CannotReadError("imread.imread._tiff: Error reading scanline"); } } - images->push_back(output); + images->push_back(std::move(output)); } while (is_multi && TIFFReadDirectory(t.tif)); return images; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/imread/lib/_tiff.h new/imread-0.7.4/imread/lib/_tiff.h --- old/imread-0.7.1/imread/lib/_tiff.h 2019-05-09 06:52:45.000000000 +0200 +++ new/imread-0.7.4/imread/lib/_tiff.h 2019-05-12 17:44:29.000000000 +0200 @@ -1,4 +1,4 @@ -// Copyright 2012 Luis Pedro Coelho <[email protected]> +// Copyright 2012-2019 Luis Pedro Coelho <[email protected]> // License: MIT (see COPYING.MIT file) #ifndef LPC_TIFF_INCLUDE_GUARD_Wed_Feb__8_19_02_16_WET_2012 @@ -14,20 +14,20 @@ bool can_write_multi() const { return true; } bool can_write_metadata() const { return true; } - std::auto_ptr<Image> read(byte_source* s, ImageFactory* f, const options_map& opts) { - std::auto_ptr<image_list> pages = this->do_read(s, f, false); + std::unique_ptr<Image> read(byte_source* s, ImageFactory* f, const options_map& opts) { + std::unique_ptr<image_list> pages = this->do_read(s, f, false); if (pages->size() != 1) throw ProgrammingError(); std::vector<Image*> ims = pages->release(); - return std::auto_ptr<Image>(ims[0]); + return std::unique_ptr<Image>(ims[0]); } - std::auto_ptr<image_list> read_multi(byte_source* s, ImageFactory* f, const options_map& opts) { + std::unique_ptr<image_list> read_multi(byte_source* s, ImageFactory* f, const options_map& opts) { return this->do_read(s, f, true); } void write(Image* input, byte_sink* output, const options_map& opts); void write_multi(image_list* input, byte_sink* output, const options_map& opts); private: - std::auto_ptr<image_list> do_read(byte_source* s, ImageFactory* f, bool is_multi); + std::unique_ptr<image_list> do_read(byte_source* s, ImageFactory* f, bool is_multi); void do_write(image_list* input, byte_sink* output, const options_map& opts, bool); }; @@ -38,7 +38,7 @@ bool can_read_multi() const { return true; } bool can_write() const { return false; } - std::auto_ptr<image_list> read_multi(byte_source* s, ImageFactory* f); + std::unique_ptr<image_list> read_multi(byte_source* s, ImageFactory* f); }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/imread/lib/_webp.cpp new/imread-0.7.4/imread/lib/_webp.cpp --- old/imread-0.7.1/imread/lib/_webp.cpp 2019-05-09 06:52:45.000000000 +0200 +++ new/imread-0.7.4/imread/lib/_webp.cpp 2019-05-12 17:44:29.000000000 +0200 @@ -1,4 +1,4 @@ -// Copyright 2012-2014 Luis Pedro Coelho <[email protected]> +// Copyright 2012-2019 Luis Pedro Coelho <[email protected]> // License: MIT (see COPYING.MIT file) #include "base.h" @@ -7,14 +7,14 @@ #include <webp/decode.h> -std::auto_ptr<Image> WebPFormat::read(byte_source* src, ImageFactory* factory, const options_map&) { +std::unique_ptr<Image> WebPFormat::read(byte_source* src, ImageFactory* factory, const options_map&) { std::vector<byte> data = full_data(*src); int w, h; int ok = WebPGetInfo(&data[0], data.size(), &w, &h); if (!ok) { throw CannotReadError("imread.imread._webp: File does not validate as WebP"); } - std::auto_ptr<Image> output(factory->create(8, h, w, 4)); + std::unique_ptr<Image> output(factory->create(8, h, w, 4)); const int stride = w*4; const uint8_t* p = WebPDecodeRGBAInto( &data[0], data.size(), diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/imread/lib/_webp.h new/imread-0.7.4/imread/lib/_webp.h --- old/imread-0.7.1/imread/lib/_webp.h 2019-05-09 06:52:45.000000000 +0200 +++ new/imread-0.7.4/imread/lib/_webp.h 2019-05-12 17:44:29.000000000 +0200 @@ -1,4 +1,4 @@ -// Copyright 2012 Luis Pedro Coelho <[email protected]> +// Copyright 2012-2019 Luis Pedro Coelho <[email protected]> // License: MIT (see COPYING.MIT file) #ifndef LPC_WEBP_H_INCLUDE_GUARD_ @@ -8,7 +8,7 @@ bool can_read() const { return true; } bool can_write() const { return false; } - std::auto_ptr<Image> read(byte_source* src, ImageFactory* factory, const options_map&); + std::unique_ptr<Image> read(byte_source* src, ImageFactory* factory, const options_map&); }; #endif // LPC_WEBP_H_INCLUDE_GUARD_ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/imread/lib/base.h new/imread-0.7.4/imread/lib/base.h --- old/imread-0.7.1/imread/lib/base.h 2019-05-09 06:52:45.000000000 +0200 +++ new/imread-0.7.4/imread/lib/base.h 2019-05-12 17:44:29.000000000 +0200 @@ -85,7 +85,7 @@ public: virtual ~Image() { } - virtual std::auto_ptr<Image> clone() const = 0; + virtual std::unique_ptr<Image> clone() const = 0; virtual void* rowp(int r) = 0; @@ -112,7 +112,7 @@ class ImageFactory { public: virtual ~ImageFactory() { } - virtual std::auto_ptr<Image> + virtual std::unique_ptr<Image> create(int nbits, int d0, int d1, int d2, int d3=-1, int d4=-1) = 0; protected: }; @@ -135,7 +135,7 @@ for (unsigned i = 0; i != content.size(); ++i) delete content[i]; } std::vector<Image*>::size_type size() const { return content.size(); } - void push_back(std::auto_ptr<Image> p) { content.push_back(p.release()); } + void push_back(std::unique_ptr<Image>&& p) { content.push_back(p.release()); } Image* at(const unsigned ix) const { return content.at(ix); } /// After release(), all of the pointers will be owned by the caller @@ -233,10 +233,10 @@ virtual bool can_write_multi() const { return false; } virtual bool can_write_metadata() const { return false; } - virtual std::auto_ptr<Image> read(byte_source* src, ImageFactory* factory, const options_map&) { + virtual std::unique_ptr<Image> read(byte_source* src, ImageFactory* factory, const options_map&) { throw NotImplementedError(); } - virtual std::auto_ptr<image_list> read_multi(byte_source* src, ImageFactory* factory, const options_map&) { + virtual std::unique_ptr<image_list> read_multi(byte_source* src, ImageFactory* factory, const options_map&) { throw NotImplementedError(); } virtual void write(Image* input, byte_sink* output, const options_map&) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/imread/lib/errors.h new/imread-0.7.4/imread/lib/errors.h --- old/imread-0.7.1/imread/lib/errors.h 2013-10-04 08:27:30.000000000 +0200 +++ new/imread-0.7.4/imread/lib/errors.h 2020-03-20 15:56:53.000000000 +0100 @@ -1,4 +1,4 @@ -// Copyright 2012 Luis Pedro Coelho <[email protected]> +// Copyright 2012-2020 Luis Pedro Coelho <[email protected]> // License: MIT (see COPYING.MIT file) #ifndef LPC_ERRORS_H_INCLUDE_GUARD_WED_FEB__1_16_34_50_WET_2012 @@ -27,6 +27,7 @@ DECLARE_IMREAD_ERROR_TYPE(CannotReadError, "Read Error"); DECLARE_IMREAD_ERROR_TYPE(CannotWriteError, "Write Error"); +DECLARE_IMREAD_ERROR_TYPE(CannotSeekError, "Could not seek in file"); DECLARE_IMREAD_ERROR_TYPE(NotImplementedError, "Not Implemented"); DECLARE_IMREAD_ERROR_TYPE(ProgrammingError, "Programming Error"); DECLARE_IMREAD_ERROR_TYPE(OptionsError, "Options Error"); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/imread/lib/file.h new/imread-0.7.4/imread/lib/file.h --- old/imread-0.7.1/imread/lib/file.h 2013-07-12 13:29:53.000000000 +0200 +++ new/imread-0.7.4/imread/lib/file.h 2020-03-20 15:52:42.000000000 +0100 @@ -1,4 +1,4 @@ -// Copyright 2012 Luis Pedro Coelho <[email protected]> +// Copyright 2012-2020 Luis Pedro Coelho <[email protected]> // License: MIT (see COPYING.MIT file) #ifndef LPC_FILE_H_INCLUDE_GUARD_WED_FEB__1_16_34_50_WET_2012 #define LPC_FILE_H_INCLUDE_GUARD_WED_FEB__1_16_34_50_WET_2012 @@ -23,9 +23,9 @@ return ::read(fd_, buffer, n); } virtual bool can_seek() const { return true; } - virtual size_t seek_absolute(size_t pos) { return ::lseek(fd_, pos, SEEK_SET); } - virtual size_t seek_relative(int delta) { return ::lseek(fd_, delta, SEEK_CUR); } - virtual size_t seek_end(int delta) { return ::lseek(fd_, delta, SEEK_END); } + virtual size_t seek_absolute(size_t pos) { return _check_seek(fd_, pos, SEEK_SET); } + virtual size_t seek_relative(int delta) { return _check_seek(fd_, delta, SEEK_CUR); } + virtual size_t seek_end(int delta) { return _check_seek(fd_, delta, SEEK_END); } virtual size_t write(const byte* buffer, size_t n) { @@ -33,6 +33,13 @@ } private: int fd_; + static off_t _check_seek(int fd, off_t offset, int whence) { + off_t r = ::lseek(fd, offset, whence); + if (r == static_cast<off_t>(-1)) { + throw CannotSeekError(); + } + return r; + } }; #endif // LPC_FILE_H_INCLUDE_GUARD_WED_FEB__1_16_34_50_WET_2012 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/imread/lib/formats.cpp new/imread-0.7.4/imread/lib/formats.cpp --- old/imread-0.7.1/imread/lib/formats.cpp 2019-05-09 06:52:45.000000000 +0200 +++ new/imread-0.7.4/imread/lib/formats.cpp 2019-05-12 17:44:29.000000000 +0200 @@ -1,4 +1,4 @@ -// Copyright 2012-2014 Luis Pedro Coelho <[email protected]> +// Copyright 2012-2019 Luis Pedro Coelho <[email protected]> // License: MIT (see COPYING.MIT file) #include "formats.h" @@ -14,22 +14,22 @@ #include <cstring> -std::auto_ptr<ImageFormat> get_format(const char* format) { +std::unique_ptr<ImageFormat> get_format(const char* format) { using std::strcmp; - if (!strcmp(format, "png")) return std::auto_ptr<ImageFormat>(new PNGFormat); - if (!strcmp(format, "jpeg") || !strcmp(format, "jpg")) return std::auto_ptr<ImageFormat>(new JPEGFormat); - if (!strcmp(format, "lsm")) return std::auto_ptr<ImageFormat>(new LSMFormat); - if (!strcmp(format, "tiff") || !strcmp(format, "tif")) return std::auto_ptr<ImageFormat>(new TIFFFormat); + if (!strcmp(format, "png")) return std::unique_ptr<ImageFormat>(new PNGFormat); + if (!strcmp(format, "jpeg") || !strcmp(format, "jpg")) return std::unique_ptr<ImageFormat>(new JPEGFormat); + if (!strcmp(format, "lsm")) return std::unique_ptr<ImageFormat>(new LSMFormat); + if (!strcmp(format, "tiff") || !strcmp(format, "tif")) return std::unique_ptr<ImageFormat>(new TIFFFormat); #if IMREAD_EXCLUDE_WEBP - if (!strcmp(format, "webp")) return std::auto_ptr<ImageFormat>(0); + if (!strcmp(format, "webp")) return std::unique_ptr<ImageFormat>(nullptr); #else - if (!strcmp(format, "webp")) return std::auto_ptr<ImageFormat>(new WebPFormat); + if (!strcmp(format, "webp")) return std::unique_ptr<ImageFormat>(new WebPFormat); #endif - if (!strcmp(format, "stk")) return std::auto_ptr<ImageFormat>(new STKFormat); - if (!strcmp(format, "bmp")) return std::auto_ptr<ImageFormat>(new BMPFormat); - return std::auto_ptr<ImageFormat>(0); + if (!strcmp(format, "stk")) return std::unique_ptr<ImageFormat>(new STKFormat); + if (!strcmp(format, "bmp")) return std::unique_ptr<ImageFormat>(new BMPFormat); + return std::unique_ptr<ImageFormat>(nullptr); } const char* magic_format(byte_source* src) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/imread/lib/formats.h new/imread-0.7.4/imread/lib/formats.h --- old/imread-0.7.1/imread/lib/formats.h 2019-05-09 06:52:45.000000000 +0200 +++ new/imread-0.7.4/imread/lib/formats.h 2019-05-12 17:44:29.000000000 +0200 @@ -1,4 +1,4 @@ -// Copyright 2012-2014 Luis Pedro Coelho <[email protected]> +// Copyright 2012-2019 Luis Pedro Coelho <[email protected]> // License: MIT (see COPYING.MIT file) #ifndef LPC_FORMATS_H_INCLUDE_GUARD_WED_FEB__1_16_34_50_WET_2012 @@ -6,7 +6,7 @@ #include "base.h" #include <memory> -std::auto_ptr<ImageFormat> get_format(const char*); +std::unique_ptr<ImageFormat> get_format(const char*); const char* magic_format(byte_source*); #endif // LPC_FORMATS_H_INCLUDE_GUARD_WED_FEB__1_16_34_50_WET_2012 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/imread/lib/numpy.h new/imread-0.7.4/imread/lib/numpy.h --- old/imread-0.7.1/imread/lib/numpy.h 2019-05-09 06:52:45.000000000 +0200 +++ new/imread-0.7.4/imread/lib/numpy.h 2019-05-12 17:44:29.000000000 +0200 @@ -1,4 +1,4 @@ -// Copyright 2012-2015 Luis Pedro Coelho <[email protected]> +// Copyright 2012-2019 Luis Pedro Coelho <[email protected]> // License: MIT (see COPYING.MIT file) #ifndef LPC_NUMPY_H_INCLUDE_GUARD_WED_FEB__1_16_34_50_WET_2012 @@ -20,9 +20,9 @@ Py_XDECREF(array_); } - std::auto_ptr<Image> clone() const { + std::unique_ptr<Image> clone() const { Py_XINCREF(array_); - return std::auto_ptr<Image>(new NumpyImage(this->array_)); + return std::unique_ptr<Image>(new NumpyImage(this->array_)); } PyArrayObject* release() { @@ -86,7 +86,7 @@ class NumpyFactory : public ImageFactory { protected: - std::auto_ptr<Image> create(int nbits, int d0, int d1, int d2, int d3, int d4) { + std::unique_ptr<Image> create(int nbits, int d0, int d1, int d2, int d3, int d4) { npy_intp dims[5]; dims[0] = d0; dims[1] = d1; @@ -114,7 +114,7 @@ PyArrayObject* array = reinterpret_cast<PyArrayObject*>(PyArray_SimpleNew(nd, dims, dtype)); if (!array) throw std::bad_alloc(); try { - return std::auto_ptr<Image>(new NumpyImage(array)); + return std::unique_ptr<Image>(new NumpyImage(array)); } catch(...) { Py_DECREF(array); throw; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/imread/tests/data/T new/imread-0.7.4/imread/tests/data/T --- old/imread-0.7.1/imread/tests/data/T 1970-01-01 01:00:00.000000000 +0100 +++ new/imread-0.7.4/imread/tests/data/T 2020-03-23 13:13:23.000000000 +0100 @@ -0,0 +1,7 @@ +bad-files/BMP/00r/00r06.bmp +bad-files/BMP/00r/00r03.bmp +bad-files/BMP/00r/00r01.bmp +bad-files/BMP/00r/00r00.bmp +bad-files/BMP/00r/00r02.bmp +bad-files/BMP/00r/00r04.bmp +bad-files/BMP/00r/00r05.bmp Binary files old/imread-0.7.1/imread/tests/data/bad-files/BMP/00r/00r00.bmp and new/imread-0.7.4/imread/tests/data/bad-files/BMP/00r/00r00.bmp differ Binary files old/imread-0.7.1/imread/tests/data/bad-files/BMP/00r/00r01.bmp and new/imread-0.7.4/imread/tests/data/bad-files/BMP/00r/00r01.bmp differ Binary files old/imread-0.7.1/imread/tests/data/bad-files/BMP/00r/00r02.bmp and new/imread-0.7.4/imread/tests/data/bad-files/BMP/00r/00r02.bmp differ Binary files old/imread-0.7.1/imread/tests/data/bad-files/BMP/00r/00r03.bmp and new/imread-0.7.4/imread/tests/data/bad-files/BMP/00r/00r03.bmp differ Binary files old/imread-0.7.1/imread/tests/data/bad-files/BMP/00r/00r04.bmp and new/imread-0.7.4/imread/tests/data/bad-files/BMP/00r/00r04.bmp differ Binary files old/imread-0.7.1/imread/tests/data/bad-files/BMP/00r/00r05.bmp and new/imread-0.7.4/imread/tests/data/bad-files/BMP/00r/00r05.bmp differ Binary files old/imread-0.7.1/imread/tests/data/bad-files/BMP/00r/00r06.bmp and new/imread-0.7.4/imread/tests/data/bad-files/BMP/00r/00r06.bmp differ Binary files old/imread-0.7.1/imread/tests/data/bad-files/LSM/00r/00r00.lsm and new/imread-0.7.4/imread/tests/data/bad-files/LSM/00r/00r00.lsm differ Binary files old/imread-0.7.1/imread/tests/data/bad-files/LSM/00r/00r01.lsm and new/imread-0.7.4/imread/tests/data/bad-files/LSM/00r/00r01.lsm differ Binary files old/imread-0.7.1/imread/tests/data/bad-files/LSM/00r/00r02.lsm and new/imread-0.7.4/imread/tests/data/bad-files/LSM/00r/00r02.lsm differ Binary files old/imread-0.7.1/imread/tests/data/bad-files/LSM/00r/00r03.lsm and new/imread-0.7.4/imread/tests/data/bad-files/LSM/00r/00r03.lsm differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/imread/tests/data/bad-files/LSM/00r/notes new/imread-0.7.4/imread/tests/data/bad-files/LSM/00r/notes --- old/imread-0.7.1/imread/tests/data/bad-files/LSM/00r/notes 1970-01-01 01:00:00.000000000 +0100 +++ new/imread-0.7.4/imread/tests/data/bad-files/LSM/00r/notes 2020-03-22 23:42:05.000000000 +0100 @@ -0,0 +1 @@ +AnalyzeTag doesn't check the value of `length` fits within the read buffer Binary files old/imread-0.7.1/imread/tests/data/bad-files/LSM/01r/01r00.lsm and new/imread-0.7.4/imread/tests/data/bad-files/LSM/01r/01r00.lsm differ Binary files old/imread-0.7.1/imread/tests/data/bad-files/LSM/01r/01r01.lsm and new/imread-0.7.4/imread/tests/data/bad-files/LSM/01r/01r01.lsm differ Binary files old/imread-0.7.1/imread/tests/data/bad-files/LSM/01r/01r02.lsm and new/imread-0.7.4/imread/tests/data/bad-files/LSM/01r/01r02.lsm differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/imread/tests/data/bad-files/LSM/01r/notes new/imread-0.7.4/imread/tests/data/bad-files/LSM/01r/notes --- old/imread-0.7.1/imread/tests/data/bad-files/LSM/01r/notes 1970-01-01 01:00:00.000000000 +0100 +++ new/imread-0.7.4/imread/tests/data/bad-files/LSM/01r/notes 2020-03-22 23:42:05.000000000 +0100 @@ -0,0 +1 @@ +ReadImageDirectory doesn't check there is sufficient space for numberOfTags in the read buffer Binary files old/imread-0.7.1/imread/tests/data/bad-files/LSM/02r/02r00.lsm and new/imread-0.7.4/imread/tests/data/bad-files/LSM/02r/02r00.lsm differ Binary files old/imread-0.7.1/imread/tests/data/bad-files/LSM/02r/02r01.lsm and new/imread-0.7.4/imread/tests/data/bad-files/LSM/02r/02r01.lsm differ Binary files old/imread-0.7.1/imread/tests/data/bad-files/LSM/02r/02r02.lsm and new/imread-0.7.4/imread/tests/data/bad-files/LSM/02r/02r02.lsm differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/imread/tests/data/bad-files/LSM/02r/notes new/imread-0.7.4/imread/tests/data/bad-files/LSM/02r/notes --- old/imread-0.7.1/imread/tests/data/bad-files/LSM/02r/notes 1970-01-01 01:00:00.000000000 +0100 +++ new/imread-0.7.4/imread/tests/data/bad-files/LSM/02r/notes 2020-03-22 23:42:05.000000000 +0100 @@ -0,0 +1 @@ +ReadChannelColorsAndNames doesn't check there is enough space for sizeOfNames in the read buffer Binary files old/imread-0.7.1/imread/tests/data/bad-files/LSM/03w/03w00.lsm and new/imread-0.7.4/imread/tests/data/bad-files/LSM/03w/03w00.lsm differ Binary files old/imread-0.7.1/imread/tests/data/bad-files/LSM/03w/03w01.lsm and new/imread-0.7.4/imread/tests/data/bad-files/LSM/03w/03w01.lsm differ Binary files old/imread-0.7.1/imread/tests/data/bad-files/LSM/03w/03w02.lsm and new/imread-0.7.4/imread/tests/data/bad-files/LSM/03w/03w02.lsm differ Binary files old/imread-0.7.1/imread/tests/data/bad-files/LSM/03w/03w03.lsm and new/imread-0.7.4/imread/tests/data/bad-files/LSM/03w/03w03.lsm differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/imread/tests/data/bad-files/LSM/03w/notes new/imread-0.7.4/imread/tests/data/bad-files/LSM/03w/notes --- old/imread-0.7.1/imread/tests/data/bad-files/LSM/03w/notes 1970-01-01 01:00:00.000000000 +0100 +++ new/imread-0.7.4/imread/tests/data/bad-files/LSM/03w/notes 2020-03-22 23:42:05.000000000 +0100 @@ -0,0 +1,3 @@ +ReadChannelColorsAndNames allows the file contents to control the size of the channel_colors_ vector (down to +a size of zero by providing a negative colnum?), which it can then cause to be written past the end of by +altering the value that ends up in dimensions[4]. Binary files old/imread-0.7.1/imread/tests/data/bad-files/TIFF/00r00.tiff and new/imread-0.7.4/imread/tests/data/bad-files/TIFF/00r00.tiff differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/imread/tests/test_bad.py new/imread-0.7.4/imread/tests/test_bad.py --- old/imread-0.7.1/imread/tests/test_bad.py 1970-01-01 01:00:00.000000000 +0100 +++ new/imread-0.7.4/imread/tests/test_bad.py 2020-03-23 13:14:28.000000000 +0100 @@ -0,0 +1,42 @@ +from nose.tools import raises +from imread import imread +from . import file_path + + +BAD_FILES = [ + 'bad-files/LSM/00r/00r01.lsm', + 'bad-files/LSM/00r/00r03.lsm', + 'bad-files/LSM/00r/00r02.lsm', + 'bad-files/LSM/00r/00r00.lsm', + + 'bad-files/LSM/01r/01r00.lsm', + 'bad-files/LSM/01r/01r01.lsm', + 'bad-files/LSM/01r/01r02.lsm', + + 'bad-files/LSM/02r/02r00.lsm', + 'bad-files/LSM/02r/02r01.lsm', + 'bad-files/LSM/02r/02r02.lsm', + + 'bad-files/LSM/03w/03w01.lsm', + 'bad-files/LSM/03w/03w00.lsm', + 'bad-files/LSM/03w/03w02.lsm', + 'bad-files/LSM/03w/03w03.lsm', + + 'bad-files/TIFF/00r00.tiff', + + 'bad-files/BMP/00r/00r00.bmp', + 'bad-files/BMP/00r/00r01.bmp', + 'bad-files/BMP/00r/00r02.bmp', + 'bad-files/BMP/00r/00r03.bmp', + 'bad-files/BMP/00r/00r04.bmp', + 'bad-files/BMP/00r/00r05.bmp', + 'bad-files/BMP/00r/00r06.bmp', + +] +def test_read(): + @raises(RuntimeError) + def read1(fname): + imread(file_path(fname)) + assert False + for fname in BAD_FILES: + read1(fname) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/imread/tests/test_rois.py new/imread-0.7.4/imread/tests/test_rois.py --- old/imread-0.7.1/imread/tests/test_rois.py 2018-09-22 13:44:02.000000000 +0200 +++ new/imread-0.7.4/imread/tests/test_rois.py 2019-05-12 17:47:23.000000000 +0200 @@ -5,7 +5,7 @@ def test_rois_smoke(): - rois = ijrois.read_roi_zip('./imread/tests/data/rois.zip') + rois = ijrois.read_roi_zip(file_path('rois.zip')) assert len(rois) == 4 - r = ijrois.read_roi(open('./imread/tests/data/0186-0099.roi', 'rb')) + r = ijrois.read_roi(open(file_path('0186-0099.roi'), 'rb')) assert any([np.array_equal(ri, r) for ri in rois]) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/imread.egg-info/PKG-INFO new/imread-0.7.4/imread.egg-info/PKG-INFO --- old/imread-0.7.1/imread.egg-info/PKG-INFO 2019-05-09 07:14:42.000000000 +0200 +++ new/imread-0.7.4/imread.egg-info/PKG-INFO 2020-04-13 13:17:06.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: imread -Version: 0.7.1 +Version: 0.7.4 Summary: imread: Image reading library Home-page: http://luispedro.org/software/imread Author: Luis Pedro Coelho @@ -10,8 +10,8 @@ mahotas-imread: Read Image Files ================================ - .. image:: https://api.travis-ci.org/luispedro/imread.png - :target: https://travis-ci.org/luispedro/imread + .. image:: https://api.travis-ci.com/luispedro/imread.png + :target: https://travis-ci.com/luispedro/imread .. image:: https://anaconda.org/conda-forge/imread/badges/license.svg :target: http://opensource.org/licenses/MIT .. image:: https://anaconda.org/conda-forge/imread/badges/installer/conda.svg @@ -140,6 +140,14 @@ History ~~~~~~~ + Version 0.7.3 (2020-04-09) + -------------------------- + - Add missing test data to distribution + + Version 0.7.2 (2020-03-24) + -------------------------- + - Fix several memory access bugs in parsers (reported by Robert Scott) + Version 0.7.1 (2019-05-09) -------------------------- - Fix 16-bit RGB/RGBA TIFF write (patch by Tomi Aarnio) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/imread.egg-info/SOURCES.txt new/imread-0.7.4/imread.egg-info/SOURCES.txt --- old/imread-0.7.1/imread.egg-info/SOURCES.txt 2019-05-09 07:14:42.000000000 +0200 +++ new/imread-0.7.4/imread.egg-info/SOURCES.txt 2020-04-13 13:17:07.000000000 +0200 @@ -43,6 +43,7 @@ imread/lib/numpy.h imread/lib/tools.h imread/tests/__init__.py +imread/tests/test_bad.py imread/tests/test_bmp.py imread/tests/test_error.py imread/tests/test_formats.py @@ -58,6 +59,7 @@ imread/tests/data/0186-0099.roi imread/tests/data/1_webp_a.webp imread/tests/data/GOOD.PNG +imread/tests/data/T imread/tests/data/arange512_16bit.png imread/tests/data/bit1.png imread/tests/data/diag.xcf @@ -75,4 +77,30 @@ imread/tests/data/rgba.png imread/tests/data/rois.zip imread/tests/data/stack.tiff -imread/tests/data/star1.bmp \ No newline at end of file +imread/tests/data/star1.bmp +imread/tests/data/bad-files/BMP/00r/00r00.bmp +imread/tests/data/bad-files/BMP/00r/00r01.bmp +imread/tests/data/bad-files/BMP/00r/00r02.bmp +imread/tests/data/bad-files/BMP/00r/00r03.bmp +imread/tests/data/bad-files/BMP/00r/00r04.bmp +imread/tests/data/bad-files/BMP/00r/00r05.bmp +imread/tests/data/bad-files/BMP/00r/00r06.bmp +imread/tests/data/bad-files/LSM/00r/00r00.lsm +imread/tests/data/bad-files/LSM/00r/00r01.lsm +imread/tests/data/bad-files/LSM/00r/00r02.lsm +imread/tests/data/bad-files/LSM/00r/00r03.lsm +imread/tests/data/bad-files/LSM/00r/notes +imread/tests/data/bad-files/LSM/01r/01r00.lsm +imread/tests/data/bad-files/LSM/01r/01r01.lsm +imread/tests/data/bad-files/LSM/01r/01r02.lsm +imread/tests/data/bad-files/LSM/01r/notes +imread/tests/data/bad-files/LSM/02r/02r00.lsm +imread/tests/data/bad-files/LSM/02r/02r01.lsm +imread/tests/data/bad-files/LSM/02r/02r02.lsm +imread/tests/data/bad-files/LSM/02r/notes +imread/tests/data/bad-files/LSM/03w/03w00.lsm +imread/tests/data/bad-files/LSM/03w/03w01.lsm +imread/tests/data/bad-files/LSM/03w/03w02.lsm +imread/tests/data/bad-files/LSM/03w/03w03.lsm +imread/tests/data/bad-files/LSM/03w/notes +imread/tests/data/bad-files/TIFF/00r00.tiff \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/imread-0.7.1/setup.py new/imread-0.7.4/setup.py --- old/imread-0.7.1/setup.py 2019-05-09 06:59:09.000000000 +0200 +++ new/imread-0.7.4/setup.py 2020-03-31 12:21:51.000000000 +0200 @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- # vim: set ts=4 sts=4 sw=4 expandtab smartindent: -# Copyright (C) 2012-2014, Luis Pedro Coelho <[email protected]> +# Copyright (C) 2012-2020, Luis Pedro Coelho <[email protected]> # License: MIT -from __future__ import division, print_function +from glob import glob import platform import sys @@ -109,7 +109,10 @@ 'imread.tests': 'imread/tests', } package_data = { - 'imread.tests': ['data/*'], + 'imread.tests': ['data/*', + 'data/bad-files/*/*.tiff', + 'data/bad-files/BMP/*/*.bmp', + 'data/bad-files/LSM/*/*.lsm'] } classifiers = [
