diff --git a/ANNOUNCE b/ANNOUNCE index f33cdb12cb28d91777a6cba3787765c639edcca6..9a3192e94133c2a8e491110ff0bbdc55d1fbde1d 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,5 +1,5 @@ -Libpng 1.5.5beta05 - July 29, 2011 +Libpng 1.5.5beta05 - August 17, 2011 This is not intended to be a public release. It will be replaced within a few weeks by a public version or by another test version. @@ -45,7 +45,21 @@ Version 1.5.5beta04 [July 29, 2011] Updated commentary about the png_rgb_to_gray() default coefficients in the manual and in pngrtran.c -Version 1.5.5beta05 [July 29, 2011] +Version 1.5.5beta05 [August 17, 2011] + Prevent unexpected API exports from non-libpng DLLs on Windows. The "_DLL" + is removed from the test of whether a DLL is being built (this erroneously + caused the libpng APIs to be marked as DLL exports in static builds under + Microsoft Visual Studio). Almost all of the libpng building configuration + is moved from pngconf.h to pngpriv.h, but PNG_DLL_EXPORT remains in + pngconf.h, though, so that it is colocated with the import definition (it + is no longer used anywhere in the installed headers). The VStudio project + definitions have been cleaned up: "_USRDLL" has been removed from the + static library builds (this was incorrect), and PNG_USE_DLL has been added + to pngvalid to test the functionality (pngtest does not supply it, + deliberately). The spurious "_EXPORTS" has been removed from the + libpng build (all these errors were a result of copy/paste between project + configurations.) + Send comments/corrections/commendations to png-mng-implement at lists.sf.net: (subscription required; visit diff --git a/CHANGES b/CHANGES index a55a850701bbcb6e9bfe83891f51368843666c30..a463383ffa96c1414480379715d94006d5518ffc 100644 --- a/CHANGES +++ b/CHANGES @@ -3529,7 +3529,20 @@ Version 1.5.5beta04 [July 29, 2011] Updated commentary about the png_rgb_to_gray() default coefficients in the manual and in pngrtran.c -Version 1.5.5beta05 [July 29, 2011] +Version 1.5.5beta05 [August 17, 2011] + Prevent unexpected API exports from non-libpng DLLs on Windows. The "_DLL" + is removed from the test of whether a DLL is being built (this erroneously + caused the libpng APIs to be marked as DLL exports in static builds under + Microsoft Visual Studio). Almost all of the libpng building configuration + is moved from pngconf.h to pngpriv.h, but PNG_DLL_EXPORT remains in + pngconf.h, though, so that it is colocated with the import definition (it + is no longer used anywhere in the installed headers). The VStudio project + definitions have been cleaned up: "_USRDLL" has been removed from the + static library builds (this was incorrect), and PNG_USE_DLL has been added + to pngvalid to test the functionality (pngtest does not supply it, + deliberately). The spurious "_EXPORTS" has been removed from the + libpng build (all these errors were a result of copy/paste between project + configurations.) Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/pngconf.h b/pngconf.h index c087df3f907ef6a2ebb15da9543c3afa0b33d6b8..cd183e39a9cfa8d8484eacacc7d2fe438a641115 100644 --- a/pngconf.h +++ b/pngconf.h @@ -1,7 +1,7 @@ /* pngconf.h - machine configurable file for libpng * - * libpng version 1.5.5beta05 - July 29, 2011 + * libpng version 1.5.5beta05 - August 17, 2011 * * Copyright (c) 1998-2011 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -164,7 +164,9 @@ * 'type', compiler specific. * * PNG_DLL_EXPORT Set to the magic to use during a libpng build to - * make a symbol exported from the DLL. + * make a symbol exported from the DLL. Not used in the + * public header files; see pngpriv.h for how it is used + * in the libpng build. * * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come * from a DLL - used to define PNG_IMPEXP when @@ -258,25 +260,14 @@ # define PNGAPI PNGCAPI #endif -/* The default for PNG_IMPEXP depends on whether the library is - * being built or used. +/* PNG_IMPEXP may be set on the compilation system command line or (if not set) + * then in an internal header file when building the library, otherwise (when + * using the library) it is set here. */ #ifndef PNG_IMPEXP -# ifdef PNGLIB_BUILD - /* Building the library */ -# if (defined(DLL_EXPORT)/*from libtool*/ ||\ - defined(_WINDLL) || defined(_DLL) || defined(__DLL__) ||\ - defined(_USRDLL) ||\ - defined(PNG_BUILD_DLL)) && defined(PNG_DLL_EXPORT) - /* Building a DLL. */ -# define PNG_IMPEXP PNG_DLL_EXPORT -# endif /* DLL */ -# else - /* Using the library */ -# if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT) - /* This forces use of a DLL, disallowing static linking */ -# define PNG_IMPEXP PNG_DLL_IMPORT -# endif +# if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT) + /* This forces use of a DLL, disallowing static linking */ +# define PNG_IMPEXP PNG_DLL_IMPORT # endif # ifndef PNG_IMPEXP @@ -356,25 +347,18 @@ # ifndef PNG_ALLOCATED # define PNG_ALLOCATED __attribute__((__malloc__)) # endif - - /* This specifically protects structure members that should only be - * accessed from within the library, therefore should be empty during - * a library build. - */ -# ifndef PNGLIB_BUILD -# ifndef PNG_DEPRECATED -# define PNG_DEPRECATED __attribute__((__deprecated__)) -# endif -# ifndef PNG_PRIVATE -# if 0 /* Doesn't work so we use deprecated instead*/ -# define PNG_PRIVATE \ - __attribute__((warning("This function is not exported by libpng."))) -# else -# define PNG_PRIVATE \ - __attribute__((__deprecated__)) -# endif +# ifndef PNG_DEPRECATED +# define PNG_DEPRECATED __attribute__((__deprecated__)) +# endif +# ifndef PNG_PRIVATE +# if 0 /* Doesn't work so we use deprecated instead*/ +# define PNG_PRIVATE \ + __attribute__((warning("This function is not exported by libpng."))) +# else +# define PNG_PRIVATE \ + __attribute__((__deprecated__)) # endif -# endif /* PNGLIB_BUILD */ +# endif # endif /* __GNUC__ */ # if defined(_MSC_VER) && (_MSC_VER >= 1300) @@ -389,19 +373,12 @@ # define PNG_ALLOCATED __declspec(restrict) # endif # endif - - /* This specifically protects structure members that should only be - * accessed from within the library, therefore should be empty during - * a library build. - */ -# ifndef PNGLIB_BUILD -# ifndef PNG_DEPRECATED -# define PNG_DEPRECATED __declspec(deprecated) -# endif -# ifndef PNG_PRIVATE -# define PNG_PRIVATE __declspec(deprecated) -# endif -# endif /* PNGLIB_BUILD */ +# ifndef PNG_DEPRECATED +# define PNG_DEPRECATED __declspec(deprecated) +# endif +# ifndef PNG_PRIVATE +# define PNG_PRIVATE __declspec(deprecated) +# endif # endif /* _MSC_VER */ #endif /* PNG_PEDANTIC_WARNINGS */ diff --git a/pngpriv.h b/pngpriv.h index 5b4d2127cc9865c574f604c411b40de2cf4f8e74..f38d603b4637c11794039101b0920681d1295b74 100644 --- a/pngpriv.h +++ b/pngpriv.h @@ -44,7 +44,8 @@ */ #include -#define PNGLIB_BUILD +#define PNGLIB_BUILD /*libpng is being built, not used*/ + #ifdef PNG_USER_CONFIG # include "pngusr.h" /* These should have been defined in pngusr.h */ @@ -55,10 +56,80 @@ # define PNG_USER_DLLFNAME_POSTFIX "Cb" # endif #endif + +/* Is this a build of a DLL where compilation of the object modules requires + * different preprocessor settings to those required for a simple library? If + * so PNG_BUILD_DLL must be set. + * + * If libpng is used inside a DLL but that DLL does not export the libpng APIs + * PNG_BUILD_DLL must not be set. To avoid the code below kicking in build a + * static library of libpng then link the DLL against that. + */ +#ifndef PNG_BUILD_DLL +# ifdef DLL_EXPORT + /* This is set by libtool when files are compiled for a DLL; libtool + * always compiles twice, even on systems where it isn't necessary. Set + * PNG_BUILD_DLL in case it is necessary: + */ +# define PNG_BUILD_DLL +# else +# ifdef _WINDLL + /* This is set by the Microsoft Visual Studio IDE in projects that + * build a DLL. It can't easily be removed from those projects (it + * isn't visible in the Visual Studio UI) so it is a fairly reliable + * indication that PNG_IMPEXP needs to be set to the DLL export + * attributes. + */ +# define PNG_BUILD_DLL +# else +# ifdef __DLL__ + /* This is set by the Borland C system when compiling for a DLL + * (as above.) + */ +# define PNG_BUILD_DLL +# else + /* Add additional compiler cases here. */ +# endif +# endif +# endif +#endif /* Setting PNG_BUILD_DLL if required */ + +/* See pngconf.h for more details: the builder of the library may set this on + * the command line to the right thing for the specific compilation system or it + * may be automagically set above (at present we know of no system where it does + * need to be set on the command line.) + * + * PNG_IMPEXP must be set here when building the library to prevent pngconf.h + * setting it to the "import" setting for a DLL build. + */ +#ifndef PNG_IMPEXP +# ifdef PNG_BUILD_DLL +# define PNG_IMPEXP PNG_DLL_EXPORT +# else + /* Not building a DLL, or the DLL doesn't require specific export + * definitions. + */ +# define PNG_IMPEXP +# endif +#endif + +/* No warnings for private or deprecated functions in the build: */ +#ifndef PNG_DEPRECATED +# define PNG_DEPRECATED +#endif +#ifndef PNG_PRIVATE +# define PNG_PRIVATE +#endif + #include "png.h" #include "pnginfo.h" #include "pngstruct.h" +/* pngconf.h does not set PNG_DLL_EXPORT unless it is required, so: */ +#ifndef PNG_DLL_EXPORT +# define PNG_DLL_EXPORT +#endif + /* This is used for 16 bit gamma tables - only the top level pointers are const, * this could be changed: */ @@ -1078,6 +1149,7 @@ PNG_EXTERN void png_64bit_product PNGARG((long v1, long v2, unsigned long *hi_product, unsigned long *lo_product)); #endif +#ifdef PNG_cHRM_SUPPORTED /* Added at libpng version 1.4.0 */ PNG_EXTERN void png_check_IHDR PNGARG((png_structp png_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, diff --git a/projects/vstudio/libpng/libpng.vcxproj b/projects/vstudio/libpng/libpng.vcxproj index 69779007cfdb4c3c687f63d903666c6f61686d25..c4bf04184ee0798ef4d35d08d72b25233f9bc09b 100644 --- a/projects/vstudio/libpng/libpng.vcxproj +++ b/projects/vstudio/libpng/libpng.vcxproj @@ -118,7 +118,7 @@ ProgramDatabase Disabled EnableFastChecks - WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) true true false @@ -175,7 +175,7 @@ MultiThreaded true true - WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) false false pngpriv.h diff --git a/projects/vstudio/pngvalid/pngvalid.vcxproj b/projects/vstudio/pngvalid/pngvalid.vcxproj index 79fd1bd82bf7d615a1700d43eb45965f1fb7bd28..bd85806aba294c823ba6693a8796d38cf5728960 100644 --- a/projects/vstudio/pngvalid/pngvalid.vcxproj +++ b/projects/vstudio/pngvalid/pngvalid.vcxproj @@ -81,7 +81,7 @@ ProgramDatabase Disabled EnableFastChecks - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;PNG_USE_DLL;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) 4996;4127 false @@ -146,7 +146,7 @@ Full false true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CONSOLE;PNG_USE_DLL;%(PreprocessorDefinitions) $(ZLibSrcDir);..\..\..\scripts;%(AdditionalIncludeDirectories) 4996;4127 false diff --git a/projects/vstudio/readme.txt b/projects/vstudio/readme.txt index 2231f4a42e016367962869075f70bc31437c3070..2b4766f30e0a0558d314cae5f8f66aa58cfcacf3 100644 --- a/projects/vstudio/readme.txt +++ b/projects/vstudio/readme.txt @@ -1,7 +1,7 @@ VisualStudio instructions -libpng version 1.5.5beta05 - July 29, 2011 +libpng version 1.5.5beta05 - August 17, 2011 Copyright (c) 1998-2010 Glenn Randers-Pehrson diff --git a/projects/vstudio/zlib.props b/projects/vstudio/zlib.props index 524b4ddf88d26468f841612e1641c2afbe1ce47c..636b3606988f816c6dd3f4114eabfc34f86b8549 100644 --- a/projects/vstudio/zlib.props +++ b/projects/vstudio/zlib.props @@ -2,7 +2,7 @@