changeset 9986:6d1d19e80aa0 icedtea-2.6.23 icedtea-2.6.24pre00

Merge jdk7u271-ga
author Andrew John Hughes <gnu.andrew@redhat.com>
date Thu, 03 Sep 2020 04:06:33 +0100
parents 4716c10ff55a (current diff) 6bb641de4b96 (diff)
children 8209d0df901c
files .hgtags THIRD_PARTY_README make/sun/cmm/lcms/Makefile make/sun/splashscreen/FILES_c.gmk make/sun/splashscreen/Makefile src/share/classes/javax/swing/plaf/basic/BasicRadioButtonUI.java src/share/classes/sun/font/TrueTypeFont.java src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java src/share/classes/sun/security/provider/certpath/OCSPResponse.java src/share/classes/sun/security/util/HostnameChecker.java src/share/classes/sun/security/util/ObjectIdentifier.java src/share/native/sun/awt/splashscreen/splashscreen_gif.c src/solaris/native/sun/awt/gtk2_interface.c src/solaris/native/sun/awt/swing_GTKEngine.c
diffstat 102 files changed, 3253 insertions(+), 1692 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Sat Apr 18 19:25:55 2020 +0100
+++ b/.hgtags	Thu Sep 03 04:06:33 2020 +0100
@@ -719,3 +719,7 @@
 53f1c67ed4171b08c0971912ab6d58c1752fc6c6 icedtea-2.6.22
 53f1c67ed4171b08c0971912ab6d58c1752fc6c6 icedtea-2.6.23pre00
 5cfb0b2d8b780765468b711932b55db1f4e8fef3 icedtea-2.6.22pre00
+ab6cd5af67f09df020e23680b94cfb9a3f0d890f jdk7u261-ga
+ab6cd5af67f09df020e23680b94cfb9a3f0d890f jdk7u271-b00
+5b06aa7a2fcc0e17cafbcce2456978da85677c56 jdk7u271-b01
+5b06aa7a2fcc0e17cafbcce2456978da85677c56 jdk7u271-ga
--- a/THIRD_PARTY_README	Sat Apr 18 19:25:55 2020 +0100
+++ b/THIRD_PARTY_README	Thu Sep 03 04:06:33 2020 +0100
@@ -1001,67 +1001,97 @@
 
 -------------------------------------------------------------------------------
 
-%% This notice is provided with respect to libpng 1.6.16, which is 
+%% This notice is provided with respect to libpng 1.6.37, which may be
 included with JRE 7, JDK 7, and OpenJDK 7.
 
 --- begin of LICENSE ---
 
-This copy of the libpng notices is provided for your convenience.  In case of
-any discrepancy between this copy and the notices in the file png.h that is
-included in the libpng distribution, the latter shall prevail.
-
-COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
-
-If you modify libpng you may insert additional notices immediately following
-this sentence.
-
-This code is released under the libpng license.
-
-libpng versions 1.2.6, August 15, 2004, through 1.6.16, December 22, 2014, are
-Copyright (c) 2004, 2006-2011 Glenn Randers-Pehrson, and are
+COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
+=========================================
+
+PNG Reference Library License version 2
+---------------------------------------
+
+ * Copyright (c) 1995-2019 The PNG Reference Library Authors.
+ * Copyright (c) 2018-2019 Cosmin Truta.
+ * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
+ * Copyright (c) 1996-1997 Andreas Dilger.
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
+
+The software is supplied "as is", without warranty of any kind,
+express or implied, including, without limitation, the warranties
+of merchantability, fitness for a particular purpose, title, and
+non-infringement.  In no event shall the Copyright owners, or
+anyone distributing the software, be liable for any damages or
+other liability, whether in contract, tort or otherwise, arising
+from, out of, or in connection with the software, or the use or
+other dealings in the software, even if advised of the possibility
+of such damage.
+
+Permission is hereby granted to use, copy, modify, and distribute
+this software, or portions hereof, for any purpose, without fee,
+subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you
+    must not claim that you wrote the original software.  If you
+    use this software in a product, an acknowledgment in the product
+    documentation would be appreciated, but is not required.
+
+ 2. Altered source versions must be plainly marked as such, and must
+    not be misrepresented as being the original software.
+
+ 3. This Copyright notice may not be removed or altered from any
+    source or altered source distribution.
+
+
+PNG Reference Library License version 1 (for libpng 0.5 through 1.6.35)
+-----------------------------------------------------------------------
+
+libpng versions 1.2.6, August 15, 2004, through 1.6.35, July 15, 2018 are
+Copyright (c) 2004, 2006-2018 Glenn Randers-Pehrson, and are
 distributed according to the same disclaimer and license as libpng-1.2.5
 with the following individual added to the list of Contributing Authors
 
-   Cosmin Truta
+    Cosmin Truta
 
 libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are
 Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
 distributed according to the same disclaimer and license as libpng-1.0.6
 with the following individuals added to the list of Contributing Authors
 
-   Simon-Pierre Cadieux
-   Eric S. Raymond
-   Gilles Vollant
+    Simon-Pierre Cadieux
+    Eric S. Raymond
+    Gilles Vollant
 
 and with the following additions to the disclaimer:
 
-   There is no warranty against interference with your enjoyment of the
-   library or against infringement.  There is no warranty that our
-   efforts or the library will fulfill any of your particular purposes
-   or needs.  This library is provided with all faults, and the entire
-   risk of satisfactory quality, performance, accuracy, and effort is with
-   the user.
+    There is no warranty against interference with your enjoyment of
+    the library or against infringement.  There is no warranty that our
+    efforts or the library will fulfill any of your particular purposes
+    or needs.  This library is provided with all faults, and the entire
+    risk of satisfactory quality, performance, accuracy, and effort is
+    with the user.
 
 libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
 Copyright (c) 1998, 1999 Glenn Randers-Pehrson, and are
 distributed according to the same disclaimer and license as libpng-0.96,
 with the following individuals added to the list of Contributing Authors:
 
-   Tom Lane
-   Glenn Randers-Pehrson
-   Willem van Schaik
+    Tom Lane
+    Glenn Randers-Pehrson
+    Willem van Schaik
 
 libpng versions 0.89, June 1996, through 0.96, May 1997, are
 Copyright (c) 1996, 1997 Andreas Dilger
 Distributed according to the same disclaimer and license as libpng-0.88,
 with the following individuals added to the list of Contributing Authors:
 
-   John Bowler
-   Kevin Bracey
-   Sam Bushell
-   Magnus Holmgren
-   Greg Roelofs
-   Tom Tanner
+    John Bowler
+    Kevin Bracey
+    Sam Bushell
+    Magnus Holmgren
+    Greg Roelofs
+    Tom Tanner
 
 libpng versions 0.5, May 1995, through 0.88, January 1996, are
 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
@@ -1069,19 +1099,20 @@
 For the purposes of this copyright and license, "Contributing Authors"
 is defined as the following set of individuals:
 
-   Andreas Dilger
-   Dave Martindale
-   Guy Eric Schalnat
-   Paul Schmidt
-   Tim Wegner
-
-The PNG Reference Library is supplied "AS IS".  The Contributing Authors
-and Group 42, Inc. disclaim all warranties, expressed or implied,
-including, without limitation, the warranties of merchantability and of
-fitness for any purpose.  The Contributing Authors and Group 42, Inc.
-assume no liability for direct, indirect, incidental, special, exemplary,
-or consequential damages, which may result from the use of the PNG
-Reference Library, even if advised of the possibility of such damage.
+    Andreas Dilger
+    Dave Martindale
+    Guy Eric Schalnat
+    Paul Schmidt
+    Tim Wegner
+
+The PNG Reference Library is supplied "AS IS".  The Contributing
+Authors and Group 42, Inc. disclaim all warranties, expressed or
+implied, including, without limitation, the warranties of
+merchantability and of fitness for any purpose.  The Contributing
+Authors and Group 42, Inc. assume no liability for direct, indirect,
+incidental, special, exemplary, or consequential damages, which may
+result from the use of the PNG Reference Library, even if advised of
+the possibility of such damage.
 
 Permission is hereby granted to use, copy, modify, and distribute this
 source code, or portions hereof, for any purpose, without fee, subject
@@ -1121,7 +1152,7 @@
 
 -------------------------------------------------------------------------------
 
-%% This notice is provided with respect to libungif 4.1.3, which is 
+%% This notice is provided with respect to GIFLIB 5.2.1 & libungif 4.1.3, which is 
 included with JRE 7, JDK 7, and OpenJDK 7.
 
 --- begin of LICENSE ---
--- a/make/sun/cmm/lcms/Makefile	Sat Apr 18 19:25:55 2020 +0100
+++ b/make/sun/cmm/lcms/Makefile	Thu Sep 03 04:06:33 2020 +0100
@@ -111,3 +111,12 @@
   CPPFLAGS += $(LCMS_CFLAGS)
   OTHER_LDLIBS += $(LCMS_LIBS)
 endif
+
+ifeq ($(CC_VERSION), llvm)
+ ifeq ("$(CC_VER_MAJOR)", "10")
+  ifeq ("$(CC_VER_MINOR)", "1")
+   CFLAGS += $(CFLAGS_$(@F))
+   CFLAGS_cmsopt.o = -O0
+  endif
+ endif
+endif
--- a/make/sun/javazic/tzdata/VERSION	Sat Apr 18 19:25:55 2020 +0100
+++ b/make/sun/javazic/tzdata/VERSION	Thu Sep 03 04:06:33 2020 +0100
@@ -21,4 +21,4 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
-tzdata2019c
+tzdata2020a
--- a/make/sun/javazic/tzdata/africa	Sat Apr 18 19:25:55 2020 +0100
+++ b/make/sun/javazic/tzdata/africa	Thu Sep 03 04:06:33 2020 +0100
@@ -890,19 +890,25 @@
 # Morocco will be on GMT starting from Sunday, May 5th 2019 at 3am.
 # The switch to GMT+1 will occur on Sunday, June 9th 2019 at 2am....
 # http://fr.le360.ma/societe/voici-la-date-du-retour-a-lheure-legale-au-maroc-188222
+
+# From Semlali Naoufal (2020-04-14):
+# Following the announcement by the Moroccan government, the switch to
+# GMT time will take place on Sunday, April 19, 2020 from 3 a.m. and
+# the return to GMT+1 time will take place on Sunday, May 31, 2020 at 2 a.m....
+# https://maroc-diplomatique.net/maroc-le-retour-a-lheure-gmt-est-prevu-dimanche-prochain/
+# http://aujourdhui.ma/actualite/gmt1-retour-a-lheure-normale-dimanche-prochain-1
 #
-# From Paul Eggert (2019-05-20):
-# This agrees with our 2018-11-01 guess that the Moroccan government
-# would continue the practice of falling back at 03:00 the last Sunday
-# before Ramadan, and of springing forward at 02:00 the first Sunday after
-# Ramadan, as this has been the practice since 2012.  To implement this,
-# transition dates for 2019 through 2087 were determined by running the
-# following program under GNU Emacs 26.2.
-# (let ((islamic-year 1440))
+# From Paul Eggert (2020-04-14):
+# For now, guess that in the future Morocco will fall back at 03:00
+# the last Sunday before Ramadan, and spring forward at 02:00 the
+# first Sunday after the day after Ramadan.  To implement this,
+# transition dates for 2021 through 2087 were determined by running
+# the following program under GNU Emacs 26.3.
+# (let ((islamic-year 1442))
 #   (require 'cal-islam)
 #   (while (< islamic-year 1511)
 #     (let ((a (calendar-islamic-to-absolute (list 9 1 islamic-year)))
-#           (b (calendar-islamic-to-absolute (list 10 1 islamic-year)))
+#           (b (1+ (calendar-islamic-to-absolute (list 10 1 islamic-year))))
 #           (sunday 0))
 #       (while (/= sunday (mod (setq a (1- a)) 7)))
 #       (while (/= sunday (mod b 7))
@@ -962,7 +968,7 @@
 Rule	Morocco	2019	only	-	May	 5	 3:00	0	-
 Rule	Morocco	2019	only	-	Jun	 9	 2:00	1:00	-
 Rule	Morocco	2020	only	-	Apr	19	 3:00	0	-
-Rule	Morocco	2020	only	-	May	24	 2:00	1:00	-
+Rule	Morocco	2020	only	-	May	31	 2:00	1:00	-
 Rule	Morocco	2021	only	-	Apr	11	 3:00	0	-
 Rule	Morocco	2021	only	-	May	16	 2:00	1:00	-
 Rule	Morocco	2022	only	-	Mar	27	 3:00	0	-
@@ -978,7 +984,7 @@
 Rule	Morocco	2027	only	-	Feb	 7	 3:00	0	-
 Rule	Morocco	2027	only	-	Mar	14	 2:00	1:00	-
 Rule	Morocco	2028	only	-	Jan	23	 3:00	0	-
-Rule	Morocco	2028	only	-	Feb	27	 2:00	1:00	-
+Rule	Morocco	2028	only	-	Mar	 5	 2:00	1:00	-
 Rule	Morocco	2029	only	-	Jan	14	 3:00	0	-
 Rule	Morocco	2029	only	-	Feb	18	 2:00	1:00	-
 Rule	Morocco	2029	only	-	Dec	30	 3:00	0	-
@@ -994,7 +1000,7 @@
 Rule	Morocco	2034	only	-	Nov	 5	 3:00	0	-
 Rule	Morocco	2034	only	-	Dec	17	 2:00	1:00	-
 Rule	Morocco	2035	only	-	Oct	28	 3:00	0	-
-Rule	Morocco	2035	only	-	Dec	 2	 2:00	1:00	-
+Rule	Morocco	2035	only	-	Dec	 9	 2:00	1:00	-
 Rule	Morocco	2036	only	-	Oct	19	 3:00	0	-
 Rule	Morocco	2036	only	-	Nov	23	 2:00	1:00	-
 Rule	Morocco	2037	only	-	Oct	 4	 3:00	0	-
@@ -1010,7 +1016,7 @@
 Rule	Morocco	2042	only	-	Aug	10	 3:00	0	-
 Rule	Morocco	2042	only	-	Sep	21	 2:00	1:00	-
 Rule	Morocco	2043	only	-	Aug	 2	 3:00	0	-
-Rule	Morocco	2043	only	-	Sep	 6	 2:00	1:00	-
+Rule	Morocco	2043	only	-	Sep	13	 2:00	1:00	-
 Rule	Morocco	2044	only	-	Jul	24	 3:00	0	-
 Rule	Morocco	2044	only	-	Aug	28	 2:00	1:00	-
 Rule	Morocco	2045	only	-	Jul	 9	 3:00	0	-
@@ -1026,7 +1032,7 @@
 Rule	Morocco	2050	only	-	May	15	 3:00	0	-
 Rule	Morocco	2050	only	-	Jun	26	 2:00	1:00	-
 Rule	Morocco	2051	only	-	May	 7	 3:00	0	-
-Rule	Morocco	2051	only	-	Jun	11	 2:00	1:00	-
+Rule	Morocco	2051	only	-	Jun	18	 2:00	1:00	-
 Rule	Morocco	2052	only	-	Apr	28	 3:00	0	-
 Rule	Morocco	2052	only	-	Jun	 2	 2:00	1:00	-
 Rule	Morocco	2053	only	-	Apr	13	 3:00	0	-
@@ -1042,7 +1048,7 @@
 Rule	Morocco	2058	only	-	Feb	17	 3:00	0	-
 Rule	Morocco	2058	only	-	Mar	31	 2:00	1:00	-
 Rule	Morocco	2059	only	-	Feb	 9	 3:00	0	-
-Rule	Morocco	2059	only	-	Mar	16	 2:00	1:00	-
+Rule	Morocco	2059	only	-	Mar	23	 2:00	1:00	-
 Rule	Morocco	2060	only	-	Feb	 1	 3:00	0	-
 Rule	Morocco	2060	only	-	Mar	 7	 2:00	1:00	-
 Rule	Morocco	2061	only	-	Jan	16	 3:00	0	-
@@ -1052,13 +1058,13 @@
 Rule	Morocco	2062	only	-	Dec	31	 3:00	0	-
 Rule	Morocco	2063	only	-	Feb	 4	 2:00	1:00	-
 Rule	Morocco	2063	only	-	Dec	16	 3:00	0	-
-Rule	Morocco	2064	only	-	Jan	20	 2:00	1:00	-
+Rule	Morocco	2064	only	-	Jan	27	 2:00	1:00	-
 Rule	Morocco	2064	only	-	Dec	 7	 3:00	0	-
 Rule	Morocco	2065	only	-	Jan	11	 2:00	1:00	-
 Rule	Morocco	2065	only	-	Nov	22	 3:00	0	-
 Rule	Morocco	2066	only	-	Jan	 3	 2:00	1:00	-
 Rule	Morocco	2066	only	-	Nov	14	 3:00	0	-
-Rule	Morocco	2066	only	-	Dec	19	 2:00	1:00	-
+Rule	Morocco	2066	only	-	Dec	26	 2:00	1:00	-
 Rule	Morocco	2067	only	-	Nov	 6	 3:00	0	-
 Rule	Morocco	2067	only	-	Dec	11	 2:00	1:00	-
 Rule	Morocco	2068	only	-	Oct	21	 3:00	0	-
@@ -1068,13 +1074,13 @@
 Rule	Morocco	2070	only	-	Oct	 5	 3:00	0	-
 Rule	Morocco	2070	only	-	Nov	 9	 2:00	1:00	-
 Rule	Morocco	2071	only	-	Sep	20	 3:00	0	-
-Rule	Morocco	2071	only	-	Oct	25	 2:00	1:00	-
+Rule	Morocco	2071	only	-	Nov	 1	 2:00	1:00	-
 Rule	Morocco	2072	only	-	Sep	11	 3:00	0	-
 Rule	Morocco	2072	only	-	Oct	16	 2:00	1:00	-
 Rule	Morocco	2073	only	-	Aug	27	 3:00	0	-
 Rule	Morocco	2073	only	-	Oct	 8	 2:00	1:00	-
 Rule	Morocco	2074	only	-	Aug	19	 3:00	0	-
-Rule	Morocco	2074	only	-	Sep	23	 2:00	1:00	-
+Rule	Morocco	2074	only	-	Sep	30	 2:00	1:00	-
 Rule	Morocco	2075	only	-	Aug	11	 3:00	0	-
 Rule	Morocco	2075	only	-	Sep	15	 2:00	1:00	-
 Rule	Morocco	2076	only	-	Jul	26	 3:00	0	-
@@ -1084,7 +1090,7 @@
 Rule	Morocco	2078	only	-	Jul	10	 3:00	0	-
 Rule	Morocco	2078	only	-	Aug	14	 2:00	1:00	-
 Rule	Morocco	2079	only	-	Jun	25	 3:00	0	-
-Rule	Morocco	2079	only	-	Jul	30	 2:00	1:00	-
+Rule	Morocco	2079	only	-	Aug	 6	 2:00	1:00	-
 Rule	Morocco	2080	only	-	Jun	16	 3:00	0	-
 Rule	Morocco	2080	only	-	Jul	21	 2:00	1:00	-
 Rule	Morocco	2081	only	-	Jun	 1	 3:00	0	-
@@ -1100,7 +1106,7 @@
 Rule	Morocco	2086	only	-	Apr	14	 3:00	0	-
 Rule	Morocco	2086	only	-	May	19	 2:00	1:00	-
 Rule	Morocco	2087	only	-	Mar	30	 3:00	0	-
-Rule	Morocco	2087	only	-	May	 4	 2:00	1:00	-
+Rule	Morocco	2087	only	-	May	11	 2:00	1:00	-
 # For dates after the somewhat-arbitrary cutoff of 2087, assume that
 # Morocco will no longer observe DST.  At some point this table will
 # need to be extended, though quite possibly Morocco will change the
@@ -1202,7 +1208,7 @@
 #Rule	Namibia	1994	only	-	Mar	21	0:00	-1:00	WAT
 #Rule	Namibia	1994	2017	-	Sep	Sun>=1	2:00	0	CAT
 #Rule	Namibia	1995	2017	-	Apr	Sun>=1	2:00	-1:00	WAT
-# Rearguard section, for parsers that do not support negative DST.
+# Rearguard section, for parsers lacking negative DST; see ziguard.awk.
 Rule	Namibia	1994	only	-	Mar	21	0:00	0	WAT
 Rule	Namibia	1994	2017	-	Sep	Sun>=1	2:00	1:00	CAT
 Rule	Namibia	1995	2017	-	Apr	Sun>=1	2:00	0	WAT
@@ -1216,7 +1222,7 @@
 			2:00	-	SAST	1990 Mar 21 # independence
 # Vanguard section, for zic and other parsers that support negative DST.
 #			2:00	Namibia	%s
-# Rearguard section, for parsers that do not support negative DST.
+# Rearguard section, for parsers lacking negative DST; see ziguard.awk.
 			2:00	-	CAT	1994 Mar 21  0:00
 # From Paul Eggert (2017-04-07):
 # The official date of the 2017 rule change was 2017-10-24.  See:
--- a/make/sun/javazic/tzdata/asia	Sat Apr 18 19:25:55 2020 +0100
+++ b/make/sun/javazic/tzdata/asia	Thu Sep 03 04:06:33 2020 +0100
@@ -309,6 +309,27 @@
 
 # China
 
+# From Phake Nick (2020-04-15):
+# According to this news report:
+# http://news.sina.com.cn/c/2004-09-01/19524201403.shtml
+# on April 11, 1919, newspaper in Shanghai said clocks in Shanghai will spring
+# forward for an hour starting from midnight of that Saturday. The report did
+# not mention what happened in Shanghai thereafter, but it mentioned that a
+# similar trial in Tianjin which ended at October 1st as citizens are told to
+# recede the clock on September 30 from 12:00pm to 11:00pm. The trial at
+# Tianjin got terminated in 1920.
+#
+# From Paul Eggert (2020-04-15):
+# The Returns of Trade and Trade Reports, page 711, says "Daylight saving was
+# given a trial during the year, and from the 12th April to the 1st October
+# the clocks were all set one hour ahead of sun time.  Though the scheme was
+# generally esteemed a success, it was announced early in 1920 that it would
+# not be repeated."
+#
+# Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
+Rule	Shang	1919	only	-	Apr	12	24:00	1:00	D
+Rule	Shang	1919	only	-	Sep	30	24:00	0	S
+
 # From Paul Eggert (2018-10-02):
 # The following comes from Table 1 of:
 # Li Yu. Research on the daylight saving movement in 1940s Shanghai.
@@ -317,6 +338,89 @@
 # The table lists dates only; I am guessing 00:00 and 24:00 transition times.
 # Also, the table lists the planned end of DST in 1949, but the corresponding
 # zone line cuts this off on May 28, when the Communists took power.
+
+# From Phake Nick (2020-04-15):
+#
+# For the history of time in Shanghai between 1940-1942, the situation is
+# actually slightly more complex than the table [below]....  At the time,
+# there were three different authorities in Shanghai, including Shanghai
+# International Settlement, a settlement established by western countries with
+# its own westernized form of government, Shanghai French Concession, similar
+# to the international settlement but is controlled by French, and then the
+# rest of the city of Shanghai, which have already been controlled by Japanese
+# force through a puppet local government (Wang Jingwei regime).  It was
+# additionally complicated by the circumstances that, according to the 1940s
+# Shanghai summer time essay cited in the database, some
+# departments/businesses/people in the Shanghai city itself during that time
+# period, refused to change their clock and instead only changed their opening
+# hours.
+#
+# For example, as quoted in the article, in 1940, other than the authority
+# itself, power, tram, bus companies, cinema, department stores, and other
+# public service organizations have all decided to follow the summer time and
+# spring forward the clock.  On the other hand, the custom office refused to
+# spring forward the clock because of worry on mechanical wear to the physical
+# clock, postal office refused to spring forward because of disruption to
+# business and log-keeping, although they did changed their office hour to
+# match rest of the city.  So is travel agents, and also weather
+# observatory.  It is said both time standards had their own supporters in the
+# city at the time, those who prefer new time standard would have moved their
+# clock while those who prefer the old time standard would keep their clock
+# unchange, and there were different clocks that use different time standard
+# in the city at the time for people who use different time standard to adjust
+# their clock to their preferred time.
+#
+# a. For the 1940 May 31 spring forward, the essay claim that it was
+# coordinared between the international settlement authority and the French
+# concession authority and have gathered support from Hong Kong and Xiamen,
+# that it would spring forward an hour from May 31 "midnight", and the essay
+# claim "Hong Kong government implemented the spring forward in the same time
+# on the same date as Shanghai".
+#
+# b. For the 1940 fall back, it was said that they initially intended to do
+# so on September 30 00:59 at night, however they postponed it to October 12
+# after discussion with relevant parties. However schools restored to the
+# original schedule ten days earlier.
+#
+# c. For the 1941 spring forward, it is said to start from March 15
+# "following the previous year's method", and in addition to that the essay
+# cited an announcement in 1941 from the Wang regime which said the Special
+# City of Shanghai under Wang regime control will follow the DST rule set by
+# the Settlements, irrespective of the original DST plan announced by the Wang
+# regime for other area under its control(April 1 to September 30). (no idea
+# to situation before that announcement)
+#
+# d. For the 1941 fall back, it was said that the fall back would occurs at
+# the end of September (A newspaper headline cited by the essay, published on
+# October 1, 1941, have the headlines which said "French Concession would
+# rewind to the old clock this morning), but it ultimately didn't happen due
+# to disagreement between the international settlement authority and the
+# French concession authority, and the fall back ultimately occurred on
+# November 1.
+#
+# e. In 1941 December, Japan have officially started war with the United
+# States and the United Kingdom, and in Shanghai they have marched into the
+# international settlement, taken over its control
+#
+# f. For the 1942 spring forward, the essay said that the spring forward
+# started on January 31. It said this time the custom office and postal
+# department will also change their clocks, unlike before.
+#
+# g. The essay itself didn't cover any specific changes thereafter until the
+# end of the war, it quoted a November 1942 command from the government of the
+# Wang regime, which claim the daylight saving time applies year round during
+# the war. However, the essay ambiguously said the period is "February 1 to
+# September 30", which I don't really understand what is the meaning of such
+# period in the context of year round implementation here.. More researches
+# might be needed to show exactly what happened during that period of time.
+
+# From Phake Nick (2020-04-15):
+# According to a Japanese tour bus pamphlet in Nanjing area believed to be
+# from around year 1941: http://www.tt-museum.jp/tairiku_0280_nan1941.html ,
+# the schedule listed was in the format of Japanese time.  Which indicate some
+# use of the Japanese time (instead of syncing by DST) might have occurred in
+# the Yangtze river delta area during that period of time although the scope
+# of such use will need to be investigated to determine.
 #
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Shang	1940	only	-	Jun	 1	 0:00	1:00	D
@@ -595,7 +699,7 @@
 			6:00	-	+06
 
 
-# Hong Kong (Xianggang)
+# Hong Kong
 
 # Milne gives 7:36:41.7; round this.
 
@@ -605,9 +709,7 @@
 # it is not [an] observatory, but the official meteorological agency of HK,
 # and also serves as the official timing agency), there are some missing
 # and incorrect rules. Although the exact switch over time is missing, I
-# think 3:30 is correct. The official DST record for Hong Kong can be
-# obtained from
-# http://www.hko.gov.hk/gts/time/Summertime.htm
+# think 3:30 is correct.
 
 # From Phake Nick (2018-10-27):
 # According to Singaporean newspaper
@@ -718,10 +820,10 @@
 #   Resolution of the Legislative Council passed on 9 May 1979
 #	https://www.legco.gov.hk/yr78-79/english/lc_sitg/hansard/h790509.pdf#page=39
 
-# From Paul Eggert (2019-05-31):
+# From Paul Eggert (2020-04-15):
 # Here are the dates given at
-# https://www.hko.gov.hk/gts/time/Summertime.htm
-# as of 2014-06-19:
+# https://www.hko.gov.hk/en/gts/time/Summertime.htm
+# as of 2020-02-10:
 # Year        Period
 # 1941        15 Jun to 30 Sep
 # 1942        Whole year
@@ -1851,6 +1953,47 @@
 
 # '9:00' and 'JST' is from Guy Harris.
 
+# From Paul Eggert (2020-01-19):
+# Starting in the 7th century, Japan generally followed an ancient Chinese
+# timekeeping system that divided night and day into six hours each,
+# with hour length depending on season.  In 1873 the government
+# started requiring the use of a Western style 24-hour clock.  See:
+# Yulia Frumer, "Making Time: Astronomical Time Measurement in Tokugawa Japan"
+# <https://www.worldcat.org/oclc/1043907065>.  As the tzdb code and
+# data support only 24-hour clocks, its tables model timestamps before
+# 1873 using Western-style local mean time.
+
+# From Hideyuki Suzuki (1998-11-09):
+# 'Tokyo' usually stands for the former location of Tokyo Astronomical
+# Observatory: 139° 44' 40.90" E (9h 18m 58.727s), 35° 39' 16.0" N.
+# This data is from 'Rika Nenpyou (Chronological Scientific Tables) 1996'
+# edited by National Astronomical Observatory of Japan....
+# JST (Japan Standard Time) has been used since 1888-01-01 00:00 (JST).
+# The law is enacted on 1886-07-07.
+
+# From Hideyuki Suzuki (1998-11-16):
+# The ordinance No. 51 (1886) established "standard time" in Japan,
+# which stands for the time on 135° E.
+# In the ordinance No. 167 (1895), "standard time" was renamed to "central
+# standard time".  And the same ordinance also established "western standard
+# time", which stands for the time on 120° E....  But "western standard
+# time" was abolished in the ordinance No. 529 (1937).  In the ordinance No.
+# 167, there is no mention regarding for what place western standard time is
+# standard....
+#
+# I wrote "ordinance" above, but I don't know how to translate.
+# In Japanese it's "chokurei", which means ordinance from emperor.
+
+# From Yu-Cheng Chuang (2013-07-12):
+# ...the Meiji Emperor announced Ordinance No. 167 of Meiji Year 28 "The clause
+# about standard time" ... The adoption began from Jan 1, 1896.
+# https://ja.wikisource.org/wiki/標準時ニ關スル件_(公布時)
+#
+# ...the Showa Emperor announced Ordinance No. 529 of Showa Year 12 ... which
+# means the whole Japan territory, including later occupations, adopt Japan
+# Central Time (UT+9). The adoption began on Oct 1, 1937.
+# https://ja.wikisource.org/wiki/明治二十八年勅令第百六十七號標準時ニ關スル件中改正ノ件
+
 # From Paul Eggert (1995-03-06):
 # Today's _Asahi Evening News_ (page 4) reports that Japan had
 # daylight saving between 1948 and 1951, but "the system was discontinued
@@ -1899,37 +2042,6 @@
 Rule	Japan	1949	only	-	Apr	Sat>=1	24:00	1:00	D
 Rule	Japan	1950	1951	-	May	Sat>=1	24:00	1:00	D
 
-# From Hideyuki Suzuki (1998-11-09):
-# 'Tokyo' usually stands for the former location of Tokyo Astronomical
-# Observatory: 139° 44' 40.90" E (9h 18m 58.727s), 35° 39' 16.0" N.
-# This data is from 'Rika Nenpyou (Chronological Scientific Tables) 1996'
-# edited by National Astronomical Observatory of Japan....
-# JST (Japan Standard Time) has been used since 1888-01-01 00:00 (JST).
-# The law is enacted on 1886-07-07.
-
-# From Hideyuki Suzuki (1998-11-16):
-# The ordinance No. 51 (1886) established "standard time" in Japan,
-# which stands for the time on 135° E.
-# In the ordinance No. 167 (1895), "standard time" was renamed to "central
-# standard time".  And the same ordinance also established "western standard
-# time", which stands for the time on 120° E....  But "western standard
-# time" was abolished in the ordinance No. 529 (1937).  In the ordinance No.
-# 167, there is no mention regarding for what place western standard time is
-# standard....
-#
-# I wrote "ordinance" above, but I don't know how to translate.
-# In Japanese it's "chokurei", which means ordinance from emperor.
-
-# From Yu-Cheng Chuang (2013-07-12):
-# ...the Meiji Emperor announced Ordinance No. 167 of Meiji Year 28 "The clause
-# about standard time" ... The adoption began from Jan 1, 1896.
-# https://ja.wikisource.org/wiki/標準時ニ關スル件_(公布時)
-#
-# ...the Showa Emperor announced Ordinance No. 529 of Showa Year 12 ... which
-# means the whole Japan territory, including later occupations, adopt Japan
-# Central Time (UT+9). The adoption began on Oct 1, 1937.
-# https://ja.wikisource.org/wiki/明治二十八年勅令第百六十七號標準時ニ關スル件中改正ノ件
-
 # Zone	NAME		STDOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Tokyo	9:18:59	-	LMT	1887 Dec 31 15:00u
 			9:00	Japan	J%sT
@@ -3109,22 +3221,9 @@
 # [T]he Palestinian cabinet decision (Mar 8th 2016) published on
 # http://www.palestinecabinet.gov.ps/WebSite/Upload/Decree/GOV_17/16032016134830.pdf
 # states that summer time will end on Oct 29th at 01:00.
-#
-# From Tim Parenti (2016-10-19):
-# Predict fall transitions on October's last Saturday at 01:00 from now on.
-# This is consistent with the 2016 transition as well as our spring
-# predictions.
-#
-# From Paul Eggert (2016-10-19):
-# It's also consistent with predictions in the following URLs today:
-# https://www.timeanddate.com/time/change/gaza-strip/gaza
-# https://www.timeanddate.com/time/change/west-bank/hebron
 
 # From Sharef Mustafa (2018-03-16):
-# Palestine summer time will start on Mar 24th 2018 by advancing the
-# clock by 60 minutes as per Palestinian cabinet decision published on
-# the official website, though the decree did not specify the exact
-# time of the time shift.
+# Palestine summer time will start on Mar 24th 2018 ...
 # http://www.palestinecabinet.gov.ps/Website/AR/NDecrees/ViewFile.ashx?ID=e7a42ab7-ee23-435a-b9c8-a4f7e81f3817
 
 # From Even Scharning (2019-03-23):
@@ -3134,15 +3233,20 @@
 # From Sharif Mustafa (2019-03-26):
 # The Palestinian cabinet announced today that the switch to DST will
 # be on Fri Mar 29th 2019 by advancing the clock by 60 minutes.
-# The decree signing date is Mar 12th but it was not published till today.
-# The decree does not specify the exact time of switch.
 # http://palestinecabinet.gov.ps/Website/AR/NDecrees/ViewFile.ashx?ID=e54e9ea1-50ee-4137-84df-0d6c78da259b
 #
 # From Even Scharning (2019-04-10):
 # Our source in Palestine said it happened Friday 29 at 00:00 local time....
+
+# From Sharef Mustafa (2019-10-18):
+# Palestine summer time will end on midnight Oct 26th 2019 ...
+# http://www.palestinecabinet.gov.ps/website/ar/ViewDetails?ID=43948
 #
 # From Paul Eggert (2019-04-10):
 # For now, guess spring-ahead transitions are March's last Friday at 00:00.
+#
+# From Tim Parenti (2016-10-19):
+# Predict fall transitions on October's last Saturday at 01:00 from now on.
 
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule EgyptAsia	1957	only	-	May	10	0:00	1:00	S
--- a/make/sun/javazic/tzdata/backward	Sat Apr 18 19:25:55 2020 +0100
+++ b/make/sun/javazic/tzdata/backward	Thu Sep 03 04:06:33 2020 +0100
@@ -40,6 +40,7 @@
 Link	America/Argentina/Cordoba	America/Cordoba
 Link	America/Tijuana		America/Ensenada
 Link	America/Indiana/Indianapolis	America/Fort_Wayne
+Link	America/Nuuk		America/Godthab
 Link	America/Indiana/Indianapolis	America/Indianapolis
 Link	America/Argentina/Jujuy	America/Jujuy
 Link	America/Indiana/Knox	America/Knox_IN
--- a/make/sun/javazic/tzdata/europe	Sat Apr 18 19:25:55 2020 +0100
+++ b/make/sun/javazic/tzdata/europe	Thu Sep 03 04:06:33 2020 +0100
@@ -572,12 +572,13 @@
 			 0:00	1:00	IST	1947 Nov  2  2:00s
 			 0:00	-	GMT	1948 Apr 18  2:00s
 			 0:00	GB-Eire	GMT/IST	1968 Oct 27
-# The next line is for when negative SAVE values are used.
+# Vanguard section, for zic and other parsers that support negative DST.
 #			 1:00	Eire	IST/GMT
-# These three lines are for when SAVE values are always nonnegative.
+# Rearguard section, for parsers lacking negative DST; see ziguard.awk.
 			 1:00	-	IST	1971 Oct 31  2:00u
 			 0:00	GB-Eire	GMT/IST	1996
 			 0:00	EU	GMT/IST
+# End of rearguard section.
 
 
 ###############################################################################
@@ -1041,7 +1042,7 @@
 			1:00	Czech	CE%sT	1946 Dec  1  3:00
 # Vanguard section, for zic and other parsers that support negative DST.
 #			1:00	-1:00	GMT	1947 Feb 23  2:00
-# Rearguard section, for parsers that do not support negative DST.
+# Rearguard section, for parsers lacking negative DST; see ziguard.awk.
 			0:00	-	GMT	1947 Feb 23  2:00
 # End of rearguard section.
 			1:00	Czech	CE%sT	1979
@@ -1198,14 +1199,17 @@
 			-3:00	-	-03	1980 Apr  6  2:00
 			-3:00	EU	-03/-02	1996
 			0:00	-	GMT
+#
+# Use the old name Scoresbysund, as the current name Ittoqqortoormiit
+# exceeds tzdb's 14-letter limit and has no common English abbreviation.
 Zone America/Scoresbysund -1:27:52 -	LMT	1916 Jul 28 # Ittoqqortoormiit
 			-2:00	-	-02	1980 Apr  6  2:00
 			-2:00	C-Eur	-02/-01	1981 Mar 29
 			-1:00	EU	-01/+00
-Zone America/Godthab	-3:26:56 -	LMT	1916 Jul 28 # Nuuk
+Zone America/Nuuk	-3:26:56 -	LMT	1916 Jul 28 # Godthåb
 			-3:00	-	-03	1980 Apr  6  2:00
 			-3:00	EU	-03/-02
-Zone America/Thule	-4:35:08 -	LMT	1916 Jul 28 # Pituffik air base
+Zone America/Thule	-4:35:08 -	LMT	1916 Jul 28 # Pituffik
 			-4:00	Thule	A%sT
 
 # Estonia
@@ -1575,7 +1579,7 @@
 #
 # From January 1st, 1908 the whole of Iceland was standardised at 1 hour
 # behind GMT. Previously, local mean solar time was used in different parts
-# of Iceland, the almanak had been based on Reykjavik mean solar time which
+# of Iceland, the almanak had been based on Reykjavík mean solar time which
 # was 1 hour and 28 minutes behind GMT.
 #
 # "first day of winter" referred to [below] means the first day of the 26 weeks
--- a/make/sun/javazic/tzdata/leapseconds	Sat Apr 18 19:25:55 2020 +0100
+++ b/make/sun/javazic/tzdata/leapseconds	Thu Sep 03 04:06:33 2020 +0100
@@ -87,9 +87,15 @@
 Leap	2015	Jun	30	23:59:60	+	S
 Leap	2016	Dec	31	23:59:60	+	S
 
+# UTC timestamp when this leap second list expires.
+# Any additional leap seconds will come after this.
+# This Expires line is commented out for now,
+# so that pre-2020a zic implementations do not reject this file.
+#Expires 2020	Dec	28	00:00:00
+
 # POSIX timestamps for the data in this file:
 #updated 1467936000 (2016-07-08 00:00:00 UTC)
-#expires 1593302400 (2020-06-28 00:00:00 UTC)
+#expires 1609113600 (2020-12-28 00:00:00 UTC)
 
-#	Updated through IERS Bulletin C58
-#	File expires on:  28 June 2020
+#	Updated through IERS Bulletin C59
+#	File expires on:  28 December 2020
--- a/make/sun/javazic/tzdata/northamerica	Sat Apr 18 19:25:55 2020 +0100
+++ b/make/sun/javazic/tzdata/northamerica	Thu Sep 03 04:06:33 2020 +0100
@@ -109,7 +109,7 @@
 # For more about the first ten years of DST in the United States, see
 # Robert Garland, Ten years of daylight saving from the Pittsburgh standpoint
 # (Carnegie Library of Pittsburgh, 1927).
-# http://www.clpgh.org/exhibit/dst.html
+# https://web.archive.org/web/20160517155308/http://www.clpgh.org/exhibit/dst.html
 #
 # Shanks says that DST was called "War Time" in the US in 1918 and 1919.
 # However, DST was imposed by the Standard Time Act of 1918, which
@@ -1493,7 +1493,8 @@
 			-4:00	Canada	A%sT
 
 
-# west Labrador, Nova Scotia, Prince Edward I
+# west Labrador, Nova Scotia, Prince Edward I,
+# Îles-de-la-Madeleine, Listuguj reserve
 
 # From Brian Inglis (2015-07-20):
 # From the historical weather station records available at:
@@ -1512,6 +1513,13 @@
 # in Canada to observe DST in 1971 but not 1970; for now we'll assume
 # this is a typo.
 
+# From Jeffery Nichols (2020-01-09):
+# America/Halifax ... also applies to Îles-de-la-Madeleine and the Listuguj
+# reserve in Quebec. Officially, this came into effect on January 1, 2007
+# (Legal Time Act, CQLR c T-5.1), but the legislative debates surrounding that
+# bill say that it is "accommodating the customs and practices" of those
+# regions, which suggests that they have always been in-line with Halifax.
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Halifax	1916	only	-	Apr	 1	0:00	1:00	D
 Rule	Halifax	1916	only	-	Oct	 1	0:00	0	S
@@ -1605,19 +1613,20 @@
 
 # Quebec
 
-# From Paul Eggert (2015-03-24):
+# From Paul Eggert (2020-01-10):
 # See America/Toronto for most of Quebec, including Montreal.
+# See America/Halifax for the Îles de la Madeleine and the Listuguj reserve.
 #
 # Matthews and Vincent (1998) also write that Quebec east of the -63
 # meridian is supposed to observe AST, but residents as far east as
 # Natashquan use EST/EDT, and residents east of Natashquan use AST.
 # The Quebec department of justice writes in
 # "The situation in Minganie and Basse-Côte-Nord"
-# http://www.justice.gouv.qc.ca/english/publications/generale/temps-minganie-a.htm
+# https://www.justice.gouv.qc.ca/en/department/ministre/functions-and-responsabilities/legal-time-in-quebec/the-situation-in-minganie-and-basse-cote-nord/
 # that the coastal strip from just east of Natashquan to Blanc-Sablon
 # observes Atlantic standard time all year round.
-# https://www.assnat.qc.ca/Media/Process.aspx?MediaId=ANQ.Vigie.Bll.DocumentGenerique_8845en
-# says this common practice was codified into law as of 2007.
+# This common practice was codified into law as of 2007; see Legal Time Act,
+# CQLR c T-5.1 <http://legisquebec.gouv.qc.ca/en/ShowDoc/cs/T-5.1>.
 # For lack of better info, guess this practice began around 1970, contra to
 # Shanks & Pottenger who have this region observing AST/ADT.
 
@@ -1636,6 +1645,15 @@
 # Nipigon (EST) and Rainy River (CST) are the largest that we know of.
 # Far west Ontario is like Winnipeg; far east Quebec is like Halifax.
 
+# From Jeffery Nichols (2020-02-06):
+# According to the [Shanks] atlas, those western Ontario zones are huge,
+# covering most of Ontario northwest of Sault Ste Marie and Timmins.
+# The zones seem to include towns bigger than the ones they're named after,
+# like Dryden in America/Rainy_River and Wawa (and maybe Attawapiskat) in
+# America/Nipigon.  I assume it's too much trouble to change the name of the
+# zone (like when you found out that America/Glace_Bay includes Sydney, Nova
+# Scotia)....
+
 # From Mark Brader (2003-07-26):
 # [According to the Toronto Star] Orillia, Ontario, adopted DST
 # effective Saturday, 1912-06-22, 22:00; the article mentions that
@@ -2442,6 +2460,18 @@
 # obtained in November 2008 should be ignored...
 # I apologize for reporting incorrect information in 2008.
 
+# From Tim Parenti (2020-03-05):
+# The government of Yukon announced [yesterday] the cessation of seasonal time
+# changes.  "After clocks are pushed ahead one hour on March 8, the territory
+# will remain on [UTC-07].  ... [The government] found 93 per cent of
+# respondents wanted to end seasonal time changes and, of that group, 70 per
+# cent wanted 'permanent Pacific Daylight Saving Time.'"
+# https://www.cbc.ca/news/canada/north/yukon-end-daylight-saving-time-1.5486358
+#
+# Although the government press release prefers PDT, we prefer MST for
+# consistency with nearby Dawson Creek, Creston, and Fort Nelson.
+# https://yukon.ca/en/news/yukon-end-seasonal-time-change
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	NT_YK	1918	only	-	Apr	14	2:00	1:00	D
 Rule	NT_YK	1918	only	-	Oct	27	2:00	0	S
@@ -2496,11 +2526,13 @@
 Zone America/Whitehorse	-9:00:12 -	LMT	1900 Aug 20
 			-9:00	NT_YK	Y%sT	1967 May 28  0:00
 			-8:00	NT_YK	P%sT	1980
-			-8:00	Canada	P%sT
+			-8:00	Canada	P%sT	2020 Mar  8  2:00
+			-7:00	-	MST
 Zone America/Dawson	-9:17:40 -	LMT	1900 Aug 20
 			-9:00	NT_YK	Y%sT	1973 Oct 28  0:00
 			-8:00	NT_YK	P%sT	1980
-			-8:00	Canada	P%sT
+			-8:00	Canada	P%sT	2020 Mar  8  2:00
+			-7:00	-	MST
 
 
 ###############################################################################
--- a/make/sun/javazic/tzdata/zone.tab	Sat Apr 18 19:25:55 2020 +0100
+++ b/make/sun/javazic/tzdata/zone.tab	Thu Sep 03 04:06:33 2020 +0100
@@ -154,8 +154,8 @@
 CA	+5946-12014	America/Dawson_Creek	MST - BC (Dawson Cr, Ft St John)
 CA	+5848-12242	America/Fort_Nelson	MST - BC (Ft Nelson)
 CA	+4916-12307	America/Vancouver	Pacific - BC (most areas)
-CA	+6043-13503	America/Whitehorse	Pacific - Yukon (south)
-CA	+6404-13925	America/Dawson	Pacific - Yukon (north)
+CA	+6043-13503	America/Whitehorse	Pacific - Yukon (east)
+CA	+6404-13925	America/Dawson	Pacific - Yukon (west)
 CC	-1210+09655	Indian/Cocos
 CD	-0418+01518	Africa/Kinshasa	Dem. Rep. of Congo (west)
 CD	-1140+02728	Africa/Lubumbashi	Dem. Rep. of Congo (east)
@@ -212,7 +212,7 @@
 GG	+492717-0023210	Europe/Guernsey
 GH	+0533-00013	Africa/Accra
 GI	+3608-00521	Europe/Gibraltar
-GL	+6411-05144	America/Godthab	Greenland (most areas)
+GL	+6411-05144	America/Nuuk	Greenland (most areas)
 GL	+7646-01840	America/Danmarkshavn	National Park (east coast)
 GL	+7029-02158	America/Scoresbysund	Scoresbysund/Ittoqqortoormiit
 GL	+7634-06847	America/Thule	Thule/Pituffik
@@ -358,7 +358,7 @@
 # The obsolescent zone.tab format cannot represent Europe/Simferopol well.
 # Put it in RU section and list as UA.  See "territorial claims" above.
 # Programs should use zone1970.tab instead; see above.
-UA	+4457+03406	Europe/Simferopol	MSK+00 - Crimea
+UA	+4457+03406	Europe/Simferopol	Crimea
 RU	+5836+04939	Europe/Kirov	MSK+00 - Kirov
 RU	+4621+04803	Europe/Astrakhan	MSK+01 - Astrakhan
 RU	+4844+04425	Europe/Volgograd	MSK+01 - Volgograd
@@ -422,8 +422,8 @@
 TW	+2503+12130	Asia/Taipei
 TZ	-0648+03917	Africa/Dar_es_Salaam
 UA	+5026+03031	Europe/Kiev	Ukraine (most areas)
-UA	+4837+02218	Europe/Uzhgorod	Ruthenia
-UA	+4750+03510	Europe/Zaporozhye	Zaporozh'ye/Zaporizhia; Lugansk/Luhansk (east)
+UA	+4837+02218	Europe/Uzhgorod	Transcarpathia
+UA	+4750+03510	Europe/Zaporozhye	Zaporozhye and east Lugansk
 UG	+0019+03225	Africa/Kampala
 UM	+2813-17722	Pacific/Midway	Midway Islands
 UM	+1917+16637	Pacific/Wake	Wake Island
--- a/make/sun/splashscreen/FILES_c.gmk	Sat Apr 18 19:25:55 2020 +0100
+++ b/make/sun/splashscreen/FILES_c.gmk	Thu Sep 03 04:06:33 2020 +0100
@@ -118,5 +118,6 @@
 FILES_c += \
 	dgif_lib.c \
 	gif_err.c \
-	gifalloc.c
+	gifalloc.c \
+	openbsd-reallocarray.c
 endif
--- a/make/sun/splashscreen/Makefile	Sat Apr 18 19:25:55 2020 +0100
+++ b/make/sun/splashscreen/Makefile	Thu Sep 03 04:06:33 2020 +0100
@@ -159,4 +159,4 @@
 
 # Shun the less than portable MMX assembly code in pnggccrd.c,
 # and use alternative implementations in C.
-CPPFLAGS += -DPNG_NO_MMX_CODE
+CPPFLAGS += -DPNG_NO_MMX_CODE -DPNG_ARM_NEON_OPT=0 -DPNG_ARM_NEON_IMPLEMENTATION=0
--- a/src/macosx/classes/apple/security/KeychainStore.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/macosx/classes/apple/security/KeychainStore.java	Thu Sep 03 04:06:33 2020 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -203,6 +203,9 @@
 
             // Get the Algorithm ID next
             DerValue[] value = in.getSequence(2);
+            if (value.length < 1 || value.length > 2) {
+                throw new IOException("Invalid length for AlgorithmIdentifier");
+            }
             AlgorithmId algId = new AlgorithmId(value[0].getOID());
             String algName = algId.getName();
 
--- a/src/macosx/native/com/sun/media/sound/PLATFORM_API_MacOSX_PCM.cpp	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/macosx/native/com/sun/media/sound/PLATFORM_API_MacOSX_PCM.cpp	Thu Sep 03 04:06:33 2020 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -203,10 +203,14 @@
     // (required only if Write() can override the buffer)
     bool Allocate(int requestedBufferSize, int extraBytes) {
         int fullBufferSize = requestedBufferSize + extraBytes;
-        int powerOfTwo = 1;
+        long powerOfTwo = 1;
         while (powerOfTwo < fullBufferSize) {
             powerOfTwo <<= 1;
         }
+        if (powerOfTwo > INT_MAX || fullBufferSize < 0) {
+            ERROR0("RingBuffer::Allocate: REQUESTED MEMORY SIZE IS TOO BIG\n");
+            return false;
+        }
         pBuffer = (Byte*)malloc(powerOfTwo);
         if (pBuffer == NULL) {
             ERROR0("RingBuffer::Allocate: OUT OF MEMORY\n");
--- a/src/share/classes/com/sun/crypto/provider/JceKeyStore.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/com/sun/crypto/provider/JceKeyStore.java	Thu Sep 03 04:06:33 2020 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -912,8 +912,6 @@
      */
     private static class DeserializationChecker implements ObjectInputFilter {
 
-        private static final int MAX_NESTED_DEPTH = 2;
-
         // Full length of keystore, anything inside a SecretKeyEntry should not
         // be bigger. Otherwise, must be illegal.
         private final int fullLength;
@@ -926,15 +924,28 @@
         public ObjectInputFilter.Status
             checkInput(ObjectInputFilter.FilterInfo info) {
 
+            if (info.arrayLength() > fullLength) {
+                return Status.REJECTED;
+            }
             // First run a custom filter
-            long nestedDepth = info.depth();
-            if ((nestedDepth == 1 &&
-                        info.serialClass() != SealedObjectForKeyProtector.class) ||
-                    info.arrayLength() > fullLength ||
-                    (nestedDepth > MAX_NESTED_DEPTH &&
-                        info.serialClass() != null &&
-                        info.serialClass() != Object.class)) {
-                return Status.REJECTED;
+            Class<?> clazz = info.serialClass();
+            switch((int)info.depth()) {
+                case 1:
+                    if (clazz != SealedObjectForKeyProtector.class) {
+                        return Status.REJECTED;
+                    }
+                    break;
+                case 2:
+                    if (clazz != null && clazz != SealedObject.class
+                            && clazz != byte[].class) {
+                        return Status.REJECTED;
+                    }
+                    break;
+                default:
+                    if (clazz != null && clazz != Object.class) {
+                        return Status.REJECTED;
+                    }
+                    break;
             }
 
             // Next run the default filter, if available
--- a/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java	Thu Sep 03 04:06:33 2020 +0100
@@ -885,6 +885,10 @@
         try {
             // Read and decode the image data, fill in theImage
             this.initCodeSize = stream.readUnsignedByte();
+            // GIF allows max 8 bpp, so anything larger is bogus for the roots.
+            if (this.initCodeSize < 1 || this.initCodeSize > 8) {
+                throw new IIOException("Bad code size:" + this.initCodeSize);
+            }
 
             // Read first data block
             this.blockLength = stream.readUnsignedByte();
@@ -983,7 +987,6 @@
             processReadAborted();
             return theImage;
         } catch (IOException e) {
-            e.printStackTrace();
             throw new IIOException("I/O error reading image!", e);
         }
     }
--- a/src/share/classes/com/sun/media/sound/DirectAudioDevice.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/com/sun/media/sound/DirectAudioDevice.java	Thu Sep 03 04:06:33 2020 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1115,7 +1115,7 @@
         public void open(AudioInputStream stream) throws LineUnavailableException, IOException {
 
             // $$fb part of fix for 4679187: Clip.open() throws unexpected Exceptions
-            Toolkit.isFullySpecifiedAudioFormat(format);
+            Toolkit.isFullySpecifiedAudioFormat(stream.getFormat());
 
             synchronized (mixer) {
                 if (Printer.trace) Printer.trace("> DirectClip.open(stream)");
@@ -1129,11 +1129,18 @@
                 if (Printer.debug) Printer.debug("DirectClip: open(AIS): lengthInFrames: " + lengthInFrames);
 
                 int bytesRead = 0;
+                int frameSize = stream.getFormat().getFrameSize();
                 if (lengthInFrames != AudioSystem.NOT_SPECIFIED) {
                     // read the data from the stream into an array in one fell swoop.
-                    int arraysize = lengthInFrames * stream.getFormat().getFrameSize();
-                    streamData = new byte[arraysize];
-
+                    int arraysize = lengthInFrames * frameSize;
+                    if (arraysize < 0) {
+                        throw new IllegalArgumentException("Audio data < 0");
+                    }
+                    try {
+                        streamData = new byte[arraysize];
+                    } catch (OutOfMemoryError e) {
+                        throw new IOException("Audio data is too big");
+                    }
                     int bytesRemaining = arraysize;
                     int thisRead = 0;
                     while (bytesRemaining > 0 && thisRead >= 0) {
@@ -1151,9 +1158,14 @@
                     // we use a slightly modified version of ByteArrayOutputStream
                     // to get direct access to the byte array (we don't want a new array
                     // to be allocated)
-                    int MAX_READ_LIMIT = 16384;
+                    int maxReadLimit = Math.max(16384, frameSize);
                     DirectBAOS dbaos  = new DirectBAOS();
-                    byte tmp[] = new byte[MAX_READ_LIMIT];
+                    byte[] tmp;
+                    try {
+                        tmp = new byte[maxReadLimit];
+                    } catch (OutOfMemoryError e) {
+                        throw new IOException("Audio data is too big");
+                    }
                     int thisRead = 0;
                     while (thisRead >= 0) {
                         thisRead = stream.read(tmp, 0, tmp.length);
@@ -1167,7 +1179,7 @@
                     } // while
                     streamData = dbaos.getInternalBuffer();
                 }
-                lengthInFrames = bytesRead / stream.getFormat().getFrameSize();
+                lengthInFrames = bytesRead / frameSize;
 
                 if (Printer.debug) Printer.debug("Read to end of stream. lengthInFrames: " + lengthInFrames);
 
--- a/src/share/classes/com/sun/media/sound/Toolkit.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/com/sun/media/sound/Toolkit.java	Thu Sep 03 04:06:33 2020 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -154,6 +154,14 @@
     }
 
     static void isFullySpecifiedAudioFormat(AudioFormat format) {
+        // Our code requires a positive frame size, that's probably is not
+        // necessary for non-linear encodings, but for now
+        // IllegalArgumentException is better than ArithmeticException
+        if (format.getFrameSize() <= 0) {
+            throw new IllegalArgumentException("invalid frame size: "
+                                               +((format.getFrameSize() == -1) ?
+                    "NOT_SPECIFIED":String.valueOf(format.getFrameSize())));
+        }
         if (!format.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED)
             && !format.getEncoding().equals(AudioFormat.Encoding.PCM_UNSIGNED)
             && !format.getEncoding().equals(AudioFormat.Encoding.ULAW)
@@ -176,11 +184,6 @@
                                                +((format.getSampleSizeInBits()==-1)?
                                                  "NOT_SPECIFIED":String.valueOf(format.getSampleSizeInBits())));
         }
-        if (format.getFrameSize() <= 0) {
-            throw new IllegalArgumentException("invalid frame size: "
-                                               +((format.getFrameSize()==-1)?
-                                                 "NOT_SPECIFIED":String.valueOf(format.getFrameSize())));
-        }
         if (format.getChannels() <= 0) {
             throw new IllegalArgumentException("invalid number of channels: "
                                                +((format.getChannels()==-1)?
--- a/src/share/classes/java/io/File.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/java/io/File.java	Thu Sep 03 04:06:33 2020 +0100
@@ -183,11 +183,13 @@
      * @return true if the file path is invalid.
      */
     final boolean isInvalid() {
-        if (status == null) {
-            status = (this.path.indexOf('\u0000') < 0) ? PathStatus.CHECKED
-                                                       : PathStatus.INVALID;
+        PathStatus s = status;
+        if (s == null) {
+            s = (this.path.indexOf('\u0000') < 0) ? PathStatus.CHECKED
+                                                  : PathStatus.INVALID;
+            status = s;
         }
-        return status == PathStatus.INVALID;
+        return s == PathStatus.INVALID;
     }
 
     /**
--- a/src/share/classes/java/io/ObjectInputStream.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/java/io/ObjectInputStream.java	Thu Sep 03 04:06:33 2020 +0100
@@ -49,6 +49,7 @@
 import sun.misc.SharedSecrets;
 import sun.reflect.misc.ReflectUtil;
 import sun.util.logging.PlatformLogger;
+import sun.security.action.GetBooleanAction;
 
 /**
  * An ObjectInputStream deserializes primitive data and objects previously
@@ -242,6 +243,23 @@
         /** queue for WeakReferences to audited subclasses */
         static final ReferenceQueue<Class<?>> subclassAuditsQueue =
             new ReferenceQueue<>();
+
+        /**
+         * Property to permit setting a filter after objects
+         * have been read.
+         * See {@link #setObjectInputFilter(ObjectInputFilter)}
+         */
+        static final boolean SET_FILTER_AFTER_READ =
+                privilegedGetProperty("jdk.serialSetFilterAfterRead");
+
+        private static boolean privilegedGetProperty(String theProp) {
+            if (System.getSecurityManager() == null) {
+                return Boolean.getBoolean(theProp);
+            } else {
+                return AccessController.doPrivileged(
+                        new GetBooleanAction(theProp));
+            }
+        }
     }
 
     static {
@@ -1248,6 +1266,10 @@
                 serialFilter != ObjectInputFilter.Config.getSerialFilter()) {
             throw new IllegalStateException("filter can not be set more than once");
         }
+        if (totalObjectRefs > 0 && !Caches.SET_FILTER_AFTER_READ) {
+            throw new IllegalStateException(
+                    "filter can not be set after an object has been read");
+        }
         this.serialFilter = filter;
     }
 
--- a/src/share/classes/java/nio/Buffer.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/java/nio/Buffer.java	Thu Sep 03 04:06:33 2020 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -266,8 +266,8 @@
         if ((newLimit > capacity) || (newLimit < 0))
             throw new IllegalArgumentException();
         limit = newLimit;
-        if (position > limit) position = limit;
-        if (mark > limit) mark = -1;
+        if (position > newLimit) position = newLimit;
+        if (mark > newLimit) mark = -1;
         return this;
     }
 
@@ -488,16 +488,18 @@
      * @return  The current position value, before it is incremented
      */
     final int nextGetIndex() {                          // package-private
-        if (position >= limit)
+        int p = position;
+        if (p >= limit)
             throw new BufferUnderflowException();
-        return position++;
+        position = p + 1;
+        return p;
     }
 
     final int nextGetIndex(int nb) {                    // package-private
-        if (limit - position < nb)
+        int p = position;
+        if (limit - p < nb)
             throw new BufferUnderflowException();
-        int p = position;
-        position += nb;
+        position = p + nb;
         return p;
     }
 
@@ -509,16 +511,18 @@
      * @return  The current position value, before it is incremented
      */
     final int nextPutIndex() {                          // package-private
-        if (position >= limit)
+        int p = position;
+        if (p >= limit)
             throw new BufferOverflowException();
-        return position++;
+        position = p + 1;
+        return p;
     }
 
     final int nextPutIndex(int nb) {                    // package-private
-        if (limit - position < nb)
+        int p = position;
+        if (limit - p < nb)
             throw new BufferOverflowException();
-        int p = position;
-        position += nb;
+        position = p + nb;
         return p;
     }
 
--- a/src/share/classes/java/security/MessageDigest.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/java/security/MessageDigest.java	Thu Sep 03 04:06:33 2020 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -433,6 +433,12 @@
     /**
      * Compares two digests for equality. Does a simple byte compare.
      *
+     * @implNote
+     * All bytes in {@code digesta} are examined to determine equality.
+     * The calculation time depends only on the length of {@code digesta}.
+     * It does not depend on the length of {@code digestb} or the contents
+     * of {@code digesta} and {@code digestb}.
+     *
      * @param digesta one of the digests to compare.
      *
      * @param digestb the other digest to compare.
@@ -444,14 +450,22 @@
         if (digesta == null || digestb == null) {
             return false;
         }
-        if (digesta.length != digestb.length) {
-            return false;
+
+        int lenA = digesta.length;
+        int lenB = digestb.length;
+
+        if (lenB == 0) {
+            return lenA == 0;
         }
 
         int result = 0;
+        result |= lenA - lenB;
+
         // time-constant comparison
-        for (int i = 0; i < digesta.length; i++) {
-            result |= digesta[i] ^ digestb[i];
+        for (int i = 0; i < lenA; i++) {
+            // If i >= lenB, indexB is 0; otherwise, i.
+            int indexB = ((i - lenB) >>> 31) * i;
+            result |= digesta[i] ^ digestb[indexB];
         }
         return result == 0;
     }
--- a/src/share/classes/java/util/ArrayList.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/java/util/ArrayList.java	Thu Sep 03 04:06:33 2020 +0100
@@ -163,11 +163,13 @@
      * @throws NullPointerException if the specified collection is null
      */
     public ArrayList(Collection<? extends E> c) {
-        elementData = c.toArray();
-        size = elementData.length;
-        // c.toArray might (incorrectly) not return Object[] (see 6260652)
-        if (elementData.getClass() != Object[].class)
-            elementData = Arrays.copyOf(elementData, size, Object[].class);
+        Object[] a = c.toArray();
+        size = a.length;
+        if (c.getClass() == ArrayList.class) {
+          elementData = a;
+        } else {
+          elementData = Arrays.copyOf(a, size, Object[].class);
+        }
     }
 
     /**
--- a/src/share/classes/java/util/PriorityQueue.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/java/util/PriorityQueue.java	Thu Sep 03 04:06:33 2020 +0100
@@ -240,8 +240,7 @@
 
     private void initElementsFromCollection(Collection<? extends E> c) {
         Object[] a = c.toArray();
-        // If c.toArray incorrectly doesn't return Object[], copy it.
-        if (a.getClass() != Object[].class)
+        if (c.getClass() != ArrayList.class)
             a = Arrays.copyOf(a, a.length, Object[].class);
         int len = a.length;
         if (len == 1 || this.comparator != null)
--- a/src/share/classes/java/util/Vector.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/java/util/Vector.java	Thu Sep 03 04:06:33 2020 +0100
@@ -168,11 +168,13 @@
      * @since   1.2
      */
     public Vector(Collection<? extends E> c) {
-        elementData = c.toArray();
-        elementCount = elementData.length;
-        // c.toArray might (incorrectly) not return Object[] (see 6260652)
-        if (elementData.getClass() != Object[].class)
-            elementData = Arrays.copyOf(elementData, elementCount, Object[].class);
+        Object[] a = c.toArray();
+        elementCount = a.length;
+        if (c.getClass() == ArrayList.class) {
+            elementData = a;
+        } else {
+            elementData = Arrays.copyOf(a, elementCount, Object[].class);
+        }
     }
 
     /**
--- a/src/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java	Thu Sep 03 04:06:33 2020 +0100
@@ -484,19 +484,25 @@
      * @return {@code true} if this queue changed as a result of the call
      */
     public boolean remove(Object o) {
-        if (o == null) return false;
-        Node<E> pred = null;
-        for (Node<E> p = first(); p != null; p = succ(p)) {
-            E item = p.item;
-            if (item != null &&
-                o.equals(item) &&
-                p.casItem(item, null)) {
-                Node<E> next = succ(p);
-                if (pred != null && next != null)
+        if (o != null) {
+            Node<E> next, pred = null;
+            for (Node<E> p = first(); p != null; pred = p, p = next) {
+                boolean removed = false;
+                E item = p.item;
+                if (item != null) {
+                    if (!o.equals(item)) {
+                        next = succ(p);
+                        continue;
+                    }
+                    removed = p.casItem(item, null);
+                }
+
+                next = succ(p);
+                if (pred != null && next != null) // unlink
                     pred.casNext(p, next);
-                return true;
+                if (removed)
+                    return true;
             }
-            pred = p;
         }
         return false;
     }
--- a/src/share/classes/java/util/concurrent/CopyOnWriteArrayList.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/java/util/concurrent/CopyOnWriteArrayList.java	Thu Sep 03 04:06:33 2020 +0100
@@ -118,9 +118,8 @@
      */
     public CopyOnWriteArrayList(Collection<? extends E> c) {
         Object[] elements = c.toArray();
-        // c.toArray might (incorrectly) not return Object[] (see 6260652)
-        if (elements.getClass() != Object[].class)
-            elements = Arrays.copyOf(elements, elements.length, Object[].class);
+        if (c.getClass() != java.util.ArrayList.class)
+          elements = Arrays.copyOf(elements, elements.length, Object[].class);
         setArray(elements);
     }
 
@@ -721,6 +720,9 @@
      */
     public int addAllAbsent(Collection<? extends E> c) {
         Object[] cs = c.toArray();
+        if (c.getClass() != ArrayList.class) {
+            cs = cs.clone();
+        }
         if (cs.length == 0)
             return 0;
         Object[] uniq = new Object[cs.length];
--- a/src/share/classes/java/util/concurrent/PriorityBlockingQueue.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/java/util/concurrent/PriorityBlockingQueue.java	Thu Sep 03 04:06:33 2020 +0100
@@ -253,8 +253,7 @@
         }
         Object[] a = c.toArray();
         int n = a.length;
-        // If c.toArray incorrectly doesn't return Object[], copy it.
-        if (a.getClass() != Object[].class)
+        if (c.getClass() != java.util.ArrayList.class)
             a = Arrays.copyOf(a, n, Object[].class);
         if (screen && (n == 1 || this.comparator != null)) {
             for (int i = 0; i < n; ++i)
--- a/src/share/classes/javax/swing/plaf/basic/BasicRadioButtonUI.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/javax/swing/plaf/basic/BasicRadioButtonUI.java	Thu Sep 03 04:06:33 2020 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -531,8 +531,13 @@
                 }
                 if (newSelectedBtn != null &&
                     (newSelectedBtn != activeBtn)) {
+                    ButtonModel btnModel = newSelectedBtn.getModel();
+                    btnModel.setPressed(true);
+                    btnModel.setArmed(true);
                     newSelectedBtn.requestFocusInWindow();
                     newSelectedBtn.setSelected(true);
+                    btnModel.setPressed(false);
+                    btnModel.setArmed(false);
                 }
             }
         }
--- a/src/share/classes/sun/font/TrueTypeFont.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/sun/font/TrueTypeFont.java	Thu Sep 03 04:06:33 2020 +0100
@@ -541,8 +541,8 @@
                 tableDirectory[i] = table = new DirectoryEntry();
                 table.tag   =  ibuffer.get();
                 /* checksum */ ibuffer.get();
-                table.offset = ibuffer.get();
-                table.length = ibuffer.get();
+                table.offset = ibuffer.get() & 0x7FFFFFFF;
+                table.length = ibuffer.get() & 0x7FFFFFFF;
                 if (table.offset + table.length > fileSize) {
                     throw new FontFormatException("bad table, tag="+table.tag);
                 }
--- a/src/share/classes/sun/net/idn/Punycode.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/sun/net/idn/Punycode.java	Thu Sep 03 04:06:33 2020 +0100
@@ -185,7 +185,7 @@
         for(j=0; j<srcLength; ++j) {
             if(srcCPCount==MAX_CP_COUNT) {
                 /* too many input code points */
-                throw new IndexOutOfBoundsException();
+                throw new ParseException("Too many input code points", -1);
             }
             c=src.charAt(j);
             if(isBasic(c)) {
--- a/src/share/classes/sun/security/pkcs/ContentInfo.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/sun/security/pkcs/ContentInfo.java	Thu Sep 03 04:06:33 2020 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -130,6 +130,9 @@
         DerValue[] contents;
 
         typeAndContent = derin.getSequence(2);
+        if (typeAndContent.length < 1 || typeAndContent.length > 2) {
+            throw new ParsingException("Invalid length for ContentInfo");
+        }
 
         // Parse the content type
         type = typeAndContent[0];
@@ -149,6 +152,9 @@
                 disTaggedContent
                     = new DerInputStream(taggedContent.toByteArray());
                 contents = disTaggedContent.getSet(1, true);
+                if (contents.length != 1) {
+                    throw new ParsingException("ContentInfo encoding error");
+                }
                 content = contents[0];
             }
         }
--- a/src/share/classes/sun/security/pkcs/SignerInfo.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/sun/security/pkcs/SignerInfo.java	Thu Sep 03 04:06:33 2020 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -151,6 +151,9 @@
 
         // issuerAndSerialNumber
         DerValue[] issuerAndSerialNumber = derin.getSequence(2);
+        if (issuerAndSerialNumber.length != 2) {
+            throw new ParsingException("Invalid length for IssuerAndSerialNumber");
+        }
         byte[] issuerBytes = issuerAndSerialNumber[0].toByteArray();
         issuerName = new X500Name(new DerValue(DerValue.tag_Sequence,
                                                issuerBytes));
--- a/src/share/classes/sun/security/pkcs12/MacData.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/sun/security/pkcs12/MacData.java	Thu Sep 03 04:06:33 2020 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -59,10 +59,16 @@
         throws IOException, ParsingException
     {
         DerValue[] macData = derin.getSequence(2);
+        if (macData.length < 2 || macData.length > 3) {
+            throw new ParsingException("Invalid length for MacData");
+        }
 
         // Parse the digest info
         DerInputStream digestIn = new DerInputStream(macData[0].toByteArray());
         DerValue[] digestInfo = digestIn.getSequence(2);
+        if (digestInfo.length != 2) {
+            throw new ParsingException("Invalid length for DigestInfo");
+        }
 
         // Parse the DigestAlgorithmIdentifier.
         AlgorithmId digestAlgorithmId = AlgorithmId.parse(digestInfo[0]);
--- a/src/share/classes/sun/security/pkcs12/PKCS12Attribute.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/sun/security/pkcs12/PKCS12Attribute.java	Thu Sep 03 04:06:33 2020 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -250,6 +250,9 @@
     private void parse(byte[] encoded) throws IOException {
         DerInputStream attributeValue = new DerInputStream(encoded);
         DerValue[] attrSeq = attributeValue.getSequence(2);
+        if (attrSeq.length != 2) {
+            throw new IOException("Invalid length for PKCS12Attribute");
+        }
         ObjectIdentifier type = attrSeq[0].getOID();
         DerInputStream attrContent =
             new DerInputStream(attrSeq[1].toByteArray());
--- a/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java	Thu Sep 03 04:06:33 2020 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -378,6 +378,9 @@
             DerInputStream in = val.toDerInputStream();
             int i = in.getInteger();
             DerValue[] value = in.getSequence(2);
+            if (value.length < 1 || value.length > 2) {
+                throw new IOException("Invalid length for AlgorithmIdentifier");
+            }
             AlgorithmId algId = new AlgorithmId(value[0].getOID());
             String keyAlgo = algId.getName();
 
@@ -1915,11 +1918,17 @@
                 DerInputStream edi =
                                 safeContents.getContent().toDerInputStream();
                 int edVersion = edi.getInteger();
-                DerValue[] seq = edi.getSequence(2);
+                DerValue[] seq = edi.getSequence(3);
+                if (seq.length != 3) {
+                    // We require the encryptedContent field, even though
+                    // it is optional
+                    throw new IOException("Invalid length for EncryptedContentInfo");
+                }
                 ObjectIdentifier edContentType = seq[0].getOID();
                 eAlgId = seq[1].toByteArray();
                 if (!seq[2].isContextSpecific((byte)0)) {
-                   throw new IOException("encrypted content not present!");
+                    throw new IOException("unsupported encrypted content type "
+                                          + seq[2].tag);
                 }
                 byte newTag = DerValue.tag_OctetString;
                 if (seq[2].isConstructed())
@@ -2142,6 +2151,9 @@
             } else if (bagId.equals((Object)CertBag_OID)) {
                 DerInputStream cs = new DerInputStream(bagValue.toByteArray());
                 DerValue[] certValues = cs.getSequence(2);
+                if (certValues.length != 2) {
+                    throw new IOException("Invalid length for CertBag");
+                }
                 ObjectIdentifier certId = certValues[0].getOID();
                 if (!certValues[1].isContextSpecific((byte)0)) {
                     throw new IOException("unsupported PKCS12 cert value type "
@@ -2157,6 +2169,9 @@
             } else if (bagId.equals((Object)SecretBag_OID)) {
                 DerInputStream ss = new DerInputStream(bagValue.toByteArray());
                 DerValue[] secretValues = ss.getSequence(2);
+                if (secretValues.length != 2) {
+                    throw new IOException("Invalid length for SecretBag");
+                }
                 ObjectIdentifier secretId = secretValues[0].getOID();
                 if (!secretValues[1].isContextSpecific((byte)0)) {
                     throw new IOException(
@@ -2195,6 +2210,9 @@
                     byte[] encoded = attrSet[j].toByteArray();
                     DerInputStream as = new DerInputStream(encoded);
                     DerValue[] attrSeq = as.getSequence(2);
+                    if (attrSeq.length != 2) {
+                        throw new IOException("Invalid length for Attribute");
+                    }
                     ObjectIdentifier attrId = attrSeq[0].getOID();
                     DerInputStream vs =
                         new DerInputStream(attrSeq[1].toByteArray());
--- a/src/share/classes/sun/security/provider/certpath/OCSPResponse.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/sun/security/provider/certpath/OCSPResponse.java	Thu Sep 03 04:06:33 2020 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -261,7 +261,7 @@
         DerInputStream basicOCSPResponse =
             new DerInputStream(derIn.getOctetString());
 
-        DerValue[] seqTmp = basicOCSPResponse.getSequence(2);
+        DerValue[] seqTmp = basicOCSPResponse.getSequence(3);
         if (seqTmp.length < 3) {
             throw new IOException("Unexpected BasicOCSPResponse value");
         }
--- a/src/share/classes/sun/security/ssl/SessionId.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/sun/security/ssl/SessionId.java	Thu Sep 03 04:06:33 2020 +0100
@@ -27,6 +27,7 @@
 package sun.security.ssl;
 
 import java.security.SecureRandom;
+import java.util.Arrays;
 import javax.net.ssl.SSLProtocolException;
 
 /**
@@ -89,11 +90,7 @@
     /** Returns a value which is the same for session IDs which are equal */
     public int hashCode ()
     {
-        int     retval = 0;
-
-        for (int i = 0; i < sessionId.length; i++)
-            retval += sessionId [i];
-        return retval;
+        return Arrays.hashCode(sessionId);
     }
 
     /** Returns true if the parameter is the same session ID */
--- a/src/share/classes/sun/security/util/DerInputBuffer.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/sun/security/util/DerInputBuffer.java	Thu Sep 03 04:06:33 2020 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,6 @@
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
-import java.io.OutputStream;
 import java.math.BigInteger;
 import java.util.Date;
 import sun.util.calendar.CalendarDate;
@@ -275,7 +274,7 @@
         if (len > available())
             throw new IOException("short read of DER Generalized Time");
 
-        if (len < 13 || len > 23)
+        if (len < 13)
             throw new IOException("DER Generalized Time length error");
 
         return getTime(len, true);
@@ -313,15 +312,15 @@
 
         if (generalized) {
             type = "Generalized";
-            year = 1000 * Character.digit((char)buf[pos++], 10);
-            year += 100 * Character.digit((char)buf[pos++], 10);
-            year += 10 * Character.digit((char)buf[pos++], 10);
-            year += Character.digit((char)buf[pos++], 10);
+            year = 1000 * toDigit(buf[pos++], type);
+            year += 100 * toDigit(buf[pos++], type);
+            year += 10 * toDigit(buf[pos++], type);
+            year += toDigit(buf[pos++], type);
             len -= 2; // For the two extra YY
         } else {
             type = "UTC";
-            year = 10 * Character.digit((char)buf[pos++], 10);
-            year += Character.digit((char)buf[pos++], 10);
+            year = 10 * toDigit(buf[pos++], type);
+            year += toDigit(buf[pos++], type);
 
             if (year < 50)              // origin 2000
                 year += 2000;
@@ -329,17 +328,17 @@
                 year += 1900;   // origin 1900
         }
 
-        month = 10 * Character.digit((char)buf[pos++], 10);
-        month += Character.digit((char)buf[pos++], 10);
+        month = 10 * toDigit(buf[pos++], type);
+        month += toDigit(buf[pos++], type);
 
-        day = 10 * Character.digit((char)buf[pos++], 10);
-        day += Character.digit((char)buf[pos++], 10);
+        day = 10 * toDigit(buf[pos++], type);
+        day += toDigit(buf[pos++], type);
 
-        hour = 10 * Character.digit((char)buf[pos++], 10);
-        hour += Character.digit((char)buf[pos++], 10);
+        hour = 10 * toDigit(buf[pos++], type);
+        hour += toDigit(buf[pos++], type);
 
-        minute = 10 * Character.digit((char)buf[pos++], 10);
-        minute += Character.digit((char)buf[pos++], 10);
+        minute = 10 * toDigit(buf[pos++], type);
+        minute += toDigit(buf[pos++], type);
 
         len -= 10; // YYMMDDhhmm
 
@@ -350,41 +349,48 @@
          */
 
         millis = 0;
-        if (len > 2 && len < 12) {
-            second = 10 * Character.digit((char)buf[pos++], 10);
-            second += Character.digit((char)buf[pos++], 10);
+        if (len > 2) {
+            second = 10 * toDigit(buf[pos++], type);
+            second += toDigit(buf[pos++], type);
             len -= 2;
             // handle fractional seconds (if present)
-            if (buf[pos] == '.' || buf[pos] == ',') {
+            if (generalized && (buf[pos] == '.' || buf[pos] == ',')) {
                 len --;
-                pos++;
-                // handle upto milisecond precision only
-                int precision = 0;
-                int peek = pos;
-                while (buf[peek] != 'Z' &&
-                       buf[peek] != '+' &&
-                       buf[peek] != '-') {
-                    peek++;
-                    precision++;
+                if (len == 0) {
+                    throw new IOException("Parse " + type +
+                            " time, empty fractional part");
                 }
-                switch (precision) {
-                case 3:
-                    millis += 100 * Character.digit((char)buf[pos++], 10);
-                    millis += 10 * Character.digit((char)buf[pos++], 10);
-                    millis += Character.digit((char)buf[pos++], 10);
-                    break;
-                case 2:
-                    millis += 100 * Character.digit((char)buf[pos++], 10);
-                    millis += 10 * Character.digit((char)buf[pos++], 10);
-                    break;
-                case 1:
-                    millis += 100 * Character.digit((char)buf[pos++], 10);
-                    break;
-                default:
+                pos++;
+                int precision = 0;
+                while (buf[pos] != 'Z' &&
+                       buf[pos] != '+' &&
+                       buf[pos] != '-') {
+                    // Validate all digits in the fractional part but
+                    // store millisecond precision only
+                    int thisDigit = toDigit(buf[pos], type);
+                    precision++;
+                    len--;
+                    if (len == 0) {
                         throw new IOException("Parse " + type +
-                            " time, unsupported precision for seconds value");
+                                " time, invalid fractional part");
+                    }
+                    pos++;
+                    switch (precision) {
+                        case 1:
+                            millis += 100 * thisDigit;
+                            break;
+                        case 2:
+                            millis += 10 * thisDigit;
+                            break;
+                        case 3:
+                            millis += thisDigit;
+                            break;
+                    }
                 }
-                len -= precision;
+                if (precision == 0) {
+                    throw new IOException("Parse " + type +
+                            " time, empty fractional part");
+                }
             }
         } else
             second = 0;
@@ -414,10 +420,13 @@
 
         switch (buf[pos++]) {
         case '+':
-            hr = 10 * Character.digit((char)buf[pos++], 10);
-            hr += Character.digit((char)buf[pos++], 10);
-            min = 10 * Character.digit((char)buf[pos++], 10);
-            min += Character.digit((char)buf[pos++], 10);
+            if (len != 5) {
+                throw new IOException("Parse " + type + " time, invalid offset");
+            }
+            hr = 10 * toDigit(buf[pos++], type);
+            hr += toDigit(buf[pos++], type);
+            min = 10 * toDigit(buf[pos++], type);
+            min += toDigit(buf[pos++], type);
 
             if (hr >= 24 || min >= 60)
                 throw new IOException("Parse " + type + " time, +hhmm");
@@ -426,10 +435,13 @@
             break;
 
         case '-':
-            hr = 10 * Character.digit((char)buf[pos++], 10);
-            hr += Character.digit((char)buf[pos++], 10);
-            min = 10 * Character.digit((char)buf[pos++], 10);
-            min += Character.digit((char)buf[pos++], 10);
+            if (len != 5) {
+                throw new IOException("Parse " + type + " time, invalid offset");
+            }
+            hr = 10 * toDigit(buf[pos++], type);
+            hr += toDigit(buf[pos++], type);
+            min = 10 * toDigit(buf[pos++], type);
+            min += toDigit(buf[pos++], type);
 
             if (hr >= 24 || min >= 60)
                 throw new IOException("Parse " + type + " time, -hhmm");
@@ -438,6 +450,9 @@
             break;
 
         case 'Z':
+            if (len != 1) {
+                throw new IOException("Parse " + type + " time, invalid format");
+            }
             break;
 
         default:
@@ -445,4 +460,16 @@
         }
         return new Date(time);
     }
+
+    /**
+     * Converts byte (represented as a char) to int.
+     * @throws IOException if integer is not a valid digit in the specified
+     *    radix (10)
+     */
+    private static int toDigit(byte b, String type) throws IOException {
+        if (b < '0' || b > '9') {
+            throw new IOException("Parse " + type + " time, invalid format");
+        }
+        return b - '0';
+    }
 }
--- a/src/share/classes/sun/security/util/DerInputStream.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/sun/security/util/DerInputStream.java	Thu Sep 03 04:06:33 2020 +0100
@@ -191,7 +191,7 @@
         if (buffer.read() != DerValue.tag_Integer) {
             throw new IOException("DER input, Integer tag error");
         }
-        return buffer.getInteger(getLength(buffer));
+        return buffer.getInteger(getDefiniteLength(buffer));
     }
 
     /**
@@ -203,7 +203,7 @@
         if (buffer.read() != DerValue.tag_Integer) {
             throw new IOException("DER input, Integer tag error");
         }
-        return buffer.getBigInteger(getLength(buffer), false);
+        return buffer.getBigInteger(getDefiniteLength(buffer), false);
     }
 
     /**
@@ -217,7 +217,7 @@
         if (buffer.read() != DerValue.tag_Integer) {
             throw new IOException("DER input, Integer tag error");
         }
-        return buffer.getBigInteger(getLength(buffer), true);
+        return buffer.getBigInteger(getDefiniteLength(buffer), true);
     }
 
     /**
@@ -229,7 +229,7 @@
         if (buffer.read() != DerValue.tag_Enumerated) {
             throw new IOException("DER input, Enumerated tag error");
         }
-        return buffer.getInteger(getLength(buffer));
+        return buffer.getInteger(getDefiniteLength(buffer));
     }
 
     /**
@@ -240,7 +240,7 @@
         if (buffer.read() != DerValue.tag_BitString)
             throw new IOException("DER input not an bit string");
 
-        return buffer.getBitString(getLength(buffer));
+        return buffer.getBitString(getDefiniteLength(buffer));
     }
 
     /**
@@ -248,15 +248,21 @@
      * not be byte-aligned.
      */
     public BitArray getUnalignedBitString() throws IOException {
-        if (buffer.read() != DerValue.tag_BitString)
+        if (buffer.read() != DerValue.tag_BitString) {
             throw new IOException("DER input not a bit string");
+        }
 
-        int length = getLength(buffer) - 1;
+        int length = getDefiniteLength(buffer);
+
+        if (length == 0) {
+            return new BitArray(0);
+        }
 
         /*
          * First byte = number of excess bits in the last octet of the
          * representation.
          */
+        length--;
         int excessBits = buffer.read();
         if (excessBits < 0) {
             throw new IOException("Unused bits of bit string invalid");
@@ -282,7 +288,7 @@
         if (buffer.read() != DerValue.tag_OctetString)
             throw new IOException("DER input not an octet string");
 
-        int length = getLength(buffer);
+        int length = getDefiniteLength(buffer);
         byte[] retval = new byte[length];
         if ((length != 0) && (buffer.read(retval) != length))
             throw new IOException("Short read of DER octet string");
@@ -397,7 +403,7 @@
            if (tag != buffer.read())
                 throw new IOException("Indefinite length encoding" +
                         " not supported");
-           len = DerInputStream.getLength(buffer);
+           len = DerInputStream.getDefiniteLength(buffer);
         }
 
         if (len == 0)
@@ -514,7 +520,7 @@
             throw new IOException("DER input not a " +
                                   stringName + " string");
 
-        int length = getLength(buffer);
+        int length = getDefiniteLength(buffer);
         byte[] retval = new byte[length];
         if ((length != 0) && (buffer.read(retval) != length))
             throw new IOException("Short read of DER " +
@@ -529,7 +535,7 @@
     public Date getUTCTime() throws IOException {
         if (buffer.read() != DerValue.tag_UtcTime)
             throw new IOException("DER input, UTCtime tag invalid ");
-        return buffer.getUTCTime(getLength(buffer));
+        return buffer.getUTCTime(getDefiniteLength(buffer));
     }
 
     /**
@@ -538,7 +544,7 @@
     public Date getGeneralizedTime() throws IOException {
         if (buffer.read() != DerValue.tag_GeneralizedTime)
             throw new IOException("DER input, GeneralizedTime tag invalid ");
-        return buffer.getGeneralizedTime(getLength(buffer));
+        return buffer.getGeneralizedTime(getDefiniteLength(buffer));
     }
 
     /*
@@ -618,6 +624,24 @@
         return value;
     }
 
+    int getDefiniteLength() throws IOException {
+        return getDefiniteLength(buffer);
+    }
+
+    /*
+     * Get a length from the input stream.
+     *
+     * @return the length
+     * @exception IOException on parsing error or if indefinite length found.
+     */
+    static int getDefiniteLength(InputStream in) throws IOException {
+        int len = getLength(in);
+        if (len < 0) {
+            throw new IOException("Indefinite length encoding not supported");
+        }
+        return len;
+    }
+
     /**
      * Mark the current position in the buffer, so that
      * a later call to <code>reset</code> will return here.
--- a/src/share/classes/sun/security/util/DerValue.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/sun/security/util/DerValue.java	Thu Sep 03 04:06:33 2020 +0100
@@ -271,7 +271,7 @@
             if (tag != inbuf.read())
                 throw new IOException
                         ("Indefinite length encoding not supported");
-            length = DerInputStream.getLength(inbuf);
+            length = DerInputStream.getDefiniteLength(inbuf);
             buffer = inbuf.dup();
             buffer.truncate(length);
             data = new DerInputStream(buffer);
@@ -403,7 +403,7 @@
             if (tag != in.read())
                 throw new IOException
                         ("Indefinite length encoding not supported");
-            length = DerInputStream.getLength(in);
+            length = DerInputStream.getDefiniteLength(in);
         }
 
         if (fullyBuffered && in.available() != length)
@@ -780,29 +780,21 @@
     }
 
     /**
-     * Returns true iff the other object is a DER value which
-     * is bitwise equal to this one.
-     *
-     * @param other the object being compared with this one
-     */
-    public boolean equals(Object other) {
-        if (other instanceof DerValue)
-            return equals((DerValue)other);
-        else
-            return false;
-    }
-
-    /**
      * Bitwise equality comparison.  DER encoded values have a single
      * encoding, so that bitwise equality of the encoded values is an
      * efficient way to establish equivalence of the unencoded values.
      *
      * @param other the object being compared with this one
      */
-    public boolean equals(DerValue other) {
-        if (this == other) {
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
             return true;
         }
+        if (!(o instanceof DerValue)) {
+            return false;
+        }
+        DerValue other = (DerValue) o;
         if (tag != other.tag) {
             return false;
         }
@@ -835,6 +827,7 @@
      *
      * @return printable representation of the value
      */
+    @Override
     public String toString() {
         try {
 
@@ -962,6 +955,7 @@
      *
      * @return a hashcode for this DerValue.
      */
+    @Override
     public int hashCode() {
         return toString().hashCode();
     }
--- a/src/share/classes/sun/security/util/HostnameChecker.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/sun/security/util/HostnameChecker.java	Thu Sep 03 04:06:33 2020 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,6 +37,7 @@
 
 import java.security.Principal;
 import java.security.cert.*;
+import java.text.Normalizer;
 
 import javax.security.auth.x500.X500Principal;
 
@@ -226,7 +227,12 @@
                                                     (X500Name.commonName_oid);
         if (derValue != null) {
             try {
-                if (isMatched(expectedName, derValue.getAsString())) {
+                String cname = derValue.getAsString();
+                if (!Normalizer.isNormalized(cname, Normalizer.Form.NFKC)) {
+                    throw new CertificateException("Not a formal name "
+                            + cname);
+                }
+                if (isMatched(expectedName, cname)) {
                     return;
                 }
             } catch (IOException e) {
--- a/src/share/classes/sun/security/util/ObjectIdentifier.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/sun/security/util/ObjectIdentifier.java	Thu Sep 03 04:06:33 2020 +0100
@@ -53,6 +53,26 @@
 final public
 class ObjectIdentifier implements Serializable
 {
+    /*
+     * The maximum encoded OID length, excluding the ASN.1 encoding tag and
+     * length.
+     *
+     * In theory, there is no maximum size for OIDs.  However, there are some
+     * limitation in practice.
+     *
+     * RFC 5280 mandates support for OIDs that have arc elements with values
+     * that are less than 2^28 (that is, they MUST be between 0 and
+     * 268,435,455, inclusive), and implementations MUST be able to handle
+     * OIDs with up to 20 elements (inclusive).  Per RFC 5280, an encoded
+     * OID should be less than 80 bytes for safe interoperability.
+     *
+     * This class could be used for protocols other than X.509 certificates.
+     * To be safe, a relatively large but still reasonable value is chosen
+     * as the restriction in JDK.
+     */
+    private static final int MAXIMUM_OID_SIZE = 4096;    // 2^12
+
+
     /**
      * We use the DER value (no tag, no length) as the internal format
      * @serial
@@ -115,7 +135,13 @@
             if (componentLen > comp.length) {
                 componentLen = comp.length;
             }
+
+            // Check the estimated size before it is too later.
+            checkOidSize(componentLen);
+
             init(comp, componentLen);
+        } else {
+            checkOidSize(encoding.length);
         }
     }
 
@@ -198,6 +224,8 @@
                 }
                 start = end + 1;
                 count++;
+
+                checkOidSize(pos);
             } while (end != -1);
 
             checkCount(count);
@@ -259,12 +287,14 @@
                 + " (tag = " +  type_id + ")"
                 );
 
-        int len = in.getLength();
+        int len = in.getDefiniteLength();
+        checkOidSize(len);
         if (len > in.available()) {
-            throw new IOException("ObjectIdentifier() -- length exceeds" +
+            throw new IOException("ObjectIdentifier length exceeds " +
                     "data available.  Length: " + len + ", Available: " +
                     in.available());
         }
+
         encoding = new byte[len];
         in.getBytes(encoding);
         check(encoding);
@@ -278,26 +308,32 @@
     ObjectIdentifier (DerInputBuffer buf) throws IOException
     {
         DerInputStream in = new DerInputStream(buf);
-        encoding = new byte[in.available()];
+        int len = in.available();
+        checkOidSize(len);
+
+        encoding = new byte[len];
         in.getBytes(encoding);
         check(encoding);
     }
 
-    private void init(int[] components, int length) {
+    private void init(int[] components, int length) throws IOException {
         int pos = 0;
-        byte[] tmp = new byte[length*5+1];  // +1 for empty input
+        byte[] tmp = new byte[length * 5 + 1];  // +1 for empty input
 
-        if (components[1] < Integer.MAX_VALUE - components[0]*40)
-            pos += pack7Oid(components[0]*40+components[1], tmp, pos);
-        else {
+        if (components[1] < Integer.MAX_VALUE - components[0] * 40) {
+            pos += pack7Oid(components[0] * 40 + components[1], tmp, pos);
+        } else {
             BigInteger big = BigInteger.valueOf(components[1]);
-            big = big.add(BigInteger.valueOf(components[0]*40));
+            big = big.add(BigInteger.valueOf(components[0] * 40));
             pos += pack7Oid(big, tmp, pos);
         }
 
-        for (int i=2; i<length; i++) {
+        for (int i = 2; i < length; i++) {
             pos += pack7Oid(components[i], tmp, pos);
+
+            checkOidSize(pos);
         }
+
         encoding = new byte[pos];
         System.arraycopy(tmp, 0, encoding, 0, pos);
     }
@@ -669,4 +705,13 @@
                     "oid component #" + (i+1) + " must be non-negative ");
         }
     }
+
+    private static void checkOidSize(int oidLength) throws IOException {
+        if (oidLength > MAXIMUM_OID_SIZE) {
+            throw new IOException(
+                    "ObjectIdentifier encoded length exceeds " +
+                    "the restriction in JDK (OId length(>=): " + oidLength +
+                    ", Restriction: " + MAXIMUM_OID_SIZE + ")");
+        }
+    }
 }
--- a/src/share/classes/sun/util/resources/TimeZoneNames.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/sun/util/resources/TimeZoneNames.java	Thu Sep 03 04:06:33 2020 +0100
@@ -193,6 +193,8 @@
                                      "Western African Summer Time", "WAST"};
         String WET[] = new String[] {"Western European Time", "WET",
                                      "Western European Summer Time", "WEST"};
+        String WGT[] = new String[] {"Western Greenland Time", "WGT",
+                                     "Western Greenland Summer Time", "WGST"};
         String WIT[] = new String[] {"West Indonesia Time", "WIB",
                                      "West Indonesia Summer Time", "WIST"};
         String WST_AUS[] = new String[] {"Australian Western Standard Time", "AWST",
@@ -347,7 +349,7 @@
             {"America/Cuiaba", AMT},
             {"America/Curacao", AST},
             {"America/Danmarkshavn", GMT},
-            {"America/Dawson", PST},
+            {"America/Dawson", MST},
             {"America/Dawson_Creek", MST},
             {"America/Detroit", EST},
             {"America/Dominica", AST},
@@ -359,8 +361,7 @@
             {"America/Fort_Wayne", EST},
             {"America/Fortaleza", BRT},
             {"America/Glace_Bay", AST},
-            {"America/Godthab", new String[] {"Western Greenland Time", "WGT",
-                                              "Western Greenland Summer Time", "WGST"}},
+            {"America/Godthab", WGT},
             {"America/Goose_Bay", AST},
             {"America/Grand_Turk", EST},
             {"America/Grenada", AST},
@@ -422,6 +423,7 @@
             {"America/North_Dakota/Beulah", CST},
             {"America/North_Dakota/Center", CST},
             {"America/North_Dakota/New_Salem", CST},
+            {"America/Nuuk", WGT},
             {"America/Ojinaga", MST},
             {"America/Panama", EST},
             {"America/Pangnirtung", EST},
@@ -460,7 +462,7 @@
             {"America/Tortola", AST},
             {"America/Vancouver", PST},
             {"America/Virgin", AST},
-            {"America/Whitehorse", PST},
+            {"America/Whitehorse", MST},
             {"America/Winnipeg", CST},
             {"America/Yakutat", AKST},
             {"America/Yellowknife", MST},
@@ -655,7 +657,7 @@
             {"Canada/Mountain", MST},
             {"Canada/Newfoundland", NST},
             {"Canada/Pacific", PST},
-            {"Canada/Yukon", PST},
+            {"Canada/Yukon", MST},
             {"Canada/Saskatchewan", CST},
             {"CAT", CAT},
             {"CET", CET},
--- a/src/share/classes/sun/util/resources/TimeZoneNames_de.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/sun/util/resources/TimeZoneNames_de.java	Thu Sep 03 04:06:33 2020 +0100
@@ -193,6 +193,8 @@
                                      "Westafrikanische Sommerzeit", "WAST"};
         String WET[] = new String[] {"Westeurop\u00e4ische Zeit", "WEZ",
                                      "Westeurop\u00e4ische Sommerzeit", "WESZ"};
+        String WGT[] = new String[] {"Westgr\u00f6nl\u00e4ndische Zeit", "WGT",
+                                     "Westgr\u00f6nl\u00e4ndische Sommerzeit", "WGST"};
         String WIT[] = new String[] {"Westindonesische Zeit", "WIB",
                                      "Westindonesische Sommerzeit", "WIST"};
         String WST_AUS[] = new String[] {"Westliche Normalzeit (Australien)", "AWST",
@@ -347,7 +349,7 @@
             {"America/Cuiaba", AMT},
             {"America/Curacao", AST},
             {"America/Danmarkshavn", GMT},
-            {"America/Dawson", PST},
+            {"America/Dawson", MST},
             {"America/Dawson_Creek", MST},
             {"America/Detroit", EST},
             {"America/Dominica", AST},
@@ -359,8 +361,7 @@
             {"America/Fort_Wayne", EST},
             {"America/Fortaleza", BRT},
             {"America/Glace_Bay", AST},
-            {"America/Godthab", new String[] {"Westgr\u00f6nl\u00e4ndische Zeit", "WGT",
-                                              "Westgr\u00f6nl\u00e4ndische Sommerzeit", "WGST"}},
+            {"America/Godthab", WGT},
             {"America/Goose_Bay", AST},
             {"America/Grand_Turk", EST},
             {"America/Grenada", AST},
@@ -422,6 +423,7 @@
             {"America/North_Dakota/Beulah", CST},
             {"America/North_Dakota/Center", CST},
             {"America/North_Dakota/New_Salem", CST},
+            {"America/Nuuk", WGT},
             {"America/Ojinaga", MST},
             {"America/Panama", EST},
             {"America/Pangnirtung", EST},
@@ -460,7 +462,7 @@
             {"America/Tortola", AST},
             {"America/Vancouver", PST},
             {"America/Virgin", AST},
-            {"America/Whitehorse", PST},
+            {"America/Whitehorse", MST},
             {"America/Winnipeg", CST},
             {"America/Yakutat", AKST},
             {"America/Yellowknife", MST},
@@ -652,7 +654,7 @@
             {"Canada/Mountain", MST},
             {"Canada/Newfoundland", NST},
             {"Canada/Pacific", PST},
-            {"Canada/Yukon", PST},
+            {"Canada/Yukon", MST},
             {"Canada/Saskatchewan", CST},
             {"CAT", CAT},
             {"CET", CET},
--- a/src/share/classes/sun/util/resources/TimeZoneNames_es.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/sun/util/resources/TimeZoneNames_es.java	Thu Sep 03 04:06:33 2020 +0100
@@ -193,6 +193,8 @@
                                      "Hora de verano de \u00c1frica Occidental", "WAST"};
         String WET[] = new String[] {"Hora de Europa Occidental", "WET",
                                      "Hora de verano de Europa Occidental", "WEST"};
+        String WGT[] = new String[] {"Hora de Groenlandia Occidental", "WGT",
+                                     "Hora de verano de Groenlandia Occidental", "WGST"};
         String WIT[] = new String[] {"Hora de Indonesia Occidental", "WIB",
                                      "Indonesia Hora de verano de Indonesia Occidental", "WIST"};
         String WST_AUS[] = new String[] {"Hora est\u00E1ndar Occidental (Australia)", "AWST",
@@ -347,7 +349,7 @@
             {"America/Cuiaba", AMT},
             {"America/Curacao", AST},
             {"America/Danmarkshavn", GMT},
-            {"America/Dawson", PST},
+            {"America/Dawson", MST},
             {"America/Dawson_Creek", MST},
             {"America/Detroit", EST},
             {"America/Dominica", AST},
@@ -359,8 +361,7 @@
             {"America/Fort_Wayne", EST},
             {"America/Fortaleza", BRT},
             {"America/Glace_Bay", AST},
-            {"America/Godthab", new String[] {"Hora de Groenlandia Occidental", "WGT",
-                                              "Hora de verano de Groenlandia Occidental", "WGST"}},
+            {"America/Godthab", WGT},
             {"America/Goose_Bay", AST},
             {"America/Grand_Turk", EST},
             {"America/Grenada", AST},
@@ -422,6 +423,7 @@
             {"America/North_Dakota/Beulah", CST},
             {"America/North_Dakota/Center", CST},
             {"America/North_Dakota/New_Salem", CST},
+            {"America/Nuuk", WGT},
             {"America/Ojinaga", MST},
             {"America/Panama", EST},
             {"America/Pangnirtung", EST},
@@ -460,7 +462,7 @@
             {"America/Tortola", AST},
             {"America/Vancouver", PST},
             {"America/Virgin", AST},
-            {"America/Whitehorse", PST},
+            {"America/Whitehorse", MST},
             {"America/Winnipeg", CST},
             {"America/Yakutat", AKST},
             {"America/Yellowknife", MST},
@@ -652,7 +654,7 @@
             {"Canada/Mountain", MST},
             {"Canada/Newfoundland", NST},
             {"Canada/Pacific", PST},
-            {"Canada/Yukon", PST},
+            {"Canada/Yukon", MST},
             {"Canada/Saskatchewan", CST},
             {"CAT", CAT},
             {"CET", CET},
--- a/src/share/classes/sun/util/resources/TimeZoneNames_fr.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/sun/util/resources/TimeZoneNames_fr.java	Thu Sep 03 04:06:33 2020 +0100
@@ -193,6 +193,8 @@
                                      "Heure d'\u00e9t\u00e9 d'Afrique de l'Ouest", "WAST"};
         String WET[] = new String[] {"Heure d'Europe de l'Ouest", "WET",
                                      "Heure d'\u00e9t\u00e9 d'Europe de l'Ouest", "WEST"};
+        String WGT[] = new String[] {"Heure du Groenland de l'Ouest", "WGT",
+                                     "Heure d'\u00e9t\u00e9 du Groenland de l'Ouest", "WGST"};
         String WIT[] = new String[] {"Heure de l'Indon\u00e9sie occidentale", "WIB",
                                      "Heure d'\u00e9t\u00e9 de l'Indon\u00e9sie occidentale", "WIST"};
         String WST_AUS[] = new String[] {"Heure normale de l'Ouest (Australie)", "AWST",
@@ -347,7 +349,7 @@
             {"America/Cuiaba", AMT},
             {"America/Curacao", AST},
             {"America/Danmarkshavn", GMT},
-            {"America/Dawson", PST},
+            {"America/Dawson", MST},
             {"America/Dawson_Creek", MST},
             {"America/Detroit", EST},
             {"America/Dominica", AST},
@@ -359,8 +361,7 @@
             {"America/Fort_Wayne", EST},
             {"America/Fortaleza", BRT},
             {"America/Glace_Bay", AST},
-            {"America/Godthab", new String[] {"Heure du Groenland de l'Ouest", "WGT",
-                                              "Heure d'\u00e9t\u00e9 du Groenland de l'Ouest", "WGST"}},
+            {"America/Godthab", WGT},
             {"America/Goose_Bay", AST},
             {"America/Grand_Turk", EST},
             {"America/Grenada", AST},
@@ -422,6 +423,7 @@
             {"America/North_Dakota/Beulah", CST},
             {"America/North_Dakota/Center", CST},
             {"America/North_Dakota/New_Salem", CST},
+            {"America/Nuuk", WGT},
             {"America/Ojinaga", MST},
             {"America/Panama", EST},
             {"America/Pangnirtung", EST},
@@ -460,7 +462,7 @@
             {"America/Tortola", AST},
             {"America/Vancouver", PST},
             {"America/Virgin", AST},
-            {"America/Whitehorse", PST},
+            {"America/Whitehorse", MST},
             {"America/Winnipeg", CST},
             {"America/Yakutat", AKST},
             {"America/Yellowknife", MST},
@@ -652,7 +654,7 @@
             {"Canada/Mountain", MST},
             {"Canada/Newfoundland", NST},
             {"Canada/Pacific", PST},
-            {"Canada/Yukon", PST},
+            {"Canada/Yukon", MST},
             {"Canada/Saskatchewan", CST},
             {"CAT", CAT},
             {"CET", CET},
--- a/src/share/classes/sun/util/resources/TimeZoneNames_it.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/sun/util/resources/TimeZoneNames_it.java	Thu Sep 03 04:06:33 2020 +0100
@@ -193,6 +193,8 @@
                                      "Ora estiva dell'Africa occidentale", "WAST"};
         String WET[] = new String[] {"Ora dell'Europa occidentale", "WET",
                                      "Ora estiva dell'Europa occidentale", "WEST"};
+        String WGT[] = new String[] {"Ora della Groenlandia occidentale", "WGT",
+                                     "Ora estiva della Groenlandia occidentale", "WGST"};
         String WIT[] = new String[] {"Ora dell'Indonesia occidentale", "WIB",
                                      "Ora estiva dell'Indonesia occidentale", "WIST"};
         String WST_AUS[] = new String[] {"Ora standard dell'Australia occidentale", "AWST",
@@ -347,7 +349,7 @@
             {"America/Cuiaba", AMT},
             {"America/Curacao", AST},
             {"America/Danmarkshavn", GMT},
-            {"America/Dawson", PST},
+            {"America/Dawson", MST},
             {"America/Dawson_Creek", MST},
             {"America/Detroit", EST},
             {"America/Dominica", AST},
@@ -359,8 +361,7 @@
             {"America/Fort_Wayne", EST},
             {"America/Fortaleza", BRT},
             {"America/Glace_Bay", AST},
-            {"America/Godthab", new String[] {"Ora della Groenlandia occidentale", "WGT",
-                                              "Ora estiva della Groenlandia occidentale", "WGST"}},
+            {"America/Godthab", WGT},
             {"America/Goose_Bay", AST},
             {"America/Grand_Turk", EST},
             {"America/Grenada", AST},
@@ -422,6 +423,7 @@
             {"America/North_Dakota/Beulah", CST},
             {"America/North_Dakota/Center", CST},
             {"America/North_Dakota/New_Salem", CST},
+            {"America/Nuuk", WGT},
             {"America/Ojinaga", MST},
             {"America/Panama", EST},
             {"America/Pangnirtung", EST},
@@ -460,7 +462,7 @@
             {"America/Tortola", AST},
             {"America/Vancouver", PST},
             {"America/Virgin", AST},
-            {"America/Whitehorse", PST},
+            {"America/Whitehorse", MST},
             {"America/Winnipeg", CST},
             {"America/Yakutat", AKST},
             {"America/Yellowknife", MST},
@@ -652,7 +654,7 @@
             {"Canada/Mountain", MST},
             {"Canada/Newfoundland", NST},
             {"Canada/Pacific", PST},
-            {"Canada/Yukon", PST},
+            {"Canada/Yukon", MST},
             {"Canada/Saskatchewan", CST},
             {"CAT", CAT},
             {"CET", CET},
--- a/src/share/classes/sun/util/resources/TimeZoneNames_ja.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/sun/util/resources/TimeZoneNames_ja.java	Thu Sep 03 04:06:33 2020 +0100
@@ -193,6 +193,8 @@
                                      "\u897f\u30a2\u30d5\u30ea\u30ab\u590f\u6642\u9593", "WAST"};
         String WET[] = new String[] {"\u897f\u30e8\u30fc\u30ed\u30c3\u30d1\u6642\u9593", "WET",
                                      "\u897f\u30e8\u30fc\u30ed\u30c3\u30d1\u590f\u6642\u9593", "WEST"};
+        String WGT[] = new String[] {"\u897f\u30b0\u30ea\u30fc\u30f3\u30e9\u30f3\u30c9\u6642\u9593", "WGT",
+                                     "\u897f\u30b0\u30ea\u30fc\u30f3\u30e9\u30f3\u30c9\u590f\u6642\u9593", "WGST"};
         String WIT[] = new String[] {"\u897f\u30a4\u30f3\u30c9\u30cd\u30b7\u30a2\u6642\u9593", "WIB",
                                      "\u897f\u30a4\u30f3\u30c9\u30cd\u30b7\u30a2\u590f\u6642\u9593", "WIST"};
         String WST_AUS[] = new String[] {"\u897F\u90E8\u6A19\u6E96\u6642(\u30AA\u30FC\u30B9\u30C8\u30E9\u30EA\u30A2)", "AWST",
@@ -347,7 +349,7 @@
             {"America/Cuiaba", AMT},
             {"America/Curacao", AST},
             {"America/Danmarkshavn", GMT},
-            {"America/Dawson", PST},
+            {"America/Dawson", MST},
             {"America/Dawson_Creek", MST},
             {"America/Detroit", EST},
             {"America/Dominica", AST},
@@ -359,8 +361,7 @@
             {"America/Fort_Wayne", EST},
             {"America/Fortaleza", BRT},
             {"America/Glace_Bay", AST},
-            {"America/Godthab", new String[] {"\u897f\u30b0\u30ea\u30fc\u30f3\u30e9\u30f3\u30c9\u6642\u9593", "WGT",
-                                              "\u897f\u30b0\u30ea\u30fc\u30f3\u30e9\u30f3\u30c9\u590f\u6642\u9593", "WGST"}},
+            {"America/Godthab", WGT},
             {"America/Goose_Bay", AST},
             {"America/Grand_Turk", EST},
             {"America/Grenada", AST},
@@ -422,6 +423,7 @@
             {"America/North_Dakota/Beulah", CST},
             {"America/North_Dakota/Center", CST},
             {"America/North_Dakota/New_Salem", CST},
+            {"America/Nuuk", WGT},
             {"America/Ojinaga", MST},
             {"America/Panama", EST},
             {"America/Pangnirtung", EST},
@@ -460,7 +462,7 @@
             {"America/Tortola", AST},
             {"America/Vancouver", PST},
             {"America/Virgin", AST},
-            {"America/Whitehorse", PST},
+            {"America/Whitehorse", MST},
             {"America/Winnipeg", CST},
             {"America/Yakutat", AKST},
             {"America/Yellowknife", MST},
@@ -652,7 +654,7 @@
             {"Canada/Mountain", MST},
             {"Canada/Newfoundland", NST},
             {"Canada/Pacific", PST},
-            {"Canada/Yukon", PST},
+            {"Canada/Yukon", MST},
             {"Canada/Saskatchewan", CST},
             {"CAT", CAT},
             {"CET", CET},
--- a/src/share/classes/sun/util/resources/TimeZoneNames_ko.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/sun/util/resources/TimeZoneNames_ko.java	Thu Sep 03 04:06:33 2020 +0100
@@ -193,6 +193,8 @@
                                      "\uc11c\ubd80 \uc544\ud504\ub9ac\uce74 \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "WAST"};
         String WET[] = new String[] {"\uc11c\uc720\ub7fd \uc2dc\uac04", "WET",
                                      "\uc11c\uc720\ub7fd \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "WEST"};
+        String WGT[] = new String[] {"\uc11c\ubd80 \uadf8\ub9b0\ub79c\ub4dc \uc2dc\uac04", "WGT",
+                                     "\uc11c\ubd80 \uadf8\ub9b0\ub79c\ub4dc \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "WGST"};
         String WIT[] = new String[] {"\uc11c\uc778\ub3c4\ub124\uc2dc\uc544 \uc2dc\uac04", "WIB",
                                      "\uc11c\uc778\ub3c4\ub124\uc2dc\uc544 \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "WIST"};
         String WST_AUS[] = new String[] {"\uC11C\uBD80 \uD45C\uC900\uC2DC(\uC624\uC2A4\uD2B8\uB808\uC77C\uB9AC\uC544)", "AWST",
@@ -347,7 +349,7 @@
             {"America/Cuiaba", AMT},
             {"America/Curacao", AST},
             {"America/Danmarkshavn", GMT},
-            {"America/Dawson", PST},
+            {"America/Dawson", MST},
             {"America/Dawson_Creek", MST},
             {"America/Detroit", EST},
             {"America/Dominica", AST},
@@ -359,8 +361,7 @@
             {"America/Fort_Wayne", EST},
             {"America/Fortaleza", BRT},
             {"America/Glace_Bay", AST},
-            {"America/Godthab", new String[] {"\uc11c\ubd80 \uadf8\ub9b0\ub79c\ub4dc \uc2dc\uac04", "WGT",
-                                              "\uc11c\ubd80 \uadf8\ub9b0\ub79c\ub4dc \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "WGST"}},
+            {"America/Godthab", WGT},
             {"America/Goose_Bay", AST},
             {"America/Grand_Turk", EST},
             {"America/Grenada", AST},
@@ -422,6 +423,7 @@
             {"America/North_Dakota/Beulah", CST},
             {"America/North_Dakota/Center", CST},
             {"America/North_Dakota/New_Salem", CST},
+            {"America/Nuuk", WGT},
             {"America/Ojinaga", MST},
             {"America/Panama", EST},
             {"America/Pangnirtung", EST},
@@ -460,7 +462,7 @@
             {"America/Tortola", AST},
             {"America/Vancouver", PST},
             {"America/Virgin", AST},
-            {"America/Whitehorse", PST},
+            {"America/Whitehorse", MST},
             {"America/Winnipeg", CST},
             {"America/Yakutat", AKST},
             {"America/Yellowknife", MST},
@@ -652,7 +654,7 @@
             {"Canada/Mountain", MST},
             {"Canada/Newfoundland", NST},
             {"Canada/Pacific", PST},
-            {"Canada/Yukon", PST},
+            {"Canada/Yukon", MST},
             {"Canada/Saskatchewan", CST},
             {"CAT", CAT},
             {"CET", CET},
--- a/src/share/classes/sun/util/resources/TimeZoneNames_pt_BR.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/sun/util/resources/TimeZoneNames_pt_BR.java	Thu Sep 03 04:06:33 2020 +0100
@@ -193,6 +193,8 @@
                                      "Fuso hor\u00e1rio de ver\u00e3o da \u00c1frica Ocidental", "WAST"};
         String WET[] = new String[] {"Fuso hor\u00e1rio da Europa Ocidental", "WET",
                                      "Fuso hor\u00e1rio de ver\u00e3o da Europa Ocidental", "WEST"};
+        String WGT[] = new String[] {"Fuso hor\u00e1rio da Groenl\u00e2ndia Ocidental", "WGT",
+                                     "Fuso hor\u00e1rio de ver\u00e3o da Groenl\u00e2ndia Ocidental", "WGST"};
         String WIT[] = new String[] {"Fuso hor\u00e1rio da Indon\u00e9sia Ocidental", "WIB",
                                      "Fuso hor\u00e1rio de ver\u00e3o da Indon\u00e9sia Ocidental", "WIST"};
         String WST_AUS[] = new String[] {"Hor\u00E1rio-Padr\u00E3o Ocidental (Austr\u00E1lia)", "AWST",
@@ -347,7 +349,7 @@
             {"America/Cuiaba", AMT},
             {"America/Curacao", AST},
             {"America/Danmarkshavn", GMT},
-            {"America/Dawson", PST},
+            {"America/Dawson", MST},
             {"America/Dawson_Creek", MST},
             {"America/Detroit", EST},
             {"America/Dominica", AST},
@@ -359,8 +361,7 @@
             {"America/Fort_Wayne", EST},
             {"America/Fortaleza", BRT},
             {"America/Glace_Bay", AST},
-            {"America/Godthab", new String[] {"Fuso hor\u00e1rio da Groenl\u00e2ndia Ocidental", "WGT",
-                                              "Fuso hor\u00e1rio de ver\u00e3o da Groenl\u00e2ndia Ocidental", "WGST"}},
+            {"America/Godthab", WGT},
             {"America/Goose_Bay", AST},
             {"America/Grand_Turk", EST},
             {"America/Grenada", AST},
@@ -422,6 +423,7 @@
             {"America/North_Dakota/Beulah", CST},
             {"America/North_Dakota/Center", CST},
             {"America/North_Dakota/New_Salem", CST},
+            {"America/Nuuk", WGT},
             {"America/Ojinaga", MST},
             {"America/Panama", EST},
             {"America/Pangnirtung", EST},
@@ -460,7 +462,7 @@
             {"America/Tortola", AST},
             {"America/Vancouver", PST},
             {"America/Virgin", AST},
-            {"America/Whitehorse", PST},
+            {"America/Whitehorse", MST},
             {"America/Winnipeg", CST},
             {"America/Yakutat", AKST},
             {"America/Yellowknife", MST},
@@ -652,7 +654,7 @@
             {"Canada/Mountain", MST},
             {"Canada/Newfoundland", NST},
             {"Canada/Pacific", PST},
-            {"Canada/Yukon", PST},
+            {"Canada/Yukon", MST},
             {"Canada/Saskatchewan", CST},
             {"CAT", CAT},
             {"CET", CET},
--- a/src/share/classes/sun/util/resources/TimeZoneNames_sv.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/sun/util/resources/TimeZoneNames_sv.java	Thu Sep 03 04:06:33 2020 +0100
@@ -193,6 +193,8 @@
                                      "V\u00e4stafrikansk sommartid", "WAST"};
         String WET[] = new String[] {"V\u00e4steuropeisk tid", "WET",
                                      "V\u00e4steuropeisk sommartid", "WEST"};
+        String WGT[] = new String[] {"V\u00e4stra Gr\u00f6nland, normaltid", "WGT",
+                                     "V\u00e4stra Gr\u00f6nland, sommartid", "WGST"};
         String WIT[] = new String[] {"V\u00e4stindonesisk tid", "WIB",
                                      "V\u00e4stindonesisk sommartid", "WIST"};
         String WST_AUS[] = new String[] {"Western Standard Time (Australien)", "AWST",
@@ -347,7 +349,7 @@
             {"America/Cuiaba", AMT},
             {"America/Curacao", AST},
             {"America/Danmarkshavn", GMT},
-            {"America/Dawson", PST},
+            {"America/Dawson", MST},
             {"America/Dawson_Creek", MST},
             {"America/Detroit", EST},
             {"America/Dominica", AST},
@@ -359,8 +361,7 @@
             {"America/Fort_Wayne", EST},
             {"America/Fortaleza", BRT},
             {"America/Glace_Bay", AST},
-            {"America/Godthab", new String[] {"V\u00e4stra Gr\u00f6nland, normaltid", "WGT",
-                                              "V\u00e4stra Gr\u00f6nland, sommartid", "WGST"}},
+            {"America/Godthab", WGT},
             {"America/Goose_Bay", AST},
             {"America/Grand_Turk", EST},
             {"America/Grenada", AST},
@@ -422,6 +423,7 @@
             {"America/North_Dakota/Beulah", CST},
             {"America/North_Dakota/Center", CST},
             {"America/North_Dakota/New_Salem", CST},
+            {"America/Nuuk", WGT},
             {"America/Ojinaga", MST},
             {"America/Panama", EST},
             {"America/Pangnirtung", EST},
@@ -460,7 +462,7 @@
             {"America/Tortola", AST},
             {"America/Vancouver", PST},
             {"America/Virgin", AST},
-            {"America/Whitehorse", PST},
+            {"America/Whitehorse", MST},
             {"America/Winnipeg", CST},
             {"America/Yakutat", AKST},
             {"America/Yellowknife", MST},
@@ -652,7 +654,7 @@
             {"Canada/Mountain", MST},
             {"Canada/Newfoundland", NST},
             {"Canada/Pacific", PST},
-            {"Canada/Yukon", PST},
+            {"Canada/Yukon", MST},
             {"Canada/Saskatchewan", CST},
             {"CAT", CAT},
             {"CET", CET},
--- a/src/share/classes/sun/util/resources/TimeZoneNames_zh_CN.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/sun/util/resources/TimeZoneNames_zh_CN.java	Thu Sep 03 04:06:33 2020 +0100
@@ -193,6 +193,8 @@
                                      "\u897f\u975e\u590f\u4ee4\u65f6", "WAST"};
         String WET[] = new String[] {"\u897f\u6b27\u65f6\u95f4", "WET",
                                      "\u897f\u6b27\u590f\u4ee4\u65f6", "WEST"};
+        String WGT[] = new String[] {"\u897f\u683c\u6797\u5170\u5c9b\u65f6\u95f4", "WGT",
+                                     "\u897f\u683c\u6797\u5170\u5c9b\u590f\u4ee4\u65f6", "WGST"};
         String WIT[] = new String[] {"\u897f\u5370\u5ea6\u5c3c\u897f\u4e9a\u65f6\u95f4", "WIB",
                                      "\u897f\u5370\u5ea6\u5c3c\u897f\u4e9a\u590f\u4ee4\u65f6", "WIST"};
         String WST_AUS[] = new String[] {"\u897F\u90E8\u6807\u51C6\u65F6\u95F4 (\u6FB3\u5927\u5229\u4E9A)", "AWST",
@@ -347,7 +349,7 @@
             {"America/Cuiaba", AMT},
             {"America/Curacao", AST},
             {"America/Danmarkshavn", GMT},
-            {"America/Dawson", PST},
+            {"America/Dawson", MST},
             {"America/Dawson_Creek", MST},
             {"America/Detroit", EST},
             {"America/Dominica", AST},
@@ -359,8 +361,7 @@
             {"America/Fort_Wayne", EST},
             {"America/Fortaleza", BRT},
             {"America/Glace_Bay", AST},
-            {"America/Godthab", new String[] {"\u897f\u683c\u6797\u5170\u5c9b\u65f6\u95f4", "WGT",
-                                              "\u897f\u683c\u6797\u5170\u5c9b\u590f\u4ee4\u65f6", "WGST"}},
+            {"America/Godthab", WGT},
             {"America/Goose_Bay", AST},
             {"America/Grand_Turk", EST},
             {"America/Grenada", AST},
@@ -422,6 +423,7 @@
             {"America/North_Dakota/Beulah", CST},
             {"America/North_Dakota/Center", CST},
             {"America/North_Dakota/New_Salem", CST},
+            {"America/Nuuk", WGT},
             {"America/Ojinaga", MST},
             {"America/Panama", EST},
             {"America/Pangnirtung", EST},
@@ -460,7 +462,7 @@
             {"America/Tortola", AST},
             {"America/Vancouver", PST},
             {"America/Virgin", AST},
-            {"America/Whitehorse", PST},
+            {"America/Whitehorse", MST},
             {"America/Winnipeg", CST},
             {"America/Yakutat", AKST},
             {"America/Yellowknife", MST},
@@ -652,7 +654,7 @@
             {"Canada/Mountain", MST},
             {"Canada/Newfoundland", NST},
             {"Canada/Pacific", PST},
-            {"Canada/Yukon", PST},
+            {"Canada/Yukon", MST},
             {"Canada/Saskatchewan", CST},
             {"CAT", CAT},
             {"CET", CET},
--- a/src/share/classes/sun/util/resources/TimeZoneNames_zh_TW.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/classes/sun/util/resources/TimeZoneNames_zh_TW.java	Thu Sep 03 04:06:33 2020 +0100
@@ -193,6 +193,8 @@
                                      "\u897f\u975e\u590f\u4ee4\u6642\u9593", "WAST"};
         String WET[] = new String[] {"\u897f\u6b50\u6642\u9593", "WET",
                                      "\u897f\u6b50\u590f\u4ee4\u6642\u9593", "WEST"};
+        String WGT[] = new String[] {"\u897f\u683c\u6797\u862d\u5cf6\u6642\u9593", "WGT",
+                                     "\u897f\u683c\u6797\u862d\u5cf6\u590f\u4ee4\u6642\u9593", "WGST"};
         String WIT[] = new String[] {"\u897f\u5370\u5c3c\u6642\u9593", "WIB",
                                      "\u897f\u5370\u5c3c\u590f\u4ee4\u6642\u9593", "WIST"};
         String WST_AUS[] = new String[] {"\u897F\u90E8\u6A19\u6E96\u6642\u9593 (\u6FB3\u5927\u5229\u4E9E)", "AWST",
@@ -347,7 +349,7 @@
             {"America/Cuiaba", AMT},
             {"America/Curacao", AST},
             {"America/Danmarkshavn", GMT},
-            {"America/Dawson", PST},
+            {"America/Dawson", MST},
             {"America/Dawson_Creek", MST},
             {"America/Detroit", EST},
             {"America/Dominica", AST},
@@ -359,8 +361,7 @@
             {"America/Fort_Wayne", EST},
             {"America/Fortaleza", BRT},
             {"America/Glace_Bay", AST},
-            {"America/Godthab", new String[] {"\u897f\u683c\u6797\u862d\u5cf6\u6642\u9593", "WGT",
-                                              "\u897f\u683c\u6797\u862d\u5cf6\u590f\u4ee4\u6642\u9593", "WGST"}},
+            {"America/Godthab", WGT},
             {"America/Goose_Bay", AST},
             {"America/Grand_Turk", EST},
             {"America/Grenada", AST},
@@ -422,6 +423,7 @@
             {"America/North_Dakota/Beulah", CST},
             {"America/North_Dakota/Center", CST},
             {"America/North_Dakota/New_Salem", CST},
+            {"America/Nuuk", WGT},
             {"America/Ojinaga", MST},
             {"America/Panama", EST},
             {"America/Pangnirtung", EST},
@@ -460,7 +462,7 @@
             {"America/Tortola", AST},
             {"America/Vancouver", PST},
             {"America/Virgin", AST},
-            {"America/Whitehorse", PST},
+            {"America/Whitehorse", MST},
             {"America/Winnipeg", CST},
             {"America/Yakutat", AKST},
             {"America/Yellowknife", MST},
@@ -653,7 +655,7 @@
             {"Canada/Mountain", MST},
             {"Canada/Newfoundland", NST},
             {"Canada/Pacific", PST},
-            {"Canada/Yukon", PST},
+            {"Canada/Yukon", MST},
             {"Canada/Saskatchewan", CST},
             {"CAT", CAT},
             {"CET", CET},
--- a/src/share/instrument/EncodingSupport.c	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/instrument/EncodingSupport.c	Thu Sep 03 04:06:33 2020 +0100
@@ -38,7 +38,11 @@
     int i;
 
     new_length = 0;
-    for ( i = 0 ; i < length ; i++ ) {
+    /*
+     * if length < 0 or new_length becomes < 0 => string is too big
+     * (handled as error after the cycle).
+     */
+    for ( i = 0 ; i < length && new_length >= 0 ; i++ ) {
         unsigned byte;
 
         byte = (unsigned char)string[i];
--- a/src/share/instrument/InvocationAdapter.c	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/instrument/InvocationAdapter.c	Thu Sep 03 04:06:33 2020 +0100
@@ -206,8 +206,10 @@
         /*
          * According to JVMS class name is represented as CONSTANT_Utf8_info,
          * so its length is u2 (i.e. must be <= 0xFFFF).
+         * Negative oldLen or newLen means we got signed integer overflow
+         * (modifiedUtf8LengthOfUtf8 returns negative value if oldLen is negative).
          */
-        if (newLen > 0xFFFF) {
+        if (oldLen < 0 || newLen < 0 || newLen > 0xFFFF) {
             fprintf(stderr, "-javaagent: Premain-Class value is too big\n");
             free(jarfile);
             if (options != NULL) free(options);
@@ -376,8 +378,10 @@
         /*
          * According to JVMS class name is represented as CONSTANT_Utf8_info,
          * so its length is u2 (i.e. must be <= 0xFFFF).
+         * Negative oldLen or newLen means we got signed integer overflow
+         * (modifiedUtf8LengthOfUtf8 returns negative value if oldLen is negative).
          */
-        if (newLen > 0xFFFF) {
+        if (oldLen < 0 || newLen < 0 || newLen > 0xFFFF) {
             fprintf(stderr, "Agent-Class value is too big\n");
             free(jarfile);
             if (options != NULL) free(options);
--- a/src/share/javavm/export/jvm.h	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/javavm/export/jvm.h	Thu Sep 03 04:06:33 2020 +0100
@@ -1419,8 +1419,8 @@
 } jvm_version_info;
 
 #define JVM_VERSION_MAJOR(version) ((version & 0xFF000000) >> 24)
-#define JVM_VERSION_MINOR(version) ((version & 0x00FF0000) >> 16)
-#define JVM_VERSION_MICRO(version) ((version & 0x0000FF00) >> 8)
+#define JVM_VERSION_MINOR(version) ((version & 0x00FFFF00) >> 8)
+#define JVM_VERSION_MICRO(version) 0
 
 /* Build number is available only for RE builds.
  * It will be zero for internal builds.
@@ -1434,9 +1434,9 @@
     // Naming convention of RE build version string: n.n.n[_uu[c]][-<identifier>]-bxx
     unsigned int jdk_version;   /* Consists of major, minor, micro (n.n.n) */
                                 /* and build number (xx) */
-    unsigned int update_version : 8;         /* Update release version (uu) */
+    unsigned int update_version : 16;        /* Update release version (uu) */
     unsigned int special_update_version : 8; /* Special update release version (c)*/
-    unsigned int reserved1 : 16;
+    unsigned int reserved1 : 8;
     unsigned int reserved2;
 
     /* The following bits represents new JDK supports that VM has dependency on.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/native/sun/awt/giflib/COPYING	Thu Sep 03 04:06:33 2020 +0100
@@ -0,0 +1,19 @@
+The GIFLIB distribution is Copyright (c) 1997  Eric S. Raymond
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
--- a/src/share/native/sun/awt/giflib/dgif_lib.c	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/native/sun/awt/giflib/dgif_lib.c	Thu Sep 03 04:06:33 2020 +0100
@@ -23,214 +23,220 @@
  */
 
 /******************************************************************************
- *   "Gif-Lib" - Yet another gif library.
- *
- * Written by:  Gershon Elber            IBM PC Ver 1.1,    Aug. 1990
- ******************************************************************************
- * The kernel of the GIF Decoding process can be found here.
- ******************************************************************************
- * History:
- * 16 Jun 89 - Version 1.0 by Gershon Elber.
- *  3 Sep 90 - Version 1.1 by Gershon Elber (Support for Gif89, Unique names).
- *****************************************************************************/
+
+dgif_lib.c - GIF decoding
 
-/* !!!! */
+The functions here and in egif_lib.c are partitioned carefully so that
+if you only require one of read and write capability, only one of these
+two modules will be linked.  Preserve this property!
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+SPDX-License-Identifier: MIT
+
+*****************************************************************************/
 
 #include <stdlib.h>
-#if defined (__MSDOS__) && !defined(__DJGPP__) && !defined(__GNUC__)
-#include <io.h>
-#include <alloc.h>
-#include <sys\stat.h>
-#else
-#include <sys/types.h>
-#include <sys/stat.h>
-#endif /* __MSDOS__ */
+#include <limits.h>
+#include <stdint.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
 
 #ifdef _WIN32
 #include <io.h>
-#define _OPEN_BINARY
 #else
 #include <unistd.h>
-#endif
+#endif /* _WIN32 */
 
-#include <fcntl.h>
-
-#include <stdio.h>
-#include <string.h>
 #include "gif_lib.h"
 #include "gif_lib_private.h"
 
-#define COMMENT_EXT_FUNC_CODE 0xfe  /* Extension function code for
-                                       comment. */
+/* compose unsigned little endian value */
+#define UNSIGNED_LITTLE_ENDIAN(lo, hi) ((lo) | ((hi) << 8))
 
 /* avoid extra function call in case we use fread (TVT) */
-#define READ(_gif,_buf,_len)                                     \
-  (((GifFilePrivateType*)_gif->Private)->Read ?                   \
-    (size_t)((GifFilePrivateType*)_gif->Private)->Read(_gif,_buf,_len) : \
-    fread(_buf,1,_len,((GifFilePrivateType*)_gif->Private)->File))
+static int InternalRead(GifFileType *gif, GifByteType *buf, int len) {
+    //fprintf(stderr, "### Read: %d\n", len);
+    return
+    (((GifFilePrivateType*)gif->Private)->Read ?
+     ((GifFilePrivateType*)gif->Private)->Read(gif,buf,len) :
+     fread(buf,1,len,((GifFilePrivateType*)gif->Private)->File));
+}
 
-static int DGifGetWord(GifFileType *GifFile, int *Word);
+static int DGifGetWord(GifFileType *GifFile, GifWord *Word);
 static int DGifSetupDecompress(GifFileType *GifFile);
 static int DGifDecompressLine(GifFileType *GifFile, GifPixelType *Line,
                               int LineLen);
-static int DGifGetPrefixChar(unsigned int *Prefix, int Code, int ClearCode);
+static int DGifGetPrefixChar(GifPrefixType *Prefix, int Code, int ClearCode);
 static int DGifDecompressInput(GifFileType *GifFile, int *Code);
 static int DGifBufferedInput(GifFileType *GifFile, GifByteType *Buf,
                              GifByteType *NextByte);
 
 /******************************************************************************
- * Open a new gif file for read, given by its name.
- * Returns GifFileType pointer dynamically allocated which serves as the gif
- * info record. _GifError is cleared if succesfull.
- *****************************************************************************/
+ Open a new GIF file for read, given by its name.
+ Returns dynamically allocated GifFileType pointer which serves as the GIF
+ info record.
+******************************************************************************/
 GifFileType *
-DGifOpenFileName(const char *FileName) {
+DGifOpenFileName(const char *FileName, int *Error)
+{
     int FileHandle;
     GifFileType *GifFile;
 
-    if ((FileHandle = open(FileName, O_RDONLY
-#if defined(__MSDOS__) || defined(_OPEN_BINARY)
-                           | O_BINARY
-#endif /* __MSDOS__ || _OPEN_BINARY */
-         )) == -1) {
-        _GifError = D_GIF_ERR_OPEN_FAILED;
+    if ((FileHandle = open(FileName, O_RDONLY)) == -1) {
+        if (Error != NULL)
+            *Error = D_GIF_ERR_OPEN_FAILED;
         return NULL;
     }
 
-    GifFile = DGifOpenFileHandle(FileHandle);
-    if (GifFile == (GifFileType *)NULL)
-        close(FileHandle);
+    GifFile = DGifOpenFileHandle(FileHandle, Error);
     return GifFile;
 }
 
 /******************************************************************************
- * Update a new gif file, given its file handle.
- * Returns GifFileType pointer dynamically allocated which serves as the gif
- * info record. _GifError is cleared if succesfull.
- *****************************************************************************/
+ Update a new GIF file, given its file handle.
+ Returns dynamically allocated GifFileType pointer which serves as the GIF
+ info record.
+******************************************************************************/
 GifFileType *
-DGifOpenFileHandle(int FileHandle) {
-
-    unsigned char Buf[GIF_STAMP_LEN + 1];
+DGifOpenFileHandle(int FileHandle, int *Error)
+{
+    char Buf[GIF_STAMP_LEN + 1];
     GifFileType *GifFile;
     GifFilePrivateType *Private;
     FILE *f;
 
     GifFile = (GifFileType *)malloc(sizeof(GifFileType));
     if (GifFile == NULL) {
-        _GifError = D_GIF_ERR_NOT_ENOUGH_MEM;
+        if (Error != NULL)
+            *Error = D_GIF_ERR_NOT_ENOUGH_MEM;
+        (void)close(FileHandle);
         return NULL;
     }
 
-    memset(GifFile, '\0', sizeof(GifFileType));
+    /*@i1@*/memset(GifFile, '\0', sizeof(GifFileType));
+
+    /* Belt and suspenders, in case the null pointer isn't zero */
+    GifFile->SavedImages = NULL;
+    GifFile->SColorMap = NULL;
 
-    Private = (GifFilePrivateType *)malloc(sizeof(GifFilePrivateType));
+    Private = (GifFilePrivateType *)calloc(1, sizeof(GifFilePrivateType));
     if (Private == NULL) {
-        _GifError = D_GIF_ERR_NOT_ENOUGH_MEM;
+        if (Error != NULL)
+            *Error = D_GIF_ERR_NOT_ENOUGH_MEM;
+        (void)close(FileHandle);
         free((char *)GifFile);
         return NULL;
     }
-#ifdef __MSDOS__
-    setmode(FileHandle, O_BINARY);    /* Make sure it is in binary mode. */
-#endif /* __MSDOS__ */
+
+    /*@i1@*/memset(Private, '\0', sizeof(GifFilePrivateType));
+
+#ifdef _WIN32
+    _setmode(FileHandle, O_BINARY);    /* Make sure it is in binary mode. */
+#endif /* _WIN32 */
 
     f = fdopen(FileHandle, "rb");    /* Make it into a stream: */
 
-#ifdef __MSDOS__
-    setvbuf(f, NULL, _IOFBF, GIF_FILE_BUFFER_SIZE);    /* And inc. stream
-                                                          buffer. */
-#endif /* __MSDOS__ */
-
-    GifFile->Private = (VoidPtr)Private;
+    /*@-mustfreeonly@*/
+    GifFile->Private = (void *)Private;
     Private->FileHandle = FileHandle;
     Private->File = f;
     Private->FileState = FILE_STATE_READ;
-    Private->Read = 0;    /* don't use alternate input method (TVT) */
-    GifFile->UserData = 0;    /* TVT */
+    Private->Read = NULL;        /* don't use alternate input method (TVT) */
+    GifFile->UserData = NULL;    /* TVT */
+    /*@=mustfreeonly@*/
 
-    /* Lets see if this is a GIF file: */
-    if (READ(GifFile, Buf, GIF_STAMP_LEN) != GIF_STAMP_LEN) {
-        _GifError = D_GIF_ERR_READ_FAILED;
-        fclose(f);
+    /* Let's see if this is a GIF file: */
+    /* coverity[check_return] */
+    if (InternalRead(GifFile, (unsigned char *)Buf, GIF_STAMP_LEN) != GIF_STAMP_LEN) {
+        if (Error != NULL)
+            *Error = D_GIF_ERR_READ_FAILED;
+        (void)fclose(f);
         free((char *)Private);
         free((char *)GifFile);
         return NULL;
     }
 
-    /* The GIF Version number is ignored at this time. Maybe we should do
-     * something more useful with it.  */
+    /* Check for GIF prefix at start of file */
     Buf[GIF_STAMP_LEN] = 0;
-    if (strncmp(GIF_STAMP, (const char*)Buf, GIF_VERSION_POS) != 0) {
-        _GifError = D_GIF_ERR_NOT_GIF_FILE;
-        fclose(f);
+    if (strncmp(GIF_STAMP, Buf, GIF_VERSION_POS) != 0) {
+        if (Error != NULL)
+            *Error = D_GIF_ERR_NOT_GIF_FILE;
+        (void)fclose(f);
         free((char *)Private);
         free((char *)GifFile);
         return NULL;
     }
 
     if (DGifGetScreenDesc(GifFile) == GIF_ERROR) {
-        fclose(f);
+        (void)fclose(f);
         free((char *)Private);
         free((char *)GifFile);
         return NULL;
     }
 
-    _GifError = 0;
+    GifFile->Error = 0;
+
+    /* What version of GIF? */
+    Private->gif89 = (Buf[GIF_VERSION_POS] == '9');
 
     return GifFile;
 }
 
 /******************************************************************************
- * GifFileType constructor with user supplied input function (TVT)
- *****************************************************************************/
+ GifFileType constructor with user supplied input function (TVT)
+******************************************************************************/
 GifFileType *
-DGifOpen(void *userData,
-         InputFunc readFunc) {
-
-    unsigned char Buf[GIF_STAMP_LEN + 1];
+DGifOpen(void *userData, InputFunc readFunc, int *Error)
+{
+    char Buf[GIF_STAMP_LEN + 1];
     GifFileType *GifFile;
     GifFilePrivateType *Private;
 
     GifFile = (GifFileType *)malloc(sizeof(GifFileType));
     if (GifFile == NULL) {
-        _GifError = D_GIF_ERR_NOT_ENOUGH_MEM;
+        if (Error != NULL)
+            *Error = D_GIF_ERR_NOT_ENOUGH_MEM;
         return NULL;
     }
 
     memset(GifFile, '\0', sizeof(GifFileType));
 
-    Private = (GifFilePrivateType *)malloc(sizeof(GifFilePrivateType));
+    /* Belt and suspenders, in case the null pointer isn't zero */
+    GifFile->SavedImages = NULL;
+    GifFile->SColorMap = NULL;
+
+    Private = (GifFilePrivateType *)calloc(1, sizeof(GifFilePrivateType));
     if (!Private) {
-        _GifError = D_GIF_ERR_NOT_ENOUGH_MEM;
+        if (Error != NULL)
+            *Error = D_GIF_ERR_NOT_ENOUGH_MEM;
         free((char *)GifFile);
         return NULL;
     }
+    /*@i1@*/memset(Private, '\0', sizeof(GifFilePrivateType));
 
-    GifFile->Private = (VoidPtr)Private;
+    GifFile->Private = (void *)Private;
     Private->FileHandle = 0;
-    Private->File = 0;
+    Private->File = NULL;
     Private->FileState = FILE_STATE_READ;
 
     Private->Read = readFunc;    /* TVT */
     GifFile->UserData = userData;    /* TVT */
 
     /* Lets see if this is a GIF file: */
-    if (READ(GifFile, Buf, GIF_STAMP_LEN) != GIF_STAMP_LEN) {
-        _GifError = D_GIF_ERR_READ_FAILED;
+    /* coverity[check_return] */
+    if (InternalRead(GifFile, (unsigned char *)Buf, GIF_STAMP_LEN) != GIF_STAMP_LEN) {
+        if (Error != NULL)
+            *Error = D_GIF_ERR_READ_FAILED;
         free((char *)Private);
         free((char *)GifFile);
         return NULL;
     }
 
-    /* The GIF Version number is ignored at this time. Maybe we should do
-     * something more useful with it. */
-    Buf[GIF_STAMP_LEN] = 0;
-    if (strncmp(GIF_STAMP, (const char*)Buf, GIF_VERSION_POS) != 0) {
-        _GifError = D_GIF_ERR_NOT_GIF_FILE;
+    /* Check for GIF prefix at start of file */
+    Buf[GIF_STAMP_LEN] = '\0';
+    if (strncmp(GIF_STAMP, Buf, GIF_VERSION_POS) != 0) {
+        if (Error != NULL)
+            *Error = D_GIF_ERR_NOT_GIF_FILE;
         free((char *)Private);
         free((char *)GifFile);
         return NULL;
@@ -239,28 +245,34 @@
     if (DGifGetScreenDesc(GifFile) == GIF_ERROR) {
         free((char *)Private);
         free((char *)GifFile);
+        if (Error != NULL)
+            *Error = D_GIF_ERR_NO_SCRN_DSCR;
         return NULL;
     }
 
-    _GifError = 0;
+    GifFile->Error = 0;
+
+    /* What version of GIF? */
+    Private->gif89 = (Buf[GIF_VERSION_POS] == '9');
 
     return GifFile;
 }
 
 /******************************************************************************
- * This routine should be called before any other DGif calls. Note that
- * this routine is called automatically from DGif file open routines.
- *****************************************************************************/
+ This routine should be called before any other DGif calls. Note that
+ this routine is called automatically from DGif file open routines.
+******************************************************************************/
 int
-DGifGetScreenDesc(GifFileType * GifFile) {
-
-    int i, BitsPerPixel;
+DGifGetScreenDesc(GifFileType *GifFile)
+{
+    int BitsPerPixel;
+    bool SortFlag;
     GifByteType Buf[3];
     GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
 
     if (!IS_READABLE(Private)) {
         /* This file was NOT open for reading: */
-        _GifError = D_GIF_ERR_NOT_READABLE;
+        GifFile->Error = D_GIF_ERR_NOT_READABLE;
         return GIF_ERROR;
     }
 
@@ -269,26 +281,34 @@
         DGifGetWord(GifFile, &GifFile->SHeight) == GIF_ERROR)
         return GIF_ERROR;
 
-    if (READ(GifFile, Buf, 3) != 3) {
-        _GifError = D_GIF_ERR_READ_FAILED;
+    if (InternalRead(GifFile, Buf, 3) != 3) {
+        GifFile->Error = D_GIF_ERR_READ_FAILED;
+        GifFreeMapObject(GifFile->SColorMap);
+        GifFile->SColorMap = NULL;
         return GIF_ERROR;
     }
     GifFile->SColorResolution = (((Buf[0] & 0x70) + 1) >> 4) + 1;
+    SortFlag = (Buf[0] & 0x08) != 0;
     BitsPerPixel = (Buf[0] & 0x07) + 1;
     GifFile->SBackGroundColor = Buf[1];
+    GifFile->AspectByte = Buf[2];
     if (Buf[0] & 0x80) {    /* Do we have global color map? */
+        int i;
 
-        GifFile->SColorMap = MakeMapObject(1 << BitsPerPixel, NULL);
+        GifFile->SColorMap = GifMakeMapObject(1 << BitsPerPixel, NULL);
         if (GifFile->SColorMap == NULL) {
-            _GifError = D_GIF_ERR_NOT_ENOUGH_MEM;
+            GifFile->Error = D_GIF_ERR_NOT_ENOUGH_MEM;
             return GIF_ERROR;
         }
 
         /* Get the global color map: */
+        GifFile->SColorMap->SortFlag = SortFlag;
         for (i = 0; i < GifFile->SColorMap->ColorCount; i++) {
-            if (READ(GifFile, Buf, 3) != 3) {
-                FreeMapObject(GifFile->SColorMap);
-                _GifError = D_GIF_ERR_READ_FAILED;
+            /* coverity[check_return] */
+            if (InternalRead(GifFile, Buf, 3) != 3) {
+                GifFreeMapObject(GifFile->SColorMap);
+                GifFile->SColorMap = NULL;
+                GifFile->Error = D_GIF_ERR_READ_FAILED;
                 return GIF_ERROR;
             }
             GifFile->SColorMap->Colors[i].Red = Buf[0];
@@ -299,64 +319,76 @@
         GifFile->SColorMap = NULL;
     }
 
+    /*
+     * No check here for whether the background color is in range for the
+     * screen color map.  Possibly there should be.
+     */
+
     return GIF_OK;
 }
 
+const char *
+DGifGetGifVersion(GifFileType *GifFile)
+{
+    GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;
+
+    if (Private->gif89)
+        return GIF89_STAMP;
+    else
+        return GIF87_STAMP;
+}
+
 /******************************************************************************
- * This routine should be called before any attempt to read an image.
- *****************************************************************************/
+ This routine should be called before any attempt to read an image.
+******************************************************************************/
 int
-DGifGetRecordType(GifFileType * GifFile,
-                  GifRecordType * Type) {
-
+DGifGetRecordType(GifFileType *GifFile, GifRecordType* Type)
+{
     GifByteType Buf;
     GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
 
     if (!IS_READABLE(Private)) {
         /* This file was NOT open for reading: */
-        _GifError = D_GIF_ERR_NOT_READABLE;
+        GifFile->Error = D_GIF_ERR_NOT_READABLE;
         return GIF_ERROR;
     }
 
-    if (READ(GifFile, &Buf, 1) != 1) {
-        _GifError = D_GIF_ERR_READ_FAILED;
+    /* coverity[check_return] */
+    if (InternalRead(GifFile, &Buf, 1) != 1) {
+        GifFile->Error = D_GIF_ERR_READ_FAILED;
         return GIF_ERROR;
     }
 
+    //fprintf(stderr, "### DGifGetRecordType: %02x\n", Buf);
     switch (Buf) {
-      case ',':
+      case DESCRIPTOR_INTRODUCER:
           *Type = IMAGE_DESC_RECORD_TYPE;
           break;
-      case '!':
+      case EXTENSION_INTRODUCER:
           *Type = EXTENSION_RECORD_TYPE;
           break;
-      case ';':
+      case TERMINATOR_INTRODUCER:
           *Type = TERMINATE_RECORD_TYPE;
           break;
       default:
           *Type = UNDEFINED_RECORD_TYPE;
-          _GifError = D_GIF_ERR_WRONG_RECORD;
+          GifFile->Error = D_GIF_ERR_WRONG_RECORD;
           return GIF_ERROR;
     }
 
     return GIF_OK;
 }
 
-/******************************************************************************
- * This routine should be called before any attempt to read an image.
- * Note it is assumed the Image desc. header (',') has been read.
- *****************************************************************************/
 int
-DGifGetImageDesc(GifFileType * GifFile) {
-
-    int i, BitsPerPixel;
+DGifGetImageHeader(GifFileType *GifFile)
+{
+    unsigned int BitsPerPixel;
     GifByteType Buf[3];
     GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
-    SavedImage *sp;
 
     if (!IS_READABLE(Private)) {
         /* This file was NOT open for reading: */
-        _GifError = D_GIF_ERR_NOT_READABLE;
+        GifFile->Error = D_GIF_ERR_NOT_READABLE;
         return GIF_ERROR;
     }
 
@@ -365,52 +397,85 @@
         DGifGetWord(GifFile, &GifFile->Image.Width) == GIF_ERROR ||
         DGifGetWord(GifFile, &GifFile->Image.Height) == GIF_ERROR)
         return GIF_ERROR;
-    if (READ(GifFile, Buf, 1) != 1) {
-        _GifError = D_GIF_ERR_READ_FAILED;
+    if (InternalRead(GifFile, Buf, 1) != 1) {
+        GifFile->Error = D_GIF_ERR_READ_FAILED;
+        GifFreeMapObject(GifFile->Image.ColorMap);
+        GifFile->Image.ColorMap = NULL;
         return GIF_ERROR;
     }
     BitsPerPixel = (Buf[0] & 0x07) + 1;
-    GifFile->Image.Interlace = (Buf[0] & 0x40);
-    if (Buf[0] & 0x80) {    /* Does this image have local color map? */
+    GifFile->Image.Interlace = (Buf[0] & 0x40) ? true : false;
 
-        /*** FIXME: Why do we check both of these in order to do this?
-         * Why do we have both Image and SavedImages? */
-        if (GifFile->Image.ColorMap && GifFile->SavedImages == NULL)
-            FreeMapObject(GifFile->Image.ColorMap);
+    /* Setup the colormap */
+    if (GifFile->Image.ColorMap) {
+        GifFreeMapObject(GifFile->Image.ColorMap);
+        GifFile->Image.ColorMap = NULL;
+    }
+    /* Does this image have local color map? */
+    if (Buf[0] & 0x80) {
+        unsigned int i;
 
-        GifFile->Image.ColorMap = MakeMapObject(1 << BitsPerPixel, NULL);
+        GifFile->Image.ColorMap = GifMakeMapObject(1 << BitsPerPixel, NULL);
         if (GifFile->Image.ColorMap == NULL) {
-            _GifError = D_GIF_ERR_NOT_ENOUGH_MEM;
+            GifFile->Error = D_GIF_ERR_NOT_ENOUGH_MEM;
             return GIF_ERROR;
         }
 
         /* Get the image local color map: */
         for (i = 0; i < GifFile->Image.ColorMap->ColorCount; i++) {
-            if (READ(GifFile, Buf, 3) != 3) {
-                FreeMapObject(GifFile->Image.ColorMap);
-                _GifError = D_GIF_ERR_READ_FAILED;
+            /* coverity[check_return] */
+            if (InternalRead(GifFile, Buf, 3) != 3) {
+                GifFreeMapObject(GifFile->Image.ColorMap);
+                GifFile->Error = D_GIF_ERR_READ_FAILED;
+                GifFile->Image.ColorMap = NULL;
                 return GIF_ERROR;
             }
             GifFile->Image.ColorMap->Colors[i].Red = Buf[0];
             GifFile->Image.ColorMap->Colors[i].Green = Buf[1];
             GifFile->Image.ColorMap->Colors[i].Blue = Buf[2];
         }
-    } else if (GifFile->Image.ColorMap) {
-        FreeMapObject(GifFile->Image.ColorMap);
-        GifFile->Image.ColorMap = NULL;
+    }
+
+    Private->PixelCount = (long)GifFile->Image.Width *
+       (long)GifFile->Image.Height;
+
+    /* Reset decompress algorithm parameters. */
+    return DGifSetupDecompress(GifFile);
+}
+
+/******************************************************************************
+ This routine should be called before any attempt to read an image.
+ Note it is assumed the Image desc. header has been read.
+******************************************************************************/
+int
+DGifGetImageDesc(GifFileType *GifFile)
+{
+    GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
+    SavedImage *sp;
+
+    if (!IS_READABLE(Private)) {
+        /* This file was NOT open for reading: */
+        GifFile->Error = D_GIF_ERR_NOT_READABLE;
+        return GIF_ERROR;
+    }
+
+    if (DGifGetImageHeader(GifFile) == GIF_ERROR) {
+        return GIF_ERROR;
     }
 
     if (GifFile->SavedImages) {
-        if ((GifFile->SavedImages = (SavedImage *)realloc(GifFile->SavedImages,
-                                      sizeof(SavedImage) *
-                                      (GifFile->ImageCount + 1))) == NULL) {
-            _GifError = D_GIF_ERR_NOT_ENOUGH_MEM;
+        SavedImage* new_saved_images =
+            (SavedImage *)reallocarray(GifFile->SavedImages,
+                            (GifFile->ImageCount + 1), sizeof(SavedImage));
+        if (new_saved_images == NULL) {
+            GifFile->Error = D_GIF_ERR_NOT_ENOUGH_MEM;
             return GIF_ERROR;
         }
+        GifFile->SavedImages = new_saved_images;
     } else {
         if ((GifFile->SavedImages =
              (SavedImage *) malloc(sizeof(SavedImage))) == NULL) {
-            _GifError = D_GIF_ERR_NOT_ENOUGH_MEM;
+            GifFile->Error = D_GIF_ERR_NOT_ENOUGH_MEM;
             return GIF_ERROR;
         }
     }
@@ -418,11 +483,11 @@
     sp = &GifFile->SavedImages[GifFile->ImageCount];
     memcpy(&sp->ImageDesc, &GifFile->Image, sizeof(GifImageDesc));
     if (GifFile->Image.ColorMap != NULL) {
-        sp->ImageDesc.ColorMap = MakeMapObject(
+        sp->ImageDesc.ColorMap = GifMakeMapObject(
                                  GifFile->Image.ColorMap->ColorCount,
                                  GifFile->Image.ColorMap->Colors);
         if (sp->ImageDesc.ColorMap == NULL) {
-            _GifError = D_GIF_ERR_NOT_ENOUGH_MEM;
+            GifFile->Error = D_GIF_ERR_NOT_ENOUGH_MEM;
             return GIF_ERROR;
         }
     }
@@ -432,46 +497,39 @@
 
     GifFile->ImageCount++;
 
-    Private->PixelCount = (long)GifFile->Image.Width *
-       (long)GifFile->Image.Height;
-
-    return DGifSetupDecompress(GifFile);  /* Reset decompress algorithm parameters. */
+    return GIF_OK;
 }
 
 /******************************************************************************
- * Get one full scanned line (Line) of length LineLen from GIF file.
- *****************************************************************************/
+ Get one full scanned line (Line) of length LineLen from GIF file.
+******************************************************************************/
 int
-DGifGetLine(GifFileType * GifFile,
-            GifPixelType * Line,
-            int LineLen) {
-
+DGifGetLine(GifFileType *GifFile, GifPixelType *Line, int LineLen)
+{
     GifByteType *Dummy;
     GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;
 
     if (!IS_READABLE(Private)) {
         /* This file was NOT open for reading: */
-        _GifError = D_GIF_ERR_NOT_READABLE;
+        GifFile->Error = D_GIF_ERR_NOT_READABLE;
         return GIF_ERROR;
     }
 
     if (!LineLen)
         LineLen = GifFile->Image.Width;
 
-#if defined(__MSDOS__) || defined(__GNUC__)
     if ((Private->PixelCount -= LineLen) > 0xffff0000UL) {
-#else
-    if ((Private->PixelCount -= LineLen) > 0xffff0000) {
-#endif /* __MSDOS__ */
-        _GifError = D_GIF_ERR_DATA_TOO_BIG;
+        GifFile->Error = D_GIF_ERR_DATA_TOO_BIG;
         return GIF_ERROR;
     }
 
     if (DGifDecompressLine(GifFile, Line, LineLen) == GIF_OK) {
         if (Private->PixelCount == 0) {
-            /* We probably would not be called any more, so lets clean
-             * everything before we return: need to flush out all rest of
-             * image until empty block (size 0) detected. We use GetCodeNext. */
+            /* We probably won't be called any more, so let's clean up
+             * everything before we return: need to flush out all the
+             * rest of image until an empty block (size 0)
+             * detected. We use GetCodeNext.
+             */
             do
                 if (DGifGetCodeNext(GifFile, &Dummy) == GIF_ERROR)
                     return GIF_ERROR;
@@ -483,35 +541,32 @@
 }
 
 /******************************************************************************
- * Put one pixel (Pixel) into GIF file.
- *****************************************************************************/
+ Put one pixel (Pixel) into GIF file.
+******************************************************************************/
 int
-DGifGetPixel(GifFileType * GifFile,
-             GifPixelType Pixel) {
-
+DGifGetPixel(GifFileType *GifFile, GifPixelType Pixel)
+{
     GifByteType *Dummy;
     GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;
 
     if (!IS_READABLE(Private)) {
         /* This file was NOT open for reading: */
-        _GifError = D_GIF_ERR_NOT_READABLE;
+        GifFile->Error = D_GIF_ERR_NOT_READABLE;
         return GIF_ERROR;
     }
-#if defined(__MSDOS__) || defined(__GNUC__)
     if (--Private->PixelCount > 0xffff0000UL)
-#else
-    if (--Private->PixelCount > 0xffff0000)
-#endif /* __MSDOS__ */
     {
-        _GifError = D_GIF_ERR_DATA_TOO_BIG;
+        GifFile->Error = D_GIF_ERR_DATA_TOO_BIG;
         return GIF_ERROR;
     }
 
     if (DGifDecompressLine(GifFile, &Pixel, 1) == GIF_OK) {
         if (Private->PixelCount == 0) {
-            /* We probably would not be called any more, so lets clean
-             * everything before we return: need to flush out all rest of
-             * image until empty block (size 0) detected. We use GetCodeNext. */
+            /* We probably won't be called any more, so let's clean up
+             * everything before we return: need to flush out all the
+             * rest of image until an empty block (size 0)
+             * detected. We use GetCodeNext.
+             */
             do
                 if (DGifGetCodeNext(GifFile, &Dummy) == GIF_ERROR)
                     return GIF_ERROR;
@@ -523,150 +578,205 @@
 }
 
 /******************************************************************************
- * Get an extension block (see GIF manual) from gif file. This routine only
- * returns the first data block, and DGifGetExtensionNext should be called
- * after this one until NULL extension is returned.
- * The Extension should NOT be freed by the user (not dynamically allocated).
- * Note it is assumed the Extension desc. header ('!') has been read.
- *****************************************************************************/
+ Get an extension block (see GIF manual) from GIF file. This routine only
+ returns the first data block, and DGifGetExtensionNext should be called
+ after this one until NULL extension is returned.
+ The Extension should NOT be freed by the user (not dynamically allocated).
+ Note it is assumed the Extension description header has been read.
+******************************************************************************/
 int
-DGifGetExtension(GifFileType * GifFile,
-                 int *ExtCode,
-                 GifByteType ** Extension) {
-
+DGifGetExtension(GifFileType *GifFile, int *ExtCode, GifByteType **Extension)
+{
     GifByteType Buf;
     GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
 
+    //fprintf(stderr, "### -> DGifGetExtension:\n");
     if (!IS_READABLE(Private)) {
         /* This file was NOT open for reading: */
-        _GifError = D_GIF_ERR_NOT_READABLE;
+        GifFile->Error = D_GIF_ERR_NOT_READABLE;
         return GIF_ERROR;
     }
 
-    if (READ(GifFile, &Buf, 1) != 1) {
-        _GifError = D_GIF_ERR_READ_FAILED;
+    /* coverity[check_return] */
+    if (InternalRead(GifFile, &Buf, 1) != 1) {
+        GifFile->Error = D_GIF_ERR_READ_FAILED;
         return GIF_ERROR;
     }
     *ExtCode = Buf;
+    //fprintf(stderr, "### <- DGifGetExtension: %02x, about to call next\n", Buf);
 
     return DGifGetExtensionNext(GifFile, Extension);
 }
 
 /******************************************************************************
- * Get a following extension block (see GIF manual) from gif file. This
- * routine should be called until NULL Extension is returned.
- * The Extension should NOT be freed by the user (not dynamically allocated).
- *****************************************************************************/
+ Get a following extension block (see GIF manual) from GIF file. This
+ routine should be called until NULL Extension is returned.
+ The Extension should NOT be freed by the user (not dynamically allocated).
+******************************************************************************/
 int
-DGifGetExtensionNext(GifFileType * GifFile,
-                     GifByteType ** Extension) {
-
+DGifGetExtensionNext(GifFileType *GifFile, GifByteType ** Extension)
+{
     GifByteType Buf;
     GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
 
-    if (READ(GifFile, &Buf, 1) != 1) {
-        _GifError = D_GIF_ERR_READ_FAILED;
+    //fprintf(stderr, "### -> DGifGetExtensionNext\n");
+    if (InternalRead(GifFile, &Buf, 1) != 1) {
+        GifFile->Error = D_GIF_ERR_READ_FAILED;
         return GIF_ERROR;
     }
+    //fprintf(stderr, "### DGifGetExtensionNext sees %d\n", Buf);
+
     if (Buf > 0) {
         *Extension = Private->Buf;    /* Use private unused buffer. */
         (*Extension)[0] = Buf;  /* Pascal strings notation (pos. 0 is len.). */
-        if (READ(GifFile, &((*Extension)[1]), Buf) != Buf) {
-            _GifError = D_GIF_ERR_READ_FAILED;
+        /* coverity[tainted_data,check_return] */
+        if (InternalRead(GifFile, &((*Extension)[1]), Buf) != Buf) {
+            GifFile->Error = D_GIF_ERR_READ_FAILED;
             return GIF_ERROR;
         }
     } else
         *Extension = NULL;
+    //fprintf(stderr, "### <- DGifGetExtensionNext: %p\n", Extension);
+
+    return GIF_OK;
+}
+
+/******************************************************************************
+ Extract a Graphics Control Block from raw extension data
+******************************************************************************/
+
+int DGifExtensionToGCB(const size_t GifExtensionLength,
+                       const GifByteType *GifExtension,
+                       GraphicsControlBlock *GCB)
+{
+    if (GifExtensionLength != 4) {
+        return GIF_ERROR;
+    }
+
+    GCB->DisposalMode = (GifExtension[0] >> 2) & 0x07;
+    GCB->UserInputFlag = (GifExtension[0] & 0x02) != 0;
+    GCB->DelayTime = UNSIGNED_LITTLE_ENDIAN(GifExtension[1], GifExtension[2]);
+    if (GifExtension[0] & 0x01)
+        GCB->TransparentColor = (int)GifExtension[3];
+    else
+        GCB->TransparentColor = NO_TRANSPARENT_COLOR;
 
     return GIF_OK;
 }
 
 /******************************************************************************
- * This routine should be called last, to close the GIF file.
- *****************************************************************************/
-int
-DGifCloseFile(GifFileType * GifFile) {
+ Extract the Graphics Control Block for a saved image, if it exists.
+******************************************************************************/
+
+int DGifSavedExtensionToGCB(GifFileType *GifFile,
+                int ImageIndex, GraphicsControlBlock *GCB)
+{
+    int i;
+
+    if (ImageIndex < 0 || ImageIndex > GifFile->ImageCount - 1)
+        return GIF_ERROR;
+
+    GCB->DisposalMode = DISPOSAL_UNSPECIFIED;
+    GCB->UserInputFlag = false;
+    GCB->DelayTime = 0;
+    GCB->TransparentColor = NO_TRANSPARENT_COLOR;
+
+    for (i = 0; i < GifFile->SavedImages[ImageIndex].ExtensionBlockCount; i++) {
+        ExtensionBlock *ep = &GifFile->SavedImages[ImageIndex].ExtensionBlocks[i];
+        if (ep->Function == GRAPHICS_EXT_FUNC_CODE)
+            return DGifExtensionToGCB(ep->ByteCount, ep->Bytes, GCB);
+    }
+
+    return GIF_ERROR;
+}
 
+/******************************************************************************
+ This routine should be called last, to close the GIF file.
+******************************************************************************/
+int
+DGifCloseFile(GifFileType *GifFile, int *ErrorCode)
+{
     GifFilePrivateType *Private;
-    FILE *File;
+
+    if (GifFile == NULL || GifFile->Private == NULL)
+        return GIF_ERROR;
 
-    if (GifFile == NULL)
-        return GIF_ERROR;
+    if (GifFile->Image.ColorMap) {
+        GifFreeMapObject(GifFile->Image.ColorMap);
+        GifFile->Image.ColorMap = NULL;
+    }
+
+    if (GifFile->SColorMap) {
+        GifFreeMapObject(GifFile->SColorMap);
+        GifFile->SColorMap = NULL;
+    }
+
+    if (GifFile->SavedImages) {
+        GifFreeSavedImages(GifFile);
+        GifFile->SavedImages = NULL;
+    }
+
+    GifFreeExtensions(&GifFile->ExtensionBlockCount, &GifFile->ExtensionBlocks);
 
     Private = (GifFilePrivateType *) GifFile->Private;
 
     if (!IS_READABLE(Private)) {
         /* This file was NOT open for reading: */
-        _GifError = D_GIF_ERR_NOT_READABLE;
+        if (ErrorCode != NULL)
+            *ErrorCode = D_GIF_ERR_NOT_READABLE;
+        free((char *)GifFile->Private);
+        free(GifFile);
         return GIF_ERROR;
     }
 
-    File = Private->File;
-
-    if (GifFile->Image.ColorMap) {
-        FreeMapObject(GifFile->Image.ColorMap);
-        GifFile->Image.ColorMap = NULL;
-    }
-
-    if (GifFile->SColorMap) {
-        FreeMapObject(GifFile->SColorMap);
-        GifFile->SColorMap = NULL;
+    if (Private->File && (fclose(Private->File) != 0)) {
+        if (ErrorCode != NULL)
+            *ErrorCode = D_GIF_ERR_CLOSE_FAILED;
+        free((char *)GifFile->Private);
+        free(GifFile);
+        return GIF_ERROR;
     }
 
-    if (Private) {
-        free((char *)Private);
-        Private = NULL;
-    }
-
-    if (GifFile->SavedImages) {
-        FreeSavedImages(GifFile);
-        GifFile->SavedImages = NULL;
-    }
-
+    free((char *)GifFile->Private);
     free(GifFile);
-
-    if (File && (fclose(File) != 0)) {
-        _GifError = D_GIF_ERR_CLOSE_FAILED;
-        return GIF_ERROR;
-    }
+    if (ErrorCode != NULL)
+        *ErrorCode = D_GIF_SUCCEEDED;
     return GIF_OK;
 }
 
 /******************************************************************************
- * Get 2 bytes (word) from the given file:
- *****************************************************************************/
+ Get 2 bytes (word) from the given file:
+******************************************************************************/
 static int
-DGifGetWord(GifFileType * GifFile,
-            int *Word) {
-
+DGifGetWord(GifFileType *GifFile, GifWord *Word)
+{
     unsigned char c[2];
 
-    if (READ(GifFile, c, 2) != 2) {
-        _GifError = D_GIF_ERR_READ_FAILED;
+    /* coverity[check_return] */
+    if (InternalRead(GifFile, c, 2) != 2) {
+        GifFile->Error = D_GIF_ERR_READ_FAILED;
         return GIF_ERROR;
     }
 
-    *Word = (((unsigned int)c[1]) << 8) + c[0];
+    *Word = (GifWord)UNSIGNED_LITTLE_ENDIAN(c[0], c[1]);
     return GIF_OK;
 }
 
 /******************************************************************************
- * Get the image code in compressed form.  This routine can be called if the
- * information needed to be piped out as is. Obviously this is much faster
- * than decoding and encoding again. This routine should be followed by calls
- * to DGifGetCodeNext, until NULL block is returned.
- * The block should NOT be freed by the user (not dynamically allocated).
- *****************************************************************************/
+ Get the image code in compressed form.  This routine can be called if the
+ information needed to be piped out as is. Obviously this is much faster
+ than decoding and encoding again. This routine should be followed by calls
+ to DGifGetCodeNext, until NULL block is returned.
+ The block should NOT be freed by the user (not dynamically allocated).
+******************************************************************************/
 int
-DGifGetCode(GifFileType * GifFile,
-            int *CodeSize,
-            GifByteType ** CodeBlock) {
-
+DGifGetCode(GifFileType *GifFile, int *CodeSize, GifByteType **CodeBlock)
+{
     GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
 
     if (!IS_READABLE(Private)) {
         /* This file was NOT open for reading: */
-        _GifError = D_GIF_ERR_NOT_READABLE;
+        GifFile->Error = D_GIF_ERR_NOT_READABLE;
         return GIF_ERROR;
     }
 
@@ -676,27 +786,30 @@
 }
 
 /******************************************************************************
- * Continue to get the image code in compressed form. This routine should be
- * called until NULL block is returned.
- * The block should NOT be freed by the user (not dynamically allocated).
- *****************************************************************************/
+ Continue to get the image code in compressed form. This routine should be
+ called until NULL block is returned.
+ The block should NOT be freed by the user (not dynamically allocated).
+******************************************************************************/
 int
-DGifGetCodeNext(GifFileType * GifFile,
-                GifByteType ** CodeBlock) {
-
+DGifGetCodeNext(GifFileType *GifFile, GifByteType **CodeBlock)
+{
     GifByteType Buf;
     GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
 
-    if (READ(GifFile, &Buf, 1) != 1) {
-        _GifError = D_GIF_ERR_READ_FAILED;
+    /* coverity[tainted_data_argument] */
+    /* coverity[check_return] */
+    if (InternalRead(GifFile, &Buf, 1) != 1) {
+        GifFile->Error = D_GIF_ERR_READ_FAILED;
         return GIF_ERROR;
     }
 
+    /* coverity[lower_bounds] */
     if (Buf > 0) {
         *CodeBlock = Private->Buf;    /* Use private unused buffer. */
         (*CodeBlock)[0] = Buf;  /* Pascal strings notation (pos. 0 is len.). */
-        if (READ(GifFile, &((*CodeBlock)[1]), Buf) != Buf) {
-            _GifError = D_GIF_ERR_READ_FAILED;
+        /* coverity[tainted_data] */
+        if (InternalRead(GifFile, &((*CodeBlock)[1]), Buf) != Buf) {
+            GifFile->Error = D_GIF_ERR_READ_FAILED;
             return GIF_ERROR;
         }
     } else {
@@ -709,23 +822,28 @@
 }
 
 /******************************************************************************
- * Setup the LZ decompression for this image:
- *****************************************************************************/
+ Setup the LZ decompression for this image:
+******************************************************************************/
 static int
-DGifSetupDecompress(GifFileType * GifFile) {
-
+DGifSetupDecompress(GifFileType *GifFile)
+{
     int i, BitsPerPixel;
     GifByteType CodeSize;
-    unsigned int *Prefix;
+    GifPrefixType *Prefix;
     GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
 
-    READ(GifFile, &CodeSize, 1);    /* Read Code size from file. */
-    if (CodeSize >= 12) {
-        /* Invalid initial code size: report failure */
-        return GIF_ERROR;
+    /* coverity[check_return] */
+    if (InternalRead(GifFile, &CodeSize, 1) < 1) {    /* Read Code size from file. */
+        return GIF_ERROR;    /* Failed to read Code size. */
     }
     BitsPerPixel = CodeSize;
 
+    /* this can only happen on a severely malformed GIF */
+    if (BitsPerPixel > 8) {
+        GifFile->Error = D_GIF_ERR_READ_FAILED;    /* somewhat bogus error code */
+        return GIF_ERROR;    /* Failed to read Code size. */
+    }
+
     Private->Buf[0] = 0;    /* Input Buffer empty. */
     Private->BitsPerPixel = BitsPerPixel;
     Private->ClearCode = (1 << BitsPerPixel);
@@ -746,20 +864,18 @@
 }
 
 /******************************************************************************
- * The LZ decompression routine:
- * This version decompress the given gif file into Line of length LineLen.
- * This routine can be called few times (one per scan line, for example), in
- * order the complete the whole image.
- *****************************************************************************/
+ The LZ decompression routine:
+ This version decompress the given GIF file into Line of length LineLen.
+ This routine can be called few times (one per scan line, for example), in
+ order the complete the whole image.
+******************************************************************************/
 static int
-DGifDecompressLine(GifFileType * GifFile,
-                   GifPixelType * Line,
-                   int LineLen) {
-
+DGifDecompressLine(GifFileType *GifFile, GifPixelType *Line, int LineLen)
+{
     int i = 0;
     int j, CrntCode, EOFCode, ClearCode, CrntPrefix, LastCode, StackPtr;
     GifByteType *Stack, *Suffix;
-    unsigned int *Prefix;
+    GifPrefixType *Prefix;
     GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;
 
     StackPtr = Private->StackPtr;
@@ -770,8 +886,12 @@
     ClearCode = Private->ClearCode;
     LastCode = Private->LastCode;
 
+    if (StackPtr > LZ_MAX_CODE) {
+        return GIF_ERROR;
+    }
+
     if (StackPtr != 0) {
-        /* Let pop the stack off before continueing to read the gif file: */
+        /* Let pop the stack off before continueing to read the GIF file: */
         while (StackPtr != 0 && i < LineLen)
             Line[i++] = Stack[--StackPtr];
     }
@@ -784,11 +904,8 @@
             /* Note however that usually we will not be here as we will stop
              * decoding as soon as we got all the pixel, or EOF code will
              * not be read at all, and DGifGetLine/Pixel clean everything.  */
-            if (i != LineLen - 1 || Private->PixelCount != 0) {
-                _GifError = D_GIF_ERR_EOF_TOO_SOON;
-                return GIF_ERROR;
-            }
-            i++;
+            GifFile->Error = D_GIF_ERR_EOF_TOO_SOON;
+            return GIF_ERROR;
         } else if (CrntCode == ClearCode) {
             /* We need to start over again: */
             for (j = 0; j <= LZ_MAX_CODE; j++)
@@ -810,36 +927,37 @@
                  * pixels on our stack. If we done, pop the stack in reverse
                  * (thats what stack is good for!) order to output.  */
                 if (Prefix[CrntCode] == NO_SUCH_CODE) {
+                    CrntPrefix = LastCode;
+
                     /* Only allowed if CrntCode is exactly the running code:
                      * In that case CrntCode = XXXCode, CrntCode or the
                      * prefix code is last code and the suffix char is
                      * exactly the prefix of last code! */
                     if (CrntCode == Private->RunningCode - 2) {
-                        CrntPrefix = LastCode;
                         Suffix[Private->RunningCode - 2] =
                            Stack[StackPtr++] = DGifGetPrefixChar(Prefix,
                                                                  LastCode,
                                                                  ClearCode);
                     } else {
-                        _GifError = D_GIF_ERR_IMAGE_DEFECT;
-                        return GIF_ERROR;
+                        Suffix[Private->RunningCode - 2] =
+                           Stack[StackPtr++] = DGifGetPrefixChar(Prefix,
+                                                                 CrntCode,
+                                                                 ClearCode);
                     }
                 } else
                     CrntPrefix = CrntCode;
 
-                /* Now (if image is O.K.) we should not get an NO_SUCH_CODE
-                 * During the trace. As we might loop forever, in case of
-                 * defective image, we count the number of loops we trace
-                 * and stop if we got LZ_MAX_CODE. obviously we can not
-                 * loop more than that.  */
-                j = 0;
-                while (j++ <= LZ_MAX_CODE &&
+                /* Now (if image is O.K.) we should not get a NO_SUCH_CODE
+                 * during the trace. As we might loop forever, in case of
+                 * defective image, we use StackPtr as loop counter and stop
+                 * before overflowing Stack[]. */
+                while (StackPtr < LZ_MAX_CODE &&
                        CrntPrefix > ClearCode && CrntPrefix <= LZ_MAX_CODE) {
                     Stack[StackPtr++] = Suffix[CrntPrefix];
                     CrntPrefix = Prefix[CrntPrefix];
                 }
-                if (j >= LZ_MAX_CODE || CrntPrefix > LZ_MAX_CODE) {
-                    _GifError = D_GIF_ERR_IMAGE_DEFECT;
+                if (StackPtr >= LZ_MAX_CODE || CrntPrefix > LZ_MAX_CODE) {
+                    GifFile->Error = D_GIF_ERR_IMAGE_DEFECT;
                     return GIF_ERROR;
                 }
                 /* Push the last character on stack: */
@@ -849,7 +967,7 @@
                 while (StackPtr != 0 && i < LineLen)
                     Line[i++] = Stack[--StackPtr];
             }
-            if (LastCode != NO_SUCH_CODE) {
+            if (LastCode != NO_SUCH_CODE && Private->RunningCode - 2 < (LZ_MAX_CODE+1) && Prefix[Private->RunningCode - 2] == NO_SUCH_CODE) {
                 Prefix[Private->RunningCode - 2] = LastCode;
 
                 if (CrntCode == Private->RunningCode - 2) {
@@ -875,37 +993,38 @@
 }
 
 /******************************************************************************
- * Routine to trace the Prefixes linked list until we get a prefix which is
- * not code, but a pixel value (less than ClearCode). Returns that pixel value.
- * If image is defective, we might loop here forever, so we limit the loops to
- * the maximum possible if image O.k. - LZ_MAX_CODE times.
- *****************************************************************************/
+ Routine to trace the Prefixes linked list until we get a prefix which is
+ not code, but a pixel value (less than ClearCode). Returns that pixel value.
+ If image is defective, we might loop here forever, so we limit the loops to
+ the maximum possible if image O.k. - LZ_MAX_CODE times.
+******************************************************************************/
 static int
-DGifGetPrefixChar(unsigned int *Prefix,
-                  int Code,
-                  int ClearCode) {
-
+DGifGetPrefixChar(GifPrefixType *Prefix, int Code, int ClearCode)
+{
     int i = 0;
 
-    while (Code > ClearCode && i++ <= LZ_MAX_CODE)
+    while (Code > ClearCode && i++ <= LZ_MAX_CODE) {
+        if (Code > LZ_MAX_CODE) {
+            return NO_SUCH_CODE;
+        }
         Code = Prefix[Code];
+    }
     return Code;
 }
 
 /******************************************************************************
- * Interface for accessing the LZ codes directly. Set Code to the real code
- * (12bits), or to -1 if EOF code is returned.
- *****************************************************************************/
+ Interface for accessing the LZ codes directly. Set Code to the real code
+ (12bits), or to -1 if EOF code is returned.
+******************************************************************************/
 int
-DGifGetLZCodes(GifFileType * GifFile,
-               int *Code) {
-
+DGifGetLZCodes(GifFileType *GifFile, int *Code)
+{
     GifByteType *CodeBlock;
     GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
 
     if (!IS_READABLE(Private)) {
         /* This file was NOT open for reading: */
-        _GifError = D_GIF_ERR_NOT_READABLE;
+        GifFile->Error = D_GIF_ERR_NOT_READABLE;
         return GIF_ERROR;
     }
 
@@ -931,32 +1050,38 @@
 }
 
 /******************************************************************************
- * The LZ decompression input routine:
- * This routine is responsable for the decompression of the bit stream from
- * 8 bits (bytes) packets, into the real codes.
- * Returns GIF_OK if read succesfully.
- *****************************************************************************/
+ The LZ decompression input routine:
+ This routine is responsable for the decompression of the bit stream from
+ 8 bits (bytes) packets, into the real codes.
+ Returns GIF_OK if read successfully.
+******************************************************************************/
 static int
-DGifDecompressInput(GifFileType * GifFile,
-                    int *Code) {
-
-    GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
-
-    GifByteType NextByte;
-    static unsigned int CodeMasks[] = {
+DGifDecompressInput(GifFileType *GifFile, int *Code)
+{
+    static const unsigned short CodeMasks[] = {
         0x0000, 0x0001, 0x0003, 0x0007,
         0x000f, 0x001f, 0x003f, 0x007f,
         0x00ff, 0x01ff, 0x03ff, 0x07ff,
         0x0fff
     };
 
+    GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
+
+    GifByteType NextByte;
+
+    /* The image can't contain more than LZ_BITS per code. */
+    if (Private->RunningBits > LZ_BITS) {
+        GifFile->Error = D_GIF_ERR_IMAGE_DEFECT;
+        return GIF_ERROR;
+    }
+
     while (Private->CrntShiftState < Private->RunningBits) {
         /* Needs to get more bytes from input stream for next code: */
         if (DGifBufferedInput(GifFile, Private->Buf, &NextByte) == GIF_ERROR) {
             return GIF_ERROR;
         }
         Private->CrntShiftDWord |=
-           ((unsigned long)NextByte) << Private->CrntShiftState;
+            ((unsigned long)NextByte) << Private->CrntShiftState;
         Private->CrntShiftState += 8;
     }
     *Code = Private->CrntShiftDWord & CodeMasks[Private->RunningBits];
@@ -965,37 +1090,45 @@
     Private->CrntShiftState -= Private->RunningBits;
 
     /* If code cannot fit into RunningBits bits, must raise its size. Note
-     * however that codes above 4095 are used for special signaling.  */
-    if (++Private->RunningCode > Private->MaxCode1) {
-        if (Private->RunningBits < LZ_BITS) {
-            Private->MaxCode1 <<= 1;
-            Private->RunningBits++;
-        } else {
-            Private->RunningCode = Private->MaxCode1;
-        }
+     * however that codes above 4095 are used for special signaling.
+     * If we're using LZ_BITS bits already and we're at the max code, just
+     * keep using the table as it is, don't increment Private->RunningCode.
+     */
+    if (Private->RunningCode < LZ_MAX_CODE + 2 &&
+        ++Private->RunningCode > Private->MaxCode1 &&
+        Private->RunningBits < LZ_BITS) {
+        Private->MaxCode1 <<= 1;
+        Private->RunningBits++;
     }
     return GIF_OK;
 }
 
 /******************************************************************************
- * This routines read one gif data block at a time and buffers it internally
- * so that the decompression routine could access it.
- * The routine returns the next byte from its internal buffer (or read next
- * block in if buffer empty) and returns GIF_OK if succesful.
- *****************************************************************************/
+ This routines read one GIF data block at a time and buffers it internally
+ so that the decompression routine could access it.
+ The routine returns the next byte from its internal buffer (or read next
+ block in if buffer empty) and returns GIF_OK if succesful.
+******************************************************************************/
 static int
-DGifBufferedInput(GifFileType * GifFile,
-                  GifByteType * Buf,
-                  GifByteType * NextByte) {
-
+DGifBufferedInput(GifFileType *GifFile, GifByteType *Buf, GifByteType *NextByte)
+{
     if (Buf[0] == 0) {
         /* Needs to read the next buffer - this one is empty: */
-        if (READ(GifFile, Buf, 1) != 1) {
-            _GifError = D_GIF_ERR_READ_FAILED;
+        /* coverity[check_return] */
+        if (InternalRead(GifFile, Buf, 1) != 1) {
+            GifFile->Error = D_GIF_ERR_READ_FAILED;
             return GIF_ERROR;
         }
-        if (READ(GifFile, &Buf[1], Buf[0]) != Buf[0]) {
-            _GifError = D_GIF_ERR_READ_FAILED;
+        /* There shouldn't be any empty data blocks here as the LZW spec
+         * says the LZW termination code should come first.  Therefore we
+         * shouldn't be inside this routine at that point.
+         */
+        if (Buf[0] == 0) {
+            GifFile->Error = D_GIF_ERR_IMAGE_DEFECT;
+            return GIF_ERROR;
+        }
+        if (InternalRead(GifFile, &Buf[1], Buf[0]) != Buf[0]) {
+            GifFile->Error = D_GIF_ERR_READ_FAILED;
             return GIF_ERROR;
         }
         *NextByte = Buf[1];
@@ -1010,21 +1143,21 @@
 }
 
 /******************************************************************************
- * This routine reads an entire GIF into core, hanging all its state info off
- * the GifFileType pointer.  Call DGifOpenFileName() or DGifOpenFileHandle()
- * first to initialize I/O.  Its inverse is EGifSpew().
- ******************************************************************************/
+ This routine reads an entire GIF into core, hanging all its state info off
+ the GifFileType pointer.  Call DGifOpenFileName() or DGifOpenFileHandle()
+ first to initialize I/O.  Its inverse is EGifSpew().
+*******************************************************************************/
 int
-DGifSlurp(GifFileType * GifFile) {
-
-    int ImageSize;
+DGifSlurp(GifFileType *GifFile)
+{
+    size_t ImageSize;
     GifRecordType RecordType;
     SavedImage *sp;
     GifByteType *ExtData;
-    SavedImage temp_save;
+    int ExtFunction;
 
-    temp_save.ExtensionBlocks = NULL;
-    temp_save.ExtensionBlockCount = 0;
+    GifFile->ExtensionBlocks = NULL;
+    GifFile->ExtensionBlockCount = 0;
 
     do {
         if (DGifGetRecordType(GifFile, &RecordType) == GIF_ERROR)
@@ -1036,44 +1169,79 @@
                   return (GIF_ERROR);
 
               sp = &GifFile->SavedImages[GifFile->ImageCount - 1];
+              /* Allocate memory for the image */
+              if (sp->ImageDesc.Width <= 0 || sp->ImageDesc.Height <= 0 ||
+                      sp->ImageDesc.Width > (INT_MAX / sp->ImageDesc.Height)) {
+                  return GIF_ERROR;
+              }
               ImageSize = sp->ImageDesc.Width * sp->ImageDesc.Height;
 
-              sp->RasterBits = (unsigned char *)malloc(ImageSize *
-                                                       sizeof(GifPixelType));
+              if (ImageSize > (SIZE_MAX / sizeof(GifPixelType))) {
+                  return GIF_ERROR;
+              }
+              sp->RasterBits = (unsigned char *)reallocarray(NULL, ImageSize,
+                      sizeof(GifPixelType));
+
               if (sp->RasterBits == NULL) {
                   return GIF_ERROR;
               }
-              if (DGifGetLine(GifFile, sp->RasterBits, ImageSize) ==
-                  GIF_ERROR)
-                  return (GIF_ERROR);
-              if (temp_save.ExtensionBlocks) {
-                  sp->ExtensionBlocks = temp_save.ExtensionBlocks;
-                  sp->ExtensionBlockCount = temp_save.ExtensionBlockCount;
 
-                  temp_save.ExtensionBlocks = NULL;
-                  temp_save.ExtensionBlockCount = 0;
+              if (sp->ImageDesc.Interlace) {
+                  int i, j;
+                   /*
+                    * The way an interlaced image should be read -
+                    * offsets and jumps...
+                    */
+                  int InterlacedOffset[] = { 0, 4, 2, 1 };
+                  int InterlacedJumps[] = { 8, 8, 4, 2 };
+                  /* Need to perform 4 passes on the image */
+                  for (i = 0; i < 4; i++)
+                      for (j = InterlacedOffset[i];
+                       j < sp->ImageDesc.Height;
+                       j += InterlacedJumps[i]) {
+                      if (DGifGetLine(GifFile,
+                              sp->RasterBits+j*sp->ImageDesc.Width,
+                              sp->ImageDesc.Width) == GIF_ERROR)
+                          return GIF_ERROR;
+                      }
+              }
+              else {
+                  if (DGifGetLine(GifFile,sp->RasterBits,ImageSize)==GIF_ERROR)
+                      return (GIF_ERROR);
+              }
 
-                  /* FIXME: The following is wrong.  It is left in only for
-                   * backwards compatibility.  Someday it should go away. Use
-                   * the sp->ExtensionBlocks->Function variable instead. */
-                  sp->Function = sp->ExtensionBlocks[0].Function;
+              if (GifFile->ExtensionBlocks) {
+                  sp->ExtensionBlocks = GifFile->ExtensionBlocks;
+                  sp->ExtensionBlockCount = GifFile->ExtensionBlockCount;
+
+                  GifFile->ExtensionBlocks = NULL;
+                  GifFile->ExtensionBlockCount = 0;
               }
               break;
 
           case EXTENSION_RECORD_TYPE:
-              if (DGifGetExtension(GifFile, &temp_save.Function, &ExtData) ==
-                  GIF_ERROR)
+              if (DGifGetExtension(GifFile,&ExtFunction,&ExtData) == GIF_ERROR)
                   return (GIF_ERROR);
-              while (ExtData != NULL) {
-
-                  /* Create an extension block with our data */
-                  if (AddExtensionBlock(&temp_save, ExtData[0], &ExtData[1])
+              /* Create an extension block with our data */
+              if (ExtData != NULL) {
+                  if (GifAddExtensionBlock(&GifFile->ExtensionBlockCount,
+                               &GifFile->ExtensionBlocks,
+                               ExtFunction, ExtData[0], &ExtData[1])
                       == GIF_ERROR)
                       return (GIF_ERROR);
-
+              }
+              for (;;) {
                   if (DGifGetExtensionNext(GifFile, &ExtData) == GIF_ERROR)
                       return (GIF_ERROR);
-                  temp_save.Function = 0;
+                  if (ExtData == NULL)
+                      break;
+                  /* Continue the extension block */
+                  if (ExtData != NULL)
+                      if (GifAddExtensionBlock(&GifFile->ExtensionBlockCount,
+                                   &GifFile->ExtensionBlocks,
+                                   CONTINUE_EXT_FUNC_CODE,
+                                   ExtData[0], &ExtData[1]) == GIF_ERROR)
+                              return (GIF_ERROR);
               }
               break;
 
@@ -1085,12 +1253,13 @@
         }
     } while (RecordType != TERMINATE_RECORD_TYPE);
 
-    /* Just in case the Gif has an extension block without an associated
-     * image... (Should we save this into a savefile structure with no image
-     * instead? Have to check if the present writing code can handle that as
-     * well.... */
-    if (temp_save.ExtensionBlocks)
-        FreeExtension(&temp_save);
+    /* Sanity check for corrupted file */
+    if (GifFile->ImageCount == 0) {
+        GifFile->Error = D_GIF_ERR_NO_IMAG_DSCR;
+        return(GIF_ERROR);
+    }
 
     return (GIF_OK);
 }
+
+/* end */
--- a/src/share/native/sun/awt/giflib/gif_err.c	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/native/sun/awt/giflib/gif_err.c	Thu Sep 03 04:06:33 2020 +0100
@@ -23,71 +23,83 @@
  */
 
 /*****************************************************************************
- *   "Gif-Lib" - Yet another gif library.
- *
- * Written by:  Gershon Elber            IBM PC Ver 0.1,    Jun. 1989
- *****************************************************************************
- * Handle error reporting for the GIF library.
- *****************************************************************************
- * History:
- * 17 Jun 89 - Version 1.0 by Gershon Elber.
- ****************************************************************************/
+
+gif_err.c - handle error reporting for the GIF library.
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+SPDX-License-Identifier: MIT
+
+****************************************************************************/
 
 #include <stdio.h>
+
 #include "gif_lib.h"
-
-int _GifError = 0;
+#include "gif_lib_private.h"
 
 /*****************************************************************************
- * Return the last GIF error (0 if none) and reset the error.
- ****************************************************************************/
-int
-GifLastError(void) {
-    int i = _GifError;
-
-    _GifError = 0;
+ Return a string description of  the last GIF error
+*****************************************************************************/
+const char *
+GifErrorString(int ErrorCode)
+{
+    const char *Err;
 
-    return i;
-}
-
-/*****************************************************************************
- * Print the last GIF error to stderr.
- ****************************************************************************/
-void
-PrintGifError(void) {
-    char *Err;
-
-    switch (_GifError) {
+    switch (ErrorCode) {
+      case E_GIF_ERR_OPEN_FAILED:
+        Err = "Failed to open given file";
+        break;
+      case E_GIF_ERR_WRITE_FAILED:
+        Err = "Failed to write to given file";
+        break;
+      case E_GIF_ERR_HAS_SCRN_DSCR:
+        Err = "Screen descriptor has already been set";
+        break;
+      case E_GIF_ERR_HAS_IMAG_DSCR:
+        Err = "Image descriptor is still active";
+        break;
+      case E_GIF_ERR_NO_COLOR_MAP:
+        Err = "Neither global nor local color map";
+        break;
+      case E_GIF_ERR_DATA_TOO_BIG:
+        Err = "Number of pixels bigger than width * height";
+        break;
+      case E_GIF_ERR_NOT_ENOUGH_MEM:
+        Err = "Failed to allocate required memory";
+        break;
+      case E_GIF_ERR_DISK_IS_FULL:
+        Err = "Write failed (disk full?)";
+        break;
+      case E_GIF_ERR_CLOSE_FAILED:
+        Err = "Failed to close given file";
+        break;
+      case E_GIF_ERR_NOT_WRITEABLE:
+        Err = "Given file was not opened for write";
+        break;
       case D_GIF_ERR_OPEN_FAILED:
         Err = "Failed to open given file";
         break;
       case D_GIF_ERR_READ_FAILED:
-        Err = "Failed to Read from given file";
+        Err = "Failed to read from given file";
         break;
       case D_GIF_ERR_NOT_GIF_FILE:
-        Err = "Given file is NOT GIF file";
+        Err = "Data is not in GIF format";
         break;
       case D_GIF_ERR_NO_SCRN_DSCR:
-        Err = "No Screen Descriptor detected";
+        Err = "No screen descriptor detected";
         break;
       case D_GIF_ERR_NO_IMAG_DSCR:
         Err = "No Image Descriptor detected";
         break;
       case D_GIF_ERR_NO_COLOR_MAP:
-        Err = "Neither Global Nor Local color map";
+        Err = "Neither global nor local color map";
         break;
       case D_GIF_ERR_WRONG_RECORD:
         Err = "Wrong record type detected";
         break;
       case D_GIF_ERR_DATA_TOO_BIG:
-        Err = "#Pixels bigger than Width * Height";
+        Err = "Number of pixels bigger than width * height";
         break;
       case D_GIF_ERR_NOT_ENOUGH_MEM:
-        Err = "Fail to allocate required memory";
+        Err = "Failed to allocate required memory";
         break;
       case D_GIF_ERR_CLOSE_FAILED:
         Err = "Failed to close given file";
@@ -99,14 +111,13 @@
         Err = "Image is defective, decoding aborted";
         break;
       case D_GIF_ERR_EOF_TOO_SOON:
-        Err = "Image EOF detected, before image complete";
+        Err = "Image EOF detected before image complete";
         break;
       default:
         Err = NULL;
         break;
     }
-    if (Err != NULL)
-        fprintf(stderr, "\nGIF-LIB error: %s.\n", Err);
-    else
-        fprintf(stderr, "\nGIF-LIB undefined error %d.\n", _GifError);
+    return Err;
 }
+
+/* end */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/native/sun/awt/giflib/gif_hash.h	Thu Sep 03 04:06:33 2020 +0100
@@ -0,0 +1,69 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/******************************************************************************
+
+gif_hash.h - magfic constants and declarations for GIF LZW
+
+SPDX-License-Identifier: MIT
+
+******************************************************************************/
+
+#ifndef _GIF_HASH_H_
+#define _GIF_HASH_H_
+
+/** Begin JDK modifications to support building on Windows **/
+#ifndef _WIN32
+#include <unistd.h>
+#endif
+/** End JDK modifications to support building on Windows **/
+#include <stdint.h>
+
+#define HT_SIZE         8192    /* 12bits = 4096 or twice as big! */
+#define HT_KEY_MASK     0x1FFF  /* 13bits keys */
+#define HT_KEY_NUM_BITS 13      /* 13bits keys */
+#define HT_MAX_KEY      8191    /* 13bits - 1, maximal code possible */
+#define HT_MAX_CODE     4095    /* Biggest code possible in 12 bits. */
+
+/* The 32 bits of the long are divided into two parts for the key & code:   */
+/* 1. The code is 12 bits as our compression algorithm is limited to 12bits */
+/* 2. The key is 12 bits Prefix code + 8 bit new char or 20 bits.           */
+/* The key is the upper 20 bits.  The code is the lower 12. */
+#define HT_GET_KEY(l)    (l >> 12)
+#define HT_GET_CODE(l)   (l & 0x0FFF)
+#define HT_PUT_KEY(l)    (l << 12)
+#define HT_PUT_CODE(l)   (l & 0x0FFF)
+
+typedef struct GifHashTableType {
+    uint32_t HTable[HT_SIZE];
+} GifHashTableType;
+
+GifHashTableType *_InitHashTable(void);
+void _ClearHashTable(GifHashTableType *HashTable);
+void _InsertHashTable(GifHashTableType *HashTable, uint32_t Key, int Code);
+int _ExistsHashTable(GifHashTableType *HashTable, uint32_t Key);
+
+#endif /* _GIF_HASH_H_ */
+
+/* end */
--- a/src/share/native/sun/awt/giflib/gif_lib.h	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/native/sun/awt/giflib/gif_lib.h	Thu Sep 03 04:06:33 2020 +0100
@@ -23,21 +23,12 @@
  */
 
 /******************************************************************************
- * In order to make life a little bit easier when using the GIF file format,
- * this library was written, and which does all the dirty work...
- *
- *                                        Written by Gershon Elber,  Jun. 1989
- *                                        Hacks by Eric S. Raymond,  Sep. 1992
- ******************************************************************************
- * History:
- * 14 Jun 89 - Version 1.0 by Gershon Elber.
- *  3 Sep 90 - Version 1.1 by Gershon Elber (Support for Gif89, Unique names)
- * 15 Sep 90 - Version 2.0 by Eric S. Raymond (Changes to suoport GIF slurp)
- * 26 Jun 96 - Version 3.0 by Eric S. Raymond (Full GIF89 support)
- * 17 Dec 98 - Version 4.0 by Toshio Kuratomi (Fix extension writing code)
- *****************************************************************************/
+
+gif_lib.h - service library for decoding and encoding GIF images
 
-/* all encoding functionality stripped */
+SPDX-License-Identifier: MIT
+
+*****************************************************************************/
 
 #ifndef _GIF_LIB_H_
 #define _GIF_LIB_H_ 1
@@ -46,21 +37,23 @@
 extern "C" {
 #endif /* __cplusplus */
 
-#define GIF_LIB_VERSION " Version 4.1, "
+#define GIFLIB_MAJOR 5
+#define GIFLIB_MINOR 2
+#define GIFLIB_RELEASE 1
 
 #define GIF_ERROR   0
 #define GIF_OK      1
 
-#ifndef TRUE
-#define TRUE        1
-#endif /* TRUE */
-#ifndef FALSE
-#define FALSE       0
-#endif /* FALSE */
-
-#ifndef NULL
-#define NULL        0
-#endif /* NULL */
+#include <stddef.h>
+/** Begin JDK modifications to support building using old compilers**/
+//#include <stdbool.h>
+#ifdef bool
+#undef bool
+#endif
+typedef int bool;
+#define false 0
+#define true 1
+/** End JDK modifications to support building using old compilers**/
 
 #define GIF_STAMP "GIFVER"          /* First chars in file - GIF stamp.  */
 #define GIF_STAMP_LEN sizeof(GIF_STAMP) - 1
@@ -68,21 +61,11 @@
 #define GIF87_STAMP "GIF87a"        /* First chars in file - GIF stamp.  */
 #define GIF89_STAMP "GIF89a"        /* First chars in file - GIF stamp.  */
 
-#define GIF_FILE_BUFFER_SIZE 16384  /* Files uses bigger buffers than usual. */
-
-typedef int GifBooleanType;
 typedef unsigned char GifPixelType;
 typedef unsigned char *GifRowType;
 typedef unsigned char GifByteType;
-
-#define GIF_MESSAGE(Msg) fprintf(stderr, "\n%s: %s\n", PROGRAM_NAME, Msg)
-#define GIF_EXIT(Msg)    { GIF_MESSAGE(Msg); exit(-3); }
-
-#ifdef SYSV
-#define VoidPtr char *
-#else
-#define VoidPtr void *
-#endif /* SYSV */
+typedef unsigned int GifPrefixType;
+typedef int GifWord;
 
 typedef struct GifColorType {
     GifByteType Red, Green, Blue;
@@ -91,27 +74,52 @@
 typedef struct ColorMapObject {
     int ColorCount;
     int BitsPerPixel;
+    bool SortFlag;
     GifColorType *Colors;    /* on malloc(3) heap */
 } ColorMapObject;
 
 typedef struct GifImageDesc {
-    int Left, Top, Width, Height,   /* Current image dimensions. */
-      Interlace;                    /* Sequential/Interlaced lines. */
-    ColorMapObject *ColorMap;       /* The local color map */
+    GifWord Left, Top, Width, Height;   /* Current image dimensions. */
+    bool Interlace;                     /* Sequential/Interlaced lines. */
+    ColorMapObject *ColorMap;           /* The local color map */
 } GifImageDesc;
 
+typedef struct ExtensionBlock {
+    int ByteCount;
+    GifByteType *Bytes; /* on malloc(3) heap */
+    int Function;       /* The block function code */
+#define CONTINUE_EXT_FUNC_CODE    0x00    /* continuation subblock */
+#define COMMENT_EXT_FUNC_CODE     0xfe    /* comment */
+#define GRAPHICS_EXT_FUNC_CODE    0xf9    /* graphics control (GIF89) */
+#define PLAINTEXT_EXT_FUNC_CODE   0x01    /* plaintext */
+#define APPLICATION_EXT_FUNC_CODE 0xff    /* application block (GIF89) */
+} ExtensionBlock;
+
+typedef struct SavedImage {
+    GifImageDesc ImageDesc;
+    GifByteType *RasterBits;         /* on malloc(3) heap */
+    int ExtensionBlockCount;         /* Count of extensions before image */
+    ExtensionBlock *ExtensionBlocks; /* Extensions before image */
+} SavedImage;
+
 typedef struct GifFileType {
-    int SWidth, SHeight,        /* Screen dimensions. */
-      SColorResolution,         /* How many colors can we generate? */
-      SBackGroundColor;         /* I hope you understand this one... */
-    ColorMapObject *SColorMap;  /* NULL if not exists. */
-    int ImageCount;             /* Number of current image */
-    GifImageDesc Image;         /* Block describing current image */
-    struct SavedImage *SavedImages; /* Use this to accumulate file state */
-    VoidPtr UserData;           /* hook to attach user data (TVT) */
-    VoidPtr Private;            /* Don't mess with this! */
+    GifWord SWidth, SHeight;         /* Size of virtual canvas */
+    GifWord SColorResolution;        /* How many colors can we generate? */
+    GifWord SBackGroundColor;        /* Background color for virtual canvas */
+    GifByteType AspectByte;          /* Used to compute pixel aspect ratio */
+    ColorMapObject *SColorMap;       /* Global colormap, NULL if nonexistent. */
+    int ImageCount;                  /* Number of current image (both APIs) */
+    GifImageDesc Image;              /* Current image (low-level API) */
+    SavedImage *SavedImages;         /* Image sequence (high-level API) */
+    int ExtensionBlockCount;         /* Count extensions past last image */
+    ExtensionBlock *ExtensionBlocks; /* Extensions past last image */
+    int Error;                       /* Last error condition reported */
+    void *UserData;                  /* hook to attach user data (TVT) */
+    void *Private;                   /* Don't mess with this! */
 } GifFileType;
 
+#define GIF_ASPECT_RATIO(n)    ((n)+15.0/64.0)
+
 typedef enum {
     UNDEFINED_RECORD_TYPE,
     SCREEN_DESC_RECORD_TYPE,
@@ -120,58 +128,95 @@
     TERMINATE_RECORD_TYPE   /* Begin with ';' */
 } GifRecordType;
 
-/* DumpScreen2Gif routine constants identify type of window/screen to dump.
- * Note all values below 1000 are reserved for the IBMPC different display
- * devices (it has many!) and are compatible with the numbering TC2.0
- * (Turbo C 2.0 compiler for IBM PC) gives to these devices.
- */
-typedef enum {
-    GIF_DUMP_SGI_WINDOW = 1000,
-    GIF_DUMP_X_WINDOW = 1001
-} GifScreenDumpType;
-
 /* func type to read gif data from arbitrary sources (TVT) */
 typedef int (*InputFunc) (GifFileType *, GifByteType *, int);
 
-/* func type to write gif data ro arbitrary targets.
+/* func type to write gif data to arbitrary targets.
  * Returns count of bytes written. (MRB)
  */
 typedef int (*OutputFunc) (GifFileType *, const GifByteType *, int);
 
 /******************************************************************************
- *  GIF89 extension function codes
+ GIF89 structures
 ******************************************************************************/
 
-#define COMMENT_EXT_FUNC_CODE     0xfe    /* comment */
-#define GRAPHICS_EXT_FUNC_CODE    0xf9    /* graphics control */
-#define PLAINTEXT_EXT_FUNC_CODE   0x01    /* plaintext */
-#define APPLICATION_EXT_FUNC_CODE 0xff    /* application block */
+typedef struct GraphicsControlBlock {
+    int DisposalMode;
+#define DISPOSAL_UNSPECIFIED      0       /* No disposal specified. */
+#define DISPOSE_DO_NOT            1       /* Leave image in place */
+#define DISPOSE_BACKGROUND        2       /* Set area too background color */
+#define DISPOSE_PREVIOUS          3       /* Restore to previous content */
+    bool UserInputFlag;      /* User confirmation required before disposal */
+    int DelayTime;           /* pre-display delay in 0.01sec units */
+    int TransparentColor;    /* Palette index for transparency, -1 if none */
+#define NO_TRANSPARENT_COLOR    -1
+} GraphicsControlBlock;
 
 /******************************************************************************
- * O.K., here are the routines one can access in order to decode GIF file:
- * (GIF_LIB file DGIF_LIB.C).
- *****************************************************************************/
+ GIF encoding routines
+******************************************************************************/
+
+/* Main entry points */
+GifFileType *EGifOpenFileName(const char *GifFileName,
+                              const bool GifTestExistence, int *Error);
+GifFileType *EGifOpenFileHandle(const int GifFileHandle, int *Error);
+GifFileType *EGifOpen(void *userPtr, OutputFunc writeFunc, int *Error);
+int EGifSpew(GifFileType * GifFile);
+const char *EGifGetGifVersion(GifFileType *GifFile); /* new in 5.x */
+int EGifCloseFile(GifFileType *GifFile, int *ErrorCode);
+
+#define E_GIF_SUCCEEDED          0
+#define E_GIF_ERR_OPEN_FAILED    1    /* And EGif possible errors. */
+#define E_GIF_ERR_WRITE_FAILED   2
+#define E_GIF_ERR_HAS_SCRN_DSCR  3
+#define E_GIF_ERR_HAS_IMAG_DSCR  4
+#define E_GIF_ERR_NO_COLOR_MAP   5
+#define E_GIF_ERR_DATA_TOO_BIG   6
+#define E_GIF_ERR_NOT_ENOUGH_MEM 7
+#define E_GIF_ERR_DISK_IS_FULL   8
+#define E_GIF_ERR_CLOSE_FAILED   9
+#define E_GIF_ERR_NOT_WRITEABLE  10
 
-GifFileType *DGifOpenFileName(const char *GifFileName);
-GifFileType *DGifOpenFileHandle(int GifFileHandle);
-GifFileType *DGifOpen(void *userPtr, InputFunc readFunc);    /* new one
-                                                             * (TVT) */
+/* These are legacy.  You probably do not want to call them directly */
+int EGifPutScreenDesc(GifFileType *GifFile,
+                      const int GifWidth, const int GifHeight,
+                      const int GifColorRes,
+                      const int GifBackGround,
+                      const ColorMapObject *GifColorMap);
+int EGifPutImageDesc(GifFileType *GifFile,
+                     const int GifLeft, const int GifTop,
+                     const int GifWidth, const int GifHeight,
+                     const bool GifInterlace,
+                     const ColorMapObject *GifColorMap);
+void EGifSetGifVersion(GifFileType *GifFile, const bool gif89);
+int EGifPutLine(GifFileType *GifFile, GifPixelType *GifLine,
+                int GifLineLen);
+int EGifPutPixel(GifFileType *GifFile, const GifPixelType GifPixel);
+int EGifPutComment(GifFileType *GifFile, const char *GifComment);
+int EGifPutExtensionLeader(GifFileType *GifFile, const int GifExtCode);
+int EGifPutExtensionBlock(GifFileType *GifFile,
+                         const int GifExtLen, const void *GifExtension);
+int EGifPutExtensionTrailer(GifFileType *GifFile);
+int EGifPutExtension(GifFileType *GifFile, const int GifExtCode,
+                     const int GifExtLen,
+                     const void *GifExtension);
+int EGifPutCode(GifFileType *GifFile, int GifCodeSize,
+                const GifByteType *GifCodeBlock);
+int EGifPutCodeNext(GifFileType *GifFile,
+                    const GifByteType *GifCodeBlock);
+
+/******************************************************************************
+ GIF decoding routines
+******************************************************************************/
+
+/* Main entry points */
+GifFileType *DGifOpenFileName(const char *GifFileName, int *Error);
+GifFileType *DGifOpenFileHandle(int GifFileHandle, int *Error);
 int DGifSlurp(GifFileType * GifFile);
-int DGifGetScreenDesc(GifFileType * GifFile);
-int DGifGetRecordType(GifFileType * GifFile, GifRecordType * GifType);
-int DGifGetImageDesc(GifFileType * GifFile);
-int DGifGetLine(GifFileType * GifFile, GifPixelType * GifLine, int GifLineLen);
-int DGifGetPixel(GifFileType * GifFile, GifPixelType GifPixel);
-int DGifGetComment(GifFileType * GifFile, char *GifComment);
-int DGifGetExtension(GifFileType * GifFile, int *GifExtCode,
-                     GifByteType ** GifExtension);
-int DGifGetExtensionNext(GifFileType * GifFile, GifByteType ** GifExtension);
-int DGifGetCode(GifFileType * GifFile, int *GifCodeSize,
-                GifByteType ** GifCodeBlock);
-int DGifGetCodeNext(GifFileType * GifFile, GifByteType ** GifCodeBlock);
-int DGifGetLZCodes(GifFileType * GifFile, int *GifCode);
-int DGifCloseFile(GifFileType * GifFile);
+GifFileType *DGifOpen(void *userPtr, InputFunc readFunc, int *Error);    /* new one (TVT) */
+    int DGifCloseFile(GifFileType * GifFile, int *ErrorCode);
 
+#define D_GIF_SUCCEEDED          0
 #define D_GIF_ERR_OPEN_FAILED    101    /* And DGif possible errors. */
 #define D_GIF_ERR_READ_FAILED    102
 #define D_GIF_ERR_NOT_GIF_FILE   103
@@ -186,68 +231,105 @@
 #define D_GIF_ERR_IMAGE_DEFECT   112
 #define D_GIF_ERR_EOF_TOO_SOON   113
 
+/* These are legacy.  You probably do not want to call them directly */
+int DGifGetScreenDesc(GifFileType *GifFile);
+int DGifGetRecordType(GifFileType *GifFile, GifRecordType *GifType);
+int DGifGetImageHeader(GifFileType *GifFile);
+int DGifGetImageDesc(GifFileType *GifFile);
+int DGifGetLine(GifFileType *GifFile, GifPixelType *GifLine, int GifLineLen);
+int DGifGetPixel(GifFileType *GifFile, GifPixelType GifPixel);
+int DGifGetExtension(GifFileType *GifFile, int *GifExtCode,
+                     GifByteType **GifExtension);
+int DGifGetExtensionNext(GifFileType *GifFile, GifByteType **GifExtension);
+int DGifGetCode(GifFileType *GifFile, int *GifCodeSize,
+                GifByteType **GifCodeBlock);
+int DGifGetCodeNext(GifFileType *GifFile, GifByteType **GifCodeBlock);
+int DGifGetLZCodes(GifFileType *GifFile, int *GifCode);
+const char *DGifGetGifVersion(GifFileType *GifFile);
 
-/******************************************************************************
- * O.K., here are the routines from GIF_LIB file GIF_ERR.C.
-******************************************************************************/
-extern void PrintGifError(void);
-extern int GifLastError(void);
 
 /******************************************************************************
- * O.K., here are the routines from GIF_LIB file DEV2GIF.C.
+ Error handling and reporting.
 ******************************************************************************/
-extern int DumpScreen2Gif(const char *FileName,
-                          int ReqGraphDriver,
-                          long ReqGraphMode1,
-                          long ReqGraphMode2,
-                          long ReqGraphMode3);
+extern const char *GifErrorString(int ErrorCode);     /* new in 2012 - ESR */
 
 /*****************************************************************************
- *
- * Everything below this point is new after version 1.2, supporting `slurp
- * mode' for doing I/O in two big belts with all the image-bashing in core.
- *
- *****************************************************************************/
+ Everything below this point is new after version 1.2, supporting `slurp
+ mode' for doing I/O in two big belts with all the image-bashing in core.
+******************************************************************************/
+
+/******************************************************************************
+ Color map handling from gif_alloc.c
+******************************************************************************/
+
+extern ColorMapObject *GifMakeMapObject(int ColorCount,
+                                     const GifColorType *ColorMap);
+extern void GifFreeMapObject(ColorMapObject *Object);
+extern ColorMapObject *GifUnionColorMap(const ColorMapObject *ColorIn1,
+                                     const ColorMapObject *ColorIn2,
+                                     GifPixelType ColorTransIn2[]);
+extern int GifBitSize(int n);
 
 /******************************************************************************
- * Color Map handling from ALLOCGIF.C
- *****************************************************************************/
+ Support for the in-core structures allocation (slurp mode).
+******************************************************************************/
 
-extern ColorMapObject *MakeMapObject(int ColorCount,
-                                     const GifColorType * ColorMap);
-extern void FreeMapObject(ColorMapObject * Object);
-extern int BitSize(int n);
+extern void GifApplyTranslation(SavedImage *Image, GifPixelType Translation[]);
+extern int GifAddExtensionBlock(int *ExtensionBlock_Count,
+                                ExtensionBlock **ExtensionBlocks,
+                                int Function,
+                                unsigned int Len, unsigned char ExtData[]);
+extern void GifFreeExtensions(int *ExtensionBlock_Count,
+                              ExtensionBlock **ExtensionBlocks);
+extern SavedImage *GifMakeSavedImage(GifFileType *GifFile,
+                                  const SavedImage *CopyFrom);
+extern void GifFreeSavedImages(GifFileType *GifFile);
 
 /******************************************************************************
- * Support for the in-core structures allocation (slurp mode).
- *****************************************************************************/
+ 5.x functions for GIF89 graphics control blocks
+******************************************************************************/
+
+int DGifExtensionToGCB(const size_t GifExtensionLength,
+                       const GifByteType *GifExtension,
+                       GraphicsControlBlock *GCB);
+size_t EGifGCBToExtension(const GraphicsControlBlock *GCB,
+                          GifByteType *GifExtension);
 
-/* This is the in-core version of an extension record */
-typedef struct {
-    int ByteCount;
-    char *Bytes;    /* on malloc(3) heap */
-    int Function;   /* Holds the type of the Extension block. */
-} ExtensionBlock;
+int DGifSavedExtensionToGCB(GifFileType *GifFile,
+                            int ImageIndex,
+                            GraphicsControlBlock *GCB);
+int EGifGCBToSavedExtension(const GraphicsControlBlock *GCB,
+                            GifFileType *GifFile,
+                            int ImageIndex);
+
+/******************************************************************************
+ The library's internal utility font
+******************************************************************************/
 
-/* This holds an image header, its unpacked raster bits, and extensions */
-typedef struct SavedImage {
-    GifImageDesc ImageDesc;
-    unsigned char *RasterBits;  /* on malloc(3) heap */
-    int Function;   /* DEPRECATED: Use ExtensionBlocks[x].Function instead */
-    int ExtensionBlockCount;
-    ExtensionBlock *ExtensionBlocks;    /* on malloc(3) heap */
-} SavedImage;
+#define GIF_FONT_WIDTH  8
+#define GIF_FONT_HEIGHT 8
+extern const unsigned char GifAsciiTable8x8[][GIF_FONT_WIDTH];
+
+extern void GifDrawText8x8(SavedImage *Image,
+                     const int x, const int y,
+                     const char *legend, const int color);
 
-extern void MakeExtension(SavedImage * New, int Function);
-extern int AddExtensionBlock(SavedImage * New, int Len,
-                             unsigned char ExtData[]);
-extern void FreeExtension(SavedImage * Image);
-extern SavedImage *MakeSavedImage(GifFileType * GifFile,
-                                  const SavedImage * CopyFrom);
-extern void FreeSavedImages(GifFileType * GifFile);
+extern void GifDrawBox(SavedImage *Image,
+                    const int x, const int y,
+                    const int w, const int d, const int color);
 
+extern void GifDrawRectangle(SavedImage *Image,
+                   const int x, const int y,
+                   const int w, const int d, const int color);
+
+extern void GifDrawBoxedText8x8(SavedImage *Image,
+                          const int x, const int y,
+                          const char *legend,
+                          const int border, const int bg, const int fg);
 
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
 #endif /* _GIF_LIB_H */
+
+/* end */
--- a/src/share/native/sun/awt/giflib/gif_lib_private.h	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/native/sun/awt/giflib/gif_lib_private.h	Thu Sep 03 04:06:33 2020 +0100
@@ -22,21 +22,27 @@
  * questions.
  */
 
+/****************************************************************************
+
+gif_lib_private.h - internal giflib routines and structures
+
+SPDX-License-Identifier: MIT
+
+****************************************************************************/
+
 #ifndef _GIF_LIB_PRIVATE_H
 #define _GIF_LIB_PRIVATE_H
 
 #include "gif_lib.h"
-
-#define PROGRAM_NAME "LIBUNGIF"
+#include "gif_hash.h"
 
-#ifdef SYSV
-#define VersionStr "Gif library module,\t\tEric S. Raymond\n\
-                    (C) Copyright 1997 Eric S. Raymond\n"
-#else
-#define VersionStr PROGRAM_NAME "    IBMPC " GIF_LIB_VERSION \
-                    "    Eric S. Raymond,    " __DATE__ ",   " \
-                    __TIME__ "\n" "(C) Copyright 1997 Eric S. Raymond\n"
-#endif /* SYSV */
+#ifndef SIZE_MAX
+    #define SIZE_MAX     UINTPTR_MAX
+#endif
+
+#define EXTENSION_INTRODUCER      0x21
+#define DESCRIPTOR_INTRODUCER     0x2c
+#define TERMINATOR_INTRODUCER     0x3b
 
 #define LZ_MAX_CODE         4095    /* Biggest code possible in 12 bits. */
 #define LZ_BITS             12
@@ -54,7 +60,7 @@
 #define IS_WRITEABLE(Private)   (Private->FileState & FILE_STATE_WRITE)
 
 typedef struct GifFilePrivateType {
-    int FileState, FileHandle,  /* Where all this data goes to! */
+    GifWord FileState, FileHandle,  /* Where all this data goes to! */
       BitsPerPixel,     /* Bits per pixel (Codes uses at least this + 1). */
       ClearCode,   /* The CLEAR LZ code. */
       EOFCode,     /* The EOF LZ code. */
@@ -73,9 +79,16 @@
     GifByteType Buf[256];   /* Compressed input is buffered here. */
     GifByteType Stack[LZ_MAX_CODE]; /* Decoded pixels are stacked here. */
     GifByteType Suffix[LZ_MAX_CODE + 1];    /* So we can trace the codes. */
-    unsigned int Prefix[LZ_MAX_CODE + 1];
+    GifPrefixType Prefix[LZ_MAX_CODE + 1];
+    GifHashTableType *HashTable;
+    bool gif89;
 } GifFilePrivateType;
 
-extern int _GifError;
+#ifndef HAVE_REALLOCARRAY
+extern void *openbsd_reallocarray(void *optr, size_t nmemb, size_t size);
+#define reallocarray openbsd_reallocarray
+#endif
 
 #endif /* _GIF_LIB_PRIVATE_H */
+
+/* end */
--- a/src/share/native/sun/awt/giflib/gifalloc.c	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/native/sun/awt/giflib/gifalloc.c	Thu Sep 03 04:06:33 2020 +0100
@@ -23,36 +23,30 @@
  */
 
 /*****************************************************************************
- *   "Gif-Lib" - Yet another gif library.
- *
- * Written by:  Gershon Elber                Ver 0.1, Jun. 1989
- * Extensively hacked by: Eric S. Raymond        Ver 1.?, Sep 1992
- *****************************************************************************
- * GIF construction tools
- *****************************************************************************
- * History:
- * 15 Sep 92 - Version 1.0 by Eric Raymond.
- ****************************************************************************/
+
+ GIF construction tools
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+SPDX-License-Identifier: MIT
+
+****************************************************************************/
 
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+
 #include "gif_lib.h"
+#include "gif_lib_private.h"
 
 #define MAX(x, y)    (((x) > (y)) ? (x) : (y))
 
 /******************************************************************************
- * Miscellaneous utility functions
- *****************************************************************************/
+ Miscellaneous utility functions
+******************************************************************************/
 
 /* return smallest bitfield size n will fit in */
 int
-BitSize(int n) {
-
+GifBitSize(int n)
+{
     register int i;
 
     for (i = 1; i <= 8; i++)
@@ -62,22 +56,21 @@
 }
 
 /******************************************************************************
- * Color map object functions
- *****************************************************************************/
+  Color map object functions
+******************************************************************************/
 
 /*
  * Allocate a color map of given size; initialize with contents of
  * ColorMap if that pointer is non-NULL.
  */
 ColorMapObject *
-MakeMapObject(int ColorCount,
-              const GifColorType * ColorMap) {
-
+GifMakeMapObject(int ColorCount, const GifColorType *ColorMap)
+{
     ColorMapObject *Object;
 
     /*** FIXME: Our ColorCount has to be a power of two.  Is it necessary to
      * make the user know that or should we automatically round up instead? */
-    if (ColorCount != (1 << BitSize(ColorCount))) {
+    if (ColorCount != (1 << GifBitSize(ColorCount))) {
         return ((ColorMapObject *) NULL);
     }
 
@@ -93,9 +86,10 @@
     }
 
     Object->ColorCount = ColorCount;
-    Object->BitsPerPixel = BitSize(ColorCount);
+    Object->BitsPerPixel = GifBitSize(ColorCount);
+    Object->SortFlag = false;
 
-    if (ColorMap) {
+    if (ColorMap != NULL) {
         memcpy((char *)Object->Colors,
                (char *)ColorMap, ColorCount * sizeof(GifColorType));
     }
@@ -103,118 +97,222 @@
     return (Object);
 }
 
-/*
- * Free a color map object
- */
+/*******************************************************************************
+Free a color map object
+*******************************************************************************/
 void
-FreeMapObject(ColorMapObject * Object) {
-
+GifFreeMapObject(ColorMapObject *Object)
+{
     if (Object != NULL) {
-        free(Object->Colors);
-        free(Object);
-        Object = NULL;
+        (void)free(Object->Colors);
+        (void)free(Object);
     }
 }
 
 #ifdef DEBUG
 void
-DumpColorMap(ColorMapObject * Object,
-             FILE * fp) {
-
-    if (Object) {
+DumpColorMap(ColorMapObject *Object,
+             FILE * fp)
+{
+    if (Object != NULL) {
         int i, j, Len = Object->ColorCount;
 
         for (i = 0; i < Len; i += 4) {
             for (j = 0; j < 4 && j < Len; j++) {
-                fprintf(fp, "%3d: %02x %02x %02x   ", i + j,
-                        Object->Colors[i + j].Red,
-                        Object->Colors[i + j].Green,
-                        Object->Colors[i + j].Blue);
+                (void)fprintf(fp, "%3d: %02x %02x %02x   ", i + j,
+                              Object->Colors[i + j].Red,
+                              Object->Colors[i + j].Green,
+                              Object->Colors[i + j].Blue);
             }
-            fprintf(fp, "\n");
+            (void)fprintf(fp, "\n");
         }
     }
 }
 #endif /* DEBUG */
 
-/******************************************************************************
- * Extension record functions
- *****************************************************************************/
+/*******************************************************************************
+ Compute the union of two given color maps and return it.  If result can't
+ fit into 256 colors, NULL is returned, the allocated union otherwise.
+ ColorIn1 is copied as is to ColorUnion, while colors from ColorIn2 are
+ copied iff they didn't exist before.  ColorTransIn2 maps the old
+ ColorIn2 into the ColorUnion color map table./
+*******************************************************************************/
+ColorMapObject *
+GifUnionColorMap(const ColorMapObject *ColorIn1,
+              const ColorMapObject *ColorIn2,
+              GifPixelType ColorTransIn2[])
+{
+    int i, j, CrntSlot, RoundUpTo, NewGifBitSize;
+    ColorMapObject *ColorUnion;
+
+    /*
+     * We don't worry about duplicates within either color map; if
+     * the caller wants to resolve those, he can perform unions
+     * with an empty color map.
+     */
 
-void
-MakeExtension(SavedImage * New,
-              int Function) {
+    /* Allocate table which will hold the result for sure. */
+    ColorUnion = GifMakeMapObject(MAX(ColorIn1->ColorCount,
+                               ColorIn2->ColorCount) * 2, NULL);
+
+    if (ColorUnion == NULL)
+        return (NULL);
+
+    /*
+     * Copy ColorIn1 to ColorUnion.
+     */
+    for (i = 0; i < ColorIn1->ColorCount; i++)
+        ColorUnion->Colors[i] = ColorIn1->Colors[i];
+    CrntSlot = ColorIn1->ColorCount;
+
+    /*
+     * Potentially obnoxious hack:
+     *
+     * Back CrntSlot down past all contiguous {0, 0, 0} slots at the end
+     * of table 1.  This is very useful if your display is limited to
+     * 16 colors.
+     */
+    while (ColorIn1->Colors[CrntSlot - 1].Red == 0
+           && ColorIn1->Colors[CrntSlot - 1].Green == 0
+           && ColorIn1->Colors[CrntSlot - 1].Blue == 0)
+        CrntSlot--;
 
-    New->Function = Function;
-    /*** FIXME:
-     * Someday we might have to deal with multiple extensions.
-     * ??? Was this a note from Gershon or from me?  Does the multiple
-     * extension blocks solve this or do we need multiple Functions?  Or is
-     * this an obsolete function?  (People should use AddExtensionBlock
-     * instead?)
-     * Looks like AddExtensionBlock needs to take the int Function argument
-     * then it can take the place of this function.  Right now people have to
-     * use both.  Fix AddExtensionBlock and add this to the deprecation list.
-     */
+    /* Copy ColorIn2 to ColorUnion (use old colors if they exist): */
+    for (i = 0; i < ColorIn2->ColorCount && CrntSlot <= 256; i++) {
+        /* Let's see if this color already exists: */
+        for (j = 0; j < ColorIn1->ColorCount; j++)
+            if (memcmp (&ColorIn1->Colors[j], &ColorIn2->Colors[i],
+                        sizeof(GifColorType)) == 0)
+                break;
+
+        if (j < ColorIn1->ColorCount)
+            ColorTransIn2[i] = j;    /* color exists in Color1 */
+        else {
+            /* Color is new - copy it to a new slot: */
+            ColorUnion->Colors[CrntSlot] = ColorIn2->Colors[i];
+            ColorTransIn2[i] = CrntSlot++;
+        }
+    }
+
+    if (CrntSlot > 256) {
+        GifFreeMapObject(ColorUnion);
+        return ((ColorMapObject *) NULL);
+    }
+
+    NewGifBitSize = GifBitSize(CrntSlot);
+    RoundUpTo = (1 << NewGifBitSize);
+
+    if (RoundUpTo != ColorUnion->ColorCount) {
+        register GifColorType *Map = ColorUnion->Colors;
+
+        /*
+         * Zero out slots up to next power of 2.
+         * We know these slots exist because of the way ColorUnion's
+         * start dimension was computed.
+         */
+        for (j = CrntSlot; j < RoundUpTo; j++)
+            Map[j].Red = Map[j].Green = Map[j].Blue = 0;
+
+        /* perhaps we can shrink the map? */
+        if (RoundUpTo < ColorUnion->ColorCount) {
+            GifColorType *new_map = (GifColorType *)reallocarray(Map,
+                                 RoundUpTo, sizeof(GifColorType));
+            if( new_map == NULL ) {
+                GifFreeMapObject(ColorUnion);
+                return ((ColorMapObject *) NULL);
+            }
+            ColorUnion->Colors = new_map;
+        }
+    }
+
+    ColorUnion->ColorCount = RoundUpTo;
+    ColorUnion->BitsPerPixel = NewGifBitSize;
+
+    return (ColorUnion);
 }
 
+/*******************************************************************************
+ Apply a given color translation to the raster bits of an image
+*******************************************************************************/
+void
+GifApplyTranslation(SavedImage *Image, GifPixelType Translation[])
+{
+    register int i;
+    register int RasterSize = Image->ImageDesc.Height * Image->ImageDesc.Width;
+
+    for (i = 0; i < RasterSize; i++)
+        Image->RasterBits[i] = Translation[Image->RasterBits[i]];
+}
+
+/******************************************************************************
+ Extension record functions
+******************************************************************************/
 int
-AddExtensionBlock(SavedImage * New,
-                  int Len,
-                  unsigned char ExtData[]) {
-
+GifAddExtensionBlock(int *ExtensionBlockCount,
+                     ExtensionBlock **ExtensionBlocks,
+                     int Function,
+                     unsigned int Len,
+                     unsigned char ExtData[])
+{
     ExtensionBlock *ep;
 
-    if (New->ExtensionBlocks == NULL)
-        New->ExtensionBlocks=(ExtensionBlock *)malloc(sizeof(ExtensionBlock));
-    else
-        New->ExtensionBlocks = (ExtensionBlock *)realloc(New->ExtensionBlocks,
-                                      sizeof(ExtensionBlock) *
-                                      (New->ExtensionBlockCount + 1));
+    if (*ExtensionBlocks == NULL)
+        *ExtensionBlocks=(ExtensionBlock *)malloc(sizeof(ExtensionBlock));
+    else {
+        ExtensionBlock* ep_new = (ExtensionBlock *)reallocarray
+                                      (*ExtensionBlocks, (*ExtensionBlockCount + 1),
+                                      sizeof(ExtensionBlock));
+        if( ep_new == NULL )
+            return (GIF_ERROR);
+        *ExtensionBlocks = ep_new;
+    }
 
-    if (New->ExtensionBlocks == NULL)
+    if (*ExtensionBlocks == NULL)
         return (GIF_ERROR);
 
-    ep = &New->ExtensionBlocks[New->ExtensionBlockCount++];
+    ep = &(*ExtensionBlocks)[(*ExtensionBlockCount)++];
 
+    ep->Function = Function;
     ep->ByteCount=Len;
-    ep->Bytes = (char *)malloc(ep->ByteCount);
+    ep->Bytes = (GifByteType *)malloc(ep->ByteCount);
     if (ep->Bytes == NULL)
         return (GIF_ERROR);
 
-    if (ExtData) {
+    if (ExtData != NULL) {
         memcpy(ep->Bytes, ExtData, Len);
-        ep->Function = New->Function;
     }
 
     return (GIF_OK);
 }
 
 void
-FreeExtension(SavedImage * Image)
+GifFreeExtensions(int *ExtensionBlockCount,
+                  ExtensionBlock **ExtensionBlocks)
 {
     ExtensionBlock *ep;
 
-    if ((Image == NULL) || (Image->ExtensionBlocks == NULL)) {
+    if (*ExtensionBlocks == NULL)
         return;
-    }
-    for (ep = Image->ExtensionBlocks;
-         ep < (Image->ExtensionBlocks + Image->ExtensionBlockCount); ep++)
+
+    for (ep = *ExtensionBlocks;
+         ep < (*ExtensionBlocks + *ExtensionBlockCount);
+         ep++)
         (void)free((char *)ep->Bytes);
-    free((char *)Image->ExtensionBlocks);
-    Image->ExtensionBlocks = NULL;
+    (void)free((char *)*ExtensionBlocks);
+    *ExtensionBlocks = NULL;
+    *ExtensionBlockCount = 0;
 }
 
 /******************************************************************************
- * Image block allocation functions
+ Image block allocation functions
 ******************************************************************************/
 
 /* Private Function:
  * Frees the last image in the GifFile->SavedImages array
  */
 void
-FreeLastSavedImage(GifFileType *GifFile) {
-
+FreeLastSavedImage(GifFileType *GifFile)
+{
     SavedImage *sp;
 
     if ((GifFile == NULL) || (GifFile->SavedImages == NULL))
@@ -225,20 +323,21 @@
     sp = &GifFile->SavedImages[GifFile->ImageCount];
 
     /* Deallocate its Colormap */
-    if (sp->ImageDesc.ColorMap)
-        FreeMapObject(sp->ImageDesc.ColorMap);
+    if (sp->ImageDesc.ColorMap != NULL) {
+        GifFreeMapObject(sp->ImageDesc.ColorMap);
+        sp->ImageDesc.ColorMap = NULL;
+    }
 
     /* Deallocate the image data */
-    if (sp->RasterBits)
+    if (sp->RasterBits != NULL)
         free((char *)sp->RasterBits);
 
     /* Deallocate any extensions */
-    if (sp->ExtensionBlocks)
-        FreeExtension(sp);
+    GifFreeExtensions(&sp->ExtensionBlockCount, &sp->ExtensionBlocks);
 
     /*** FIXME: We could realloc the GifFile->SavedImages structure but is
      * there a point to it? Saves some memory but we'd have to do it every
-     * time.  If this is used in FreeSavedImages then it would be inefficient
+     * time.  If this is used in GifFreeSavedImages then it would be inefficient
      * (The whole array is going to be deallocated.)  If we just use it when
      * we want to free the last Image it's convenient to do it here.
      */
@@ -248,24 +347,23 @@
  * Append an image block to the SavedImages array
  */
 SavedImage *
-MakeSavedImage(GifFileType * GifFile,
-               const SavedImage * CopyFrom) {
-
-    SavedImage *sp;
-
+GifMakeSavedImage(GifFileType *GifFile, const SavedImage *CopyFrom)
+{
     if (GifFile->SavedImages == NULL)
         GifFile->SavedImages = (SavedImage *)malloc(sizeof(SavedImage));
-    else
-        GifFile->SavedImages = (SavedImage *)realloc(GifFile->SavedImages,
-                               sizeof(SavedImage) * (GifFile->ImageCount + 1));
-
+    else {
+        SavedImage* newSavedImages = (SavedImage *)reallocarray(GifFile->SavedImages,
+                               (GifFile->ImageCount + 1), sizeof(SavedImage));
+        if( newSavedImages == NULL)
+            return ((SavedImage *)NULL);
+        GifFile->SavedImages = newSavedImages;
+    }
     if (GifFile->SavedImages == NULL)
         return ((SavedImage *)NULL);
     else {
-        sp = &GifFile->SavedImages[GifFile->ImageCount++];
-        memset((char *)sp, '\0', sizeof(SavedImage));
+        SavedImage *sp = &GifFile->SavedImages[GifFile->ImageCount++];
 
-        if (CopyFrom) {
+        if (CopyFrom != NULL) {
             memcpy((char *)sp, CopyFrom, sizeof(SavedImage));
 
             /*
@@ -275,8 +373,8 @@
              */
 
             /* first, the local color map */
-            if (sp->ImageDesc.ColorMap) {
-                sp->ImageDesc.ColorMap = MakeMapObject(
+            if (CopyFrom->ImageDesc.ColorMap != NULL) {
+                sp->ImageDesc.ColorMap = GifMakeMapObject(
                                          CopyFrom->ImageDesc.ColorMap->ColorCount,
                                          CopyFrom->ImageDesc.ColorMap->Colors);
                 if (sp->ImageDesc.ColorMap == NULL) {
@@ -286,9 +384,10 @@
             }
 
             /* next, the raster */
-            sp->RasterBits = (unsigned char *)malloc(sizeof(GifPixelType) *
-                                                   CopyFrom->ImageDesc.Height *
-                                                   CopyFrom->ImageDesc.Width);
+            sp->RasterBits = (unsigned char *)reallocarray(NULL,
+                                                  (CopyFrom->ImageDesc.Height *
+                                                  CopyFrom->ImageDesc.Width),
+                                                  sizeof(GifPixelType));
             if (sp->RasterBits == NULL) {
                 FreeLastSavedImage(GifFile);
                 return (SavedImage *)(NULL);
@@ -298,37 +397,29 @@
                    CopyFrom->ImageDesc.Width);
 
             /* finally, the extension blocks */
-            if (sp->ExtensionBlocks) {
-                sp->ExtensionBlocks = (ExtensionBlock *)malloc(
-                                      sizeof(ExtensionBlock) *
-                                      CopyFrom->ExtensionBlockCount);
+            if (CopyFrom->ExtensionBlocks != NULL) {
+                sp->ExtensionBlocks = (ExtensionBlock *)reallocarray(NULL,
+                                      CopyFrom->ExtensionBlockCount,
+                                      sizeof(ExtensionBlock));
                 if (sp->ExtensionBlocks == NULL) {
                     FreeLastSavedImage(GifFile);
                     return (SavedImage *)(NULL);
                 }
                 memcpy(sp->ExtensionBlocks, CopyFrom->ExtensionBlocks,
                        sizeof(ExtensionBlock) * CopyFrom->ExtensionBlockCount);
-
-                /*
-                 * For the moment, the actual blocks can take their
-                 * chances with free().  We'll fix this later.
-                 *** FIXME: [Better check this out... Toshio]
-                 * 2004 May 27: Looks like this was an ESR note.
-                 * It means the blocks are shallow copied from InFile to
-                 * OutFile.  However, I don't see that in this code....
-                 * Did ESR fix it but never remove this note (And other notes
-                 * in gifspnge?)
-                 */
             }
         }
+        else {
+            memset((char *)sp, '\0', sizeof(SavedImage));
+        }
 
         return (sp);
     }
 }
 
 void
-FreeSavedImages(GifFileType * GifFile) {
-
+GifFreeSavedImages(GifFileType *GifFile)
+{
     SavedImage *sp;
 
     if ((GifFile == NULL) || (GifFile->SavedImages == NULL)) {
@@ -336,15 +427,18 @@
     }
     for (sp = GifFile->SavedImages;
          sp < GifFile->SavedImages + GifFile->ImageCount; sp++) {
-        if (sp->ImageDesc.ColorMap)
-            FreeMapObject(sp->ImageDesc.ColorMap);
+        if (sp->ImageDesc.ColorMap != NULL) {
+            GifFreeMapObject(sp->ImageDesc.ColorMap);
+            sp->ImageDesc.ColorMap = NULL;
+        }
 
-        if (sp->RasterBits)
+        if (sp->RasterBits != NULL)
             free((char *)sp->RasterBits);
 
-        if (sp->ExtensionBlocks)
-            FreeExtension(sp);
+        GifFreeExtensions(&sp->ExtensionBlockCount, &sp->ExtensionBlocks);
     }
     free((char *)GifFile->SavedImages);
-    GifFile->SavedImages=NULL;
+    GifFile->SavedImages = NULL;
 }
+
+/* end */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/native/sun/awt/giflib/openbsd-reallocarray.c	Thu Sep 03 04:06:33 2020 +0100
@@ -0,0 +1,99 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*    $OpenBSD: reallocarray.c,v 1.1 2014/05/08 21:43:49 deraadt Exp $    */
+/*
+ * Copyright (c) 2008 Otto Moerbeek <otto@drijf.net>
+ * SPDX-License-Identifier: MIT
+ */
+
+#include <sys/types.h>
+#include <errno.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#ifndef SIZE_MAX
+    #define SIZE_MAX     UINTPTR_MAX
+#endif
+
+/*
+ * This is sqrt(SIZE_MAX+1), as s1*s2 <= SIZE_MAX
+ * if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW
+ */
+#define MUL_NO_OVERFLOW    ((size_t)1 << (sizeof(size_t) * 4))
+
+void *
+openbsd_reallocarray(void *optr, size_t nmemb, size_t size)
+{
+    if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
+        nmemb > 0 && SIZE_MAX / nmemb < size) {
+        errno = ENOMEM;
+        return NULL;
+    }
+    /*
+     * Head off variations in realloc behavior on different
+     * platforms (reported by MarkR <mrogers6@users.sf.net>)
+     *
+     * The behaviour of reallocarray is implementation-defined if
+     * nmemb or size is zero. It can return NULL or non-NULL
+     * depending on the platform.
+     * https://www.securecoding.cert.org/confluence/display/c/MEM04-C.Beware+of+zero-lengthallocations
+     *
+     * Here are some extracts from realloc man pages on different platforms.
+     *
+     * void realloc( void memblock, size_t size );
+     *
+     * Windows:
+     *
+     * If there is not enough available memory to expand the block
+     * to the given size, the original block is left unchanged,
+     * and NULL is returned.  If size is zero, then the block
+     * pointed to by memblock is freed; the return value is NULL,
+     * and memblock is left pointing at a freed block.
+     *
+     * OpenBSD:
+     *
+     * If size or nmemb is equal to 0, a unique pointer to an
+     * access protected, zero sized object is returned. Access via
+     * this pointer will generate a SIGSEGV exception.
+     *
+     * Linux:
+     *
+     * If size was equal to 0, either NULL or a pointer suitable
+     * to be passed to free() is returned.
+     *
+     * OS X:
+     *
+     * If size is zero and ptr is not NULL, a new, minimum sized
+     * object is allocated and the original object is freed.
+     *
+     * It looks like images with zero width or height can trigger
+     * this, and fuzzing behaviour will differ by platform, so
+     * fuzzing on one platform may not detect zero-size allocation
+     * problems on other platforms.
+     */
+    if (size == 0 || nmemb == 0)
+        return NULL;
+    return realloc(optr, size * nmemb);
+}
--- a/src/share/native/sun/awt/image/BufImgSurfaceData.c	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/native/sun/awt/image/BufImgSurfaceData.c	Thu Sep 03 04:06:33 2020 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -294,6 +294,7 @@
         CHECK_NULL_RETURN(pRgb, (ColorData*)NULL);
         cData->img_clr_tbl = initCubemap(pRgb, bisdo->lutsize, 32);
         if (cData->img_clr_tbl == NULL) {
+            (*env)->ReleasePrimitiveArrayCritical(env, bisdo->lutarray, pRgb, JNI_ABORT);
             free(cData);
             return (ColorData*)NULL;
         }
--- a/src/share/native/sun/awt/libpng/CHANGES	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/native/sun/awt/libpng/CHANGES	Thu Sep 03 04:06:33 2020 +0100
@@ -6063,9 +6063,47 @@
   Added missing parentheses to a macro definition
     (suggested by "irwir" in GitHub issue #216)
 
-Send comments/corrections/commendations to png-mng-implement at lists.sf.net
-(subscription required; visit
+Version 1.6.36 [December 1, 2018]
+  Optimized png_do_expand_palette for ARM processors.
+  Improved performance by around 10-22% on a recent ARM Chromebook.
+    (Contributed by Richard Townsend, ARM Holdings)
+  Fixed manipulation of machine-specific optimization options.
+    (Contributed by Vicki Pfau)
+  Used memcpy instead of manual pointer arithmetic on Intel SSE2.
+    (Contributed by Samuel Williams)
+  Fixed build errors with MSVC on ARM64.
+    (Contributed by Zhijie Liang)
+  Fixed detection of libm in CMakeLists.
+    (Contributed by Cameron Cawley)
+  Fixed incorrect creation of pkg-config file in CMakeLists.
+    (Contributed by Kyle Bentley)
+  Fixed the CMake build on Windows MSYS by avoiding symlinks.
+  Fixed a build warning on OpenBSD.
+    (Contributed by Theo Buehler)
+  Fixed various typos in comments.
+    (Contributed by "luz.paz")
+  Raised the minimum required CMake version from 3.0.2 to 3.1.
+  Removed yet more of the vestigial support for pre-ANSI C compilers.
+  Removed ancient makefiles for ancient systems that have been broken
+    across all previous libpng-1.6.x versions.
+  Removed the Y2K compliance statement and the export control
+    information.
+  Applied various code style and documentation fixes.
+
+Version 1.6.37 [April 14, 2019]
+  Fixed a use-after-free vulnerability (CVE-2019-7317) in png_image_free.
+  Fixed a memory leak in the ARM NEON implementation of png_do_expand_palette.
+  Fixed a memory leak in pngtest.c.
+  Fixed two vulnerabilities (CVE-2018-14048, CVE-2018-14550) in
+    contrib/pngminus; refactor.
+  Changed the license of contrib/pngminus to MIT; refresh makefile and docs.
+    (Contributed by Willem van Schaik)
+  Fixed a typo in the libpng license v2.
+    (Contributed by Miguel Ojeda)
+  Added makefiles for AddressSanitizer-enabled builds.
+  Cleaned up various makefiles.
+
+Send comments/corrections/commendations to png-mng-implement at lists.sf.net.
+Subscription is required; visit
 https://lists.sourceforge.net/lists/listinfo/png-mng-implement
-to subscribe).
-
-Glenn R-P
+to subscribe.
--- a/src/share/native/sun/awt/libpng/LICENSE	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/native/sun/awt/libpng/LICENSE	Thu Sep 03 04:06:33 2020 +0100
@@ -1,53 +1,82 @@
+COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
+=========================================
 
-This copy of the libpng notices is provided for your convenience.  In case of
-any discrepancy between this copy and the notices in the file png.h that is
-included in the libpng distribution, the latter shall prevail.
+PNG Reference Library License version 2
+---------------------------------------
 
-COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
+ * Copyright (c) 1995-2019 The PNG Reference Library Authors.
+ * Copyright (c) 2018-2019 Cosmin Truta.
+ * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
+ * Copyright (c) 1996-1997 Andreas Dilger.
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
 
-If you modify libpng you may insert additional notices immediately following
-this sentence.
+The software is supplied "as is", without warranty of any kind,
+express or implied, including, without limitation, the warranties
+of merchantability, fitness for a particular purpose, title, and
+non-infringement.  In no event shall the Copyright owners, or
+anyone distributing the software, be liable for any damages or
+other liability, whether in contract, tort or otherwise, arising
+from, out of, or in connection with the software, or the use or
+other dealings in the software, even if advised of the possibility
+of such damage.
+
+Permission is hereby granted to use, copy, modify, and distribute
+this software, or portions hereof, for any purpose, without fee,
+subject to the following restrictions:
 
-This code is released under the libpng license.
+ 1. The origin of this software must not be misrepresented; you
+    must not claim that you wrote the original software.  If you
+    use this software in a product, an acknowledgment in the product
+    documentation would be appreciated, but is not required.
+
+ 2. Altered source versions must be plainly marked as such, and must
+    not be misrepresented as being the original software.
 
-libpng versions 1.0.7, July 1, 2000 through 1.6.35, July 15, 2018 are
+ 3. This Copyright notice may not be removed or altered from any
+    source or altered source distribution.
+
+
+PNG Reference Library License version 1 (for libpng 0.5 through 1.6.35)
+-----------------------------------------------------------------------
+
+libpng versions 1.0.7, July 1, 2000, through 1.6.35, July 15, 2018 are
 Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson, are
 derived from libpng-1.0.6, and are distributed according to the same
 disclaimer and license as libpng-1.0.6 with the following individuals
 added to the list of Contributing Authors:
 
-   Simon-Pierre Cadieux
-   Eric S. Raymond
-   Mans Rullgard
-   Cosmin Truta
-   Gilles Vollant
-   James Yu
-   Mandar Sahastrabuddhe
-   Google Inc.
-   Vadim Barkov
+    Simon-Pierre Cadieux
+    Eric S. Raymond
+    Mans Rullgard
+    Cosmin Truta
+    Gilles Vollant
+    James Yu
+    Mandar Sahastrabuddhe
+    Google Inc.
+    Vadim Barkov
 
 and with the following additions to the disclaimer:
 
-   There is no warranty against interference with your enjoyment of the
-   library or against infringement.  There is no warranty that our
-   efforts or the library will fulfill any of your particular purposes
-   or needs.  This library is provided with all faults, and the entire
-   risk of satisfactory quality, performance, accuracy, and effort is with
-   the user.
+    There is no warranty against interference with your enjoyment of
+    the library or against infringement.  There is no warranty that our
+    efforts or the library will fulfill any of your particular purposes
+    or needs.  This library is provided with all faults, and the entire
+    risk of satisfactory quality, performance, accuracy, and effort is
+    with the user.
 
 Some files in the "contrib" directory and some configure-generated
-files that are distributed with libpng have other copyright owners and
+files that are distributed with libpng have other copyright owners, and
 are released under other open source licenses.
 
 libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
 Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
 libpng-0.96, and are distributed according to the same disclaimer and
-license as libpng-0.96, with the following individuals added to the list
-of Contributing Authors:
+license as libpng-0.96, with the following individuals added to the
+list of Contributing Authors:
 
-   Tom Lane
-   Glenn Randers-Pehrson
-   Willem van Schaik
+    Tom Lane
+    Glenn Randers-Pehrson
+    Willem van Schaik
 
 libpng versions 0.89, June 1996, through 0.96, May 1997, are
 Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
@@ -55,14 +84,14 @@
 libpng-0.88, with the following individuals added to the list of
 Contributing Authors:
 
-   John Bowler
-   Kevin Bracey
-   Sam Bushell
-   Magnus Holmgren
-   Greg Roelofs
-   Tom Tanner
+    John Bowler
+    Kevin Bracey
+    Sam Bushell
+    Magnus Holmgren
+    Greg Roelofs
+    Tom Tanner
 
-Some files in the "scripts" directory have other copyright owners
+Some files in the "scripts" directory have other copyright owners,
 but are released under this license.
 
 libpng versions 0.5, May 1995, through 0.88, January 1996, are
@@ -71,63 +100,35 @@
 For the purposes of this copyright and license, "Contributing Authors"
 is defined as the following set of individuals:
 
-   Andreas Dilger
-   Dave Martindale
-   Guy Eric Schalnat
-   Paul Schmidt
-   Tim Wegner
+    Andreas Dilger
+    Dave Martindale
+    Guy Eric Schalnat
+    Paul Schmidt
+    Tim Wegner
 
-The PNG Reference Library is supplied "AS IS".  The Contributing Authors
-and Group 42, Inc. disclaim all warranties, expressed or implied,
-including, without limitation, the warranties of merchantability and of
-fitness for any purpose.  The Contributing Authors and Group 42, Inc.
-assume no liability for direct, indirect, incidental, special, exemplary,
-or consequential damages, which may result from the use of the PNG
-Reference Library, even if advised of the possibility of such damage.
+The PNG Reference Library is supplied "AS IS".  The Contributing
+Authors and Group 42, Inc. disclaim all warranties, expressed or
+implied, including, without limitation, the warranties of
+merchantability and of fitness for any purpose.  The Contributing
+Authors and Group 42, Inc. assume no liability for direct, indirect,
+incidental, special, exemplary, or consequential damages, which may
+result from the use of the PNG Reference Library, even if advised of
+the possibility of such damage.
 
 Permission is hereby granted to use, copy, modify, and distribute this
 source code, or portions hereof, for any purpose, without fee, subject
 to the following restrictions:
 
-  1. The origin of this source code must not be misrepresented.
-
-  2. Altered versions must be plainly marked as such and must not
-     be misrepresented as being the original source.
-
-  3. This Copyright notice may not be removed or altered from any
-     source or altered source distribution.
+ 1. The origin of this source code must not be misrepresented.
 
-The Contributing Authors and Group 42, Inc. specifically permit, without
-fee, and encourage the use of this source code as a component to
-supporting the PNG file format in commercial products.  If you use this
-source code in a product, acknowledgment is not required but would be
-appreciated.
-
-END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
-
-TRADEMARK:
+ 2. Altered versions must be plainly marked as such and must not
+    be misrepresented as being the original source.
 
-The name "libpng" has not been registered by the Copyright owner
-as a trademark in any jurisdiction.  However, because libpng has
-been distributed and maintained world-wide, continually since 1995,
-the Copyright owner claims "common-law trademark protection" in any
-jurisdiction where common-law trademark is recognized.
-
-OSI CERTIFICATION:
-
-Libpng is OSI Certified Open Source Software.  OSI Certified Open Source is
-a certification mark of the Open Source Initiative. OSI has not addressed
-the additional disclaimers inserted at version 1.0.7.
+ 3. This Copyright notice may not be removed or altered from any
+    source or altered source distribution.
 
-EXPORT CONTROL:
-
-The Copyright owner believes that the Export Control Classification
-Number (ECCN) for libpng is EAR99, which means not subject to export
-controls or International Traffic in Arms Regulations (ITAR) because
-it is open source, publicly available software, that does not contain
-any encryption software.  See the EAR, paragraphs 734.3(b)(3) and
-734.7(b).
-
-Glenn Randers-Pehrson
-glennrp at users.sourceforge.net
-July 15, 2018
+The Contributing Authors and Group 42, Inc. specifically permit,
+without fee, and encourage the use of this source code as a component
+to supporting the PNG file format in commercial products.  If you use
+this source code in a product, acknowledgment is not required but would
+be appreciated.
--- a/src/share/native/sun/awt/libpng/README	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/native/sun/awt/libpng/README	Thu Sep 03 04:06:33 2020 +0100
@@ -1,15 +1,16 @@
-README for libpng version 1.6.35 - July 15, 2018 (shared library 16.0)
-See the note about version numbers near the top of png.h
+README for libpng version 1.6.37 - April 14, 2019
+=================================================
 
+See the note about version numbers near the top of png.h.
 See INSTALL for instructions on how to install libpng.
 
 Libpng comes in several distribution formats.  Get libpng-*.tar.gz or
-libpng-*.tar.xz or if you want UNIX-style line endings in the text files,
-or lpng*.7z or lpng*.zip if you want DOS-style line endings.
+libpng-*.tar.xz or if you want UNIX-style line endings in the text
+files, or lpng*.7z or lpng*.zip if you want DOS-style line endings.
 
 Version 0.89 was the first official release of libpng.  Don't let the
-fact that it's the first release fool you.  The libpng library has been in
-extensive use and testing since mid-1995.  By late 1997 it had
+fact that it's the first release fool you.  The libpng library has been
+in extensive use and testing since mid-1995.  By late 1997 it had
 finally gotten to the stage where there hadn't been significant
 changes to the API in some time, and people have a bad feeling about
 libraries with versions < 1.0.  Version 1.0.0 was released in
@@ -60,59 +61,37 @@
 to set different actions based on whether the CRC error occurred in a
 critical or an ancillary chunk.
 
-The changes made to the library, and bugs fixed are based on discussions
-on the PNG-implement mailing list and not on material submitted
-privately to Guy, Andreas, or Glenn.  They will forward any good
-suggestions to the list.
-
-For a detailed description on using libpng, read libpng-manual.txt.  For
-examples of libpng in a program, see example.c and pngtest.c.  For usage
-information and restrictions (what little they are) on libpng, see
-png.h.  For a description on using zlib (the compression library used by
-libpng) and zlib's restrictions, see zlib.h
+For a detailed description on using libpng, read libpng-manual.txt.
+For examples of libpng in a program, see example.c and pngtest.c.  For
+usage information and restrictions (what little they are) on libpng,
+see png.h.  For a description on using zlib (the compression library
+used by libpng) and zlib's restrictions, see zlib.h
 
 I have included a general makefile, as well as several machine and
-compiler specific ones, but you may have to modify one for your own needs.
+compiler specific ones, but you may have to modify one for your own
+needs.
 
 You should use zlib 1.0.4 or later to run this, but it MAY work with
 versions as old as zlib 0.95.  Even so, there are bugs in older zlib
 versions which can cause the output of invalid compression streams for
-some images.  You will definitely need zlib 1.0.4 or later if you are
-taking advantage of the MS-DOS "far" structure allocation for the small
-and medium memory models.  You should also note that zlib is a
-compression library that is useful for more things than just PNG files.
-You can use zlib as a drop-in replacement for fread() and fwrite() if
-you are so inclined.
+some images.
 
-zlib should be available at the same place that libpng is, or at zlib.net.
+You should also note that zlib is a compression library that is useful
+for more things than just PNG files.  You can use zlib as a drop-in
+replacement for fread() and fwrite(), if you are so inclined.
+
+zlib should be available at the same place that libpng is, or at
+https://zlib.net.
 
 You may also want a copy of the PNG specification.  It is available
 as an RFC, a W3C Recommendation, and an ISO/IEC Standard.  You can find
 these at http://www.libpng.org/pub/png/pngdocs.html .
 
 This code is currently being archived at libpng.sourceforge.io in the
-[DOWNLOAD] area, and at http://libpng.download/src .  If you
-can't find it in any of those places, e-mail me, and I'll help you find it.
-
-I am not a lawyer, but I believe that the Export Control Classification
-Number (ECCN) for libpng is EAR99, which means not subject to export
-controls or International Traffic in Arms Regulations (ITAR) because it
-is open source, publicly available software, that does not contain any
-encryption software.  See the EAR, paragraphs 734.3(b)(3) and 734.7(b).
+[DOWNLOAD] area, and at http://libpng.download/src .
 
-If you have any code changes, requests, problems, etc., please e-mail
-them to me.  Also, I'd appreciate any make files or project files,
-and any modifications you needed to make to get libpng to compile,
-along with a #define variable to tell what compiler/system you are on.
-If you needed to add transformations to libpng, or wish libpng would
-provide the image in a different way, drop me a note (and code, if
-possible), so I can consider supporting the transformation.
-Finally, if you get any warning messages when compiling libpng
-(note: not zlib), and they are easy to fix, I'd appreciate the
-fix.  Please mention "libpng" somewhere in the subject line.  Thanks.
-
-This release was created and will be supported by myself (of course
-based in a large way on Guy's and Andreas' earlier work), and the PNG
+This release, based in a large way on Glenn's, Guy's and Andreas'
+earlier work, was created and will be supported by myself and the PNG
 development group.
 
 Send comments/corrections/commendations to png-mng-implement at
@@ -120,34 +99,21 @@
 https://lists.sourceforge.net/lists/listinfo/png-mng-implement
 to subscribe).
 
-You can't reach Guy, the original libpng author, at the addresses
-given in previous versions of this document.  He and Andreas will
-read mail addressed to the png-implement list, however.
-
-Please do not send general questions about PNG.  Send them to
-png-mng-misc at lists.sf.net (subscription required; visit
+Send general questions about the PNG specification to png-mng-misc
+at lists.sourceforge.net (subscription required; visit
 https://lists.sourceforge.net/lists/listinfo/png-mng-misc to
-subscribe).  If you have a question about something
-in the PNG specification that is related to using libpng, send it
-to me.  Send me any questions that start with "I was using libpng,
-and ...".  If in doubt, send questions to me.  I'll bounce them
-to others, if necessary.
-
-Please do not send suggestions on how to change PNG.  We have
-been discussing PNG for twenty years now, and it is official and
-finished.  If you have suggestions for libpng, however, I'll
-gladly listen.  Even if your suggestion is not used immediately,
-it may be used later.
+subscribe).
 
 Files in this distribution:
 
       ANNOUNCE      =>  Announcement of this version, with recent changes
+      AUTHORS       =>  List of contributing authors
       CHANGES       =>  Description of changes between libpng versions
       KNOWNBUG      =>  List of known bugs and deficiencies
       LICENSE       =>  License to use and redistribute libpng
       README        =>  This file
       TODO          =>  Things not implemented in the current library
-      Y2KINFO       =>  Statement of Y2K compliance
+      TRADEMARK     =>  Trademark information
       example.c     =>  Example code for using libpng functions
       libpng.3      =>  manual page for libpng (includes libpng-manual.txt)
       libpng-manual.txt  =>  Description of libpng and its functions
@@ -208,15 +174,10 @@
       scripts       =>  Directory containing scripts for building libpng:
                             (see scripts/README.txt for the list of scripts)
 
-Good luck, and happy coding.
-
--Glenn Randers-Pehrson (current maintainer, since 1998)
- Internet: glennrp at users.sourceforge.net
+Good luck, and happy coding!
 
--Andreas Eric Dilger (former maintainer, 1996-1997)
- Internet: adilger at enel.ucalgary.ca
- Web: http://www-mddsp.enel.ucalgary.ca/People/adilger/
-
--Guy Eric Schalnat (original author and former maintainer, 1995-1996)
- (formerly of Group 42, Inc)
- Internet: gschal at infinet.com
+ * Cosmin Truta (current maintainer, since 2018)
+ * Glenn Randers-Pehrson (former maintainer, 1998-2018)
+ * Andreas Eric Dilger (former maintainer, 1996-1997)
+ * Guy Eric Schalnat (original author and former maintainer, 1995-1996)
+   (formerly of Group 42, Inc.)
--- a/src/share/native/sun/awt/libpng/png.c	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/native/sun/awt/libpng/png.c	Thu Sep 03 04:06:33 2020 +0100
@@ -29,10 +29,10 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.35 [July 15, 2018]
+ * Copyright (c) 2018-2019 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
@@ -42,7 +42,7 @@
 #include "pngpriv.h"
 
 /* Generate a compiler error if there is an old png.h in the search path. */
-typedef png_libpng_version_1_6_35 Your_png_h_is_not_version_1_6_35;
+typedef png_libpng_version_1_6_37 Your_png_h_is_not_version_1_6_37;
 
 #ifdef __GNUC__
 /* The version tests may need to be added to, but the problem warning has
@@ -764,7 +764,7 @@
 int PNGAPI
 png_convert_to_rfc1123_buffer(char out[29], png_const_timep ptime)
 {
-   static PNG_CONST char short_months[12][4] =
+   static const char short_months[12][4] =
         {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
          "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
 
@@ -842,20 +842,14 @@
 #ifdef PNG_STRING_COPYRIGHT
    return PNG_STRING_COPYRIGHT
 #else
-#  ifdef __STDC__
    return PNG_STRING_NEWLINE \
-      "libpng version 1.6.35 - July 15, 2018" PNG_STRING_NEWLINE \
+      "libpng version 1.6.37" PNG_STRING_NEWLINE \
+      "Copyright (c) 2018-2019 Cosmin Truta" PNG_STRING_NEWLINE \
       "Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson" \
       PNG_STRING_NEWLINE \
       "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
       "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
       PNG_STRING_NEWLINE;
-#  else
-   return "libpng version 1.6.35 - July 15, 2018\
-      Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson\
-      Copyright (c) 1996-1997 Andreas Dilger\
-      Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
-#  endif
 #endif
 }
 
@@ -1149,7 +1143,7 @@
     png_colorspacerp colorspace, png_fixed_point gAMA)
 {
    /* Changed in libpng-1.5.4 to limit the values to ensure overflow can't
-    * occur.  Since the fixed point representation is asymetrical it is
+    * occur.  Since the fixed point representation is asymmetrical it is
     * possible for 1/gamma to overflow the limit of 21474 and this means the
     * gamma value must be at least 5/100000 and hence at most 20000.0.  For
     * safety the limits here are a little narrower.  The values are 0.00016 to
@@ -3162,11 +3156,11 @@
             /* The total output count (max) is now 4+precision */
 
             /* Check for an exponent, if we don't need one we are
-             * done and just need to terminate the string.  At
-             * this point exp_b10==(-1) is effectively a flag - it got
-             * to '-1' because of the decrement after outputting
-             * the decimal point above (the exponent required is
-             * *not* -1!)
+             * done and just need to terminate the string.  At this
+             * point, exp_b10==(-1) is effectively a flag: it got
+             * to '-1' because of the decrement, after outputting
+             * the decimal point above. (The exponent required is
+             * *not* -1.)
              */
             if (exp_b10 >= (-1) && exp_b10 <= 2)
             {
@@ -4004,18 +3998,18 @@
  */
 static void
 png_build_16bit_table(png_structrp png_ptr, png_uint_16pp *ptable,
-    PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val)
+    unsigned int shift, png_fixed_point gamma_val)
 {
    /* Various values derived from 'shift': */
-   PNG_CONST unsigned int num = 1U << (8U - shift);
+   unsigned int num = 1U << (8U - shift);
 #ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
    /* CSE the division and work round wacky GCC warnings (see the comments
     * in png_gamma_8bit_correct for where these come from.)
     */
-   PNG_CONST double fmax = 1./(((png_int_32)1 << (16U - shift))-1);
+   double fmax = 1.0 / (((png_int_32)1 << (16U - shift)) - 1);
 #endif
-   PNG_CONST unsigned int max = (1U << (16U - shift))-1U;
-   PNG_CONST unsigned int max_by_2 = 1U << (15U-shift);
+   unsigned int max = (1U << (16U - shift)) - 1U;
+   unsigned int max_by_2 = 1U << (15U - shift);
    unsigned int i;
 
    png_uint_16pp table = *ptable =
@@ -4081,10 +4075,10 @@
  */
 static void
 png_build_16to8_table(png_structrp png_ptr, png_uint_16pp *ptable,
-    PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val)
+    unsigned int shift, png_fixed_point gamma_val)
 {
-   PNG_CONST unsigned int num = 1U << (8U - shift);
-   PNG_CONST unsigned int max = (1U << (16U - shift))-1U;
+   unsigned int num = 1U << (8U - shift);
+   unsigned int max = (1U << (16U - shift))-1U;
    unsigned int i;
    png_uint_32 last;
 
@@ -4149,7 +4143,7 @@
  */
 static void
 png_build_8bit_table(png_structrp png_ptr, png_bytepp ptable,
-    PNG_CONST png_fixed_point gamma_val)
+    png_fixed_point gamma_val)
 {
    unsigned int i;
    png_bytep table = *ptable = (png_bytep)png_malloc(png_ptr, 256);
--- a/src/share/native/sun/awt/libpng/png.h	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/native/sun/awt/libpng/png.h	Thu Sep 03 04:06:33 2020 +0100
@@ -29,68 +29,105 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * libpng version 1.6.35, July 15, 2018
+ * libpng version 1.6.37 - April 14, 2019
  *
+ * Copyright (c) 2018-2019 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
- * This code is released under the libpng license (See LICENSE, below)
+ * This code is released under the libpng license. (See LICENSE, below.)
  *
  * Authors and maintainers:
  *   libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
  *   libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
- *   libpng versions 0.97, January 1998, through 1.6.35, July 15, 2018:
- *     Glenn Randers-Pehrson.
+ *   libpng versions 0.97, January 1998, through 1.6.35, July 2018:
+ *     Glenn Randers-Pehrson
+ *   libpng versions 1.6.36, December 2018, through 1.6.37, April 2019:
+ *     Cosmin Truta
  *   See also "Contributing Authors", below.
  */
 
 /*
- * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
+ * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
+ * =========================================
+ *
+ * PNG Reference Library License version 2
+ * ---------------------------------------
+ *
+ *  * Copyright (c) 1995-2019 The PNG Reference Library Authors.
+ *  * Copyright (c) 2018-2019 Cosmin Truta.
+ *  * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
+ *  * Copyright (c) 1996-1997 Andreas Dilger.
+ *  * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
- * If you modify libpng you may insert additional notices immediately following
- * this sentence.
+ * The software is supplied "as is", without warranty of any kind,
+ * express or implied, including, without limitation, the warranties
+ * of merchantability, fitness for a particular purpose, title, and
+ * non-infringement.  In no event shall the Copyright owners, or
+ * anyone distributing the software, be liable for any damages or
+ * other liability, whether in contract, tort or otherwise, arising
+ * from, out of, or in connection with the software, or the use or
+ * other dealings in the software, even if advised of the possibility
+ * of such damage.
+ *
+ * Permission is hereby granted to use, copy, modify, and distribute
+ * this software, or portions hereof, for any purpose, without fee,
+ * subject to the following restrictions:
  *
- * This code is released under the libpng license.
+ *  1. The origin of this software must not be misrepresented; you
+ *     must not claim that you wrote the original software.  If you
+ *     use this software in a product, an acknowledgment in the product
+ *     documentation would be appreciated, but is not required.
+ *
+ *  2. Altered source versions must be plainly marked as such, and must
+ *     not be misrepresented as being the original software.
  *
- * libpng versions 1.0.7, July 1, 2000 through 1.6.35, July 15, 2018 are
+ *  3. This Copyright notice may not be removed or altered from any
+ *     source or altered source distribution.
+ *
+ *
+ * PNG Reference Library License version 1 (for libpng 0.5 through 1.6.35)
+ * -----------------------------------------------------------------------
+ *
+ * libpng versions 1.0.7, July 1, 2000, through 1.6.35, July 15, 2018 are
  * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson, are
  * derived from libpng-1.0.6, and are distributed according to the same
  * disclaimer and license as libpng-1.0.6 with the following individuals
  * added to the list of Contributing Authors:
  *
- *    Simon-Pierre Cadieux
- *    Eric S. Raymond
- *    Mans Rullgard
- *    Cosmin Truta
- *    Gilles Vollant
- *    James Yu
- *    Mandar Sahastrabuddhe
- *    Google Inc.
- *    Vadim Barkov
+ *     Simon-Pierre Cadieux
+ *     Eric S. Raymond
+ *     Mans Rullgard
+ *     Cosmin Truta
+ *     Gilles Vollant
+ *     James Yu
+ *     Mandar Sahastrabuddhe
+ *     Google Inc.
+ *     Vadim Barkov
  *
  * and with the following additions to the disclaimer:
  *
- *    There is no warranty against interference with your enjoyment of the
- *    library or against infringement.  There is no warranty that our
- *    efforts or the library will fulfill any of your particular purposes
- *    or needs.  This library is provided with all faults, and the entire
- *    risk of satisfactory quality, performance, accuracy, and effort is with
- *    the user.
+ *     There is no warranty against interference with your enjoyment of
+ *     the library or against infringement.  There is no warranty that our
+ *     efforts or the library will fulfill any of your particular purposes
+ *     or needs.  This library is provided with all faults, and the entire
+ *     risk of satisfactory quality, performance, accuracy, and effort is
+ *     with the user.
  *
  * Some files in the "contrib" directory and some configure-generated
- * files that are distributed with libpng have other copyright owners and
+ * files that are distributed with libpng have other copyright owners, and
  * are released under other open source licenses.
  *
  * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
  * Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
  * libpng-0.96, and are distributed according to the same disclaimer and
- * license as libpng-0.96, with the following individuals added to the list
- * of Contributing Authors:
+ * license as libpng-0.96, with the following individuals added to the
+ * list of Contributing Authors:
  *
- *    Tom Lane
- *    Glenn Randers-Pehrson
- *    Willem van Schaik
+ *     Tom Lane
+ *     Glenn Randers-Pehrson
+ *     Willem van Schaik
  *
  * libpng versions 0.89, June 1996, through 0.96, May 1997, are
  * Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
@@ -98,12 +135,12 @@
  * libpng-0.88, with the following individuals added to the list of
  * Contributing Authors:
  *
- *    John Bowler
- *    Kevin Bracey
- *    Sam Bushell
- *    Magnus Holmgren
- *    Greg Roelofs
- *    Tom Tanner
+ *     John Bowler
+ *     Kevin Bracey
+ *     Sam Bushell
+ *     Magnus Holmgren
+ *     Greg Roelofs
+ *     Tom Tanner
  *
  * libpng versions 0.5, May 1995, through 0.88, January 1996, are
  * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -111,62 +148,49 @@
  * For the purposes of this copyright and license, "Contributing Authors"
  * is defined as the following set of individuals:
  *
- *    Andreas Dilger
- *    Dave Martindale
- *    Guy Eric Schalnat
- *    Paul Schmidt
- *    Tim Wegner
+ *     Andreas Dilger
+ *     Dave Martindale
+ *     Guy Eric Schalnat
+ *     Paul Schmidt
+ *     Tim Wegner
  *
- * The PNG Reference Library is supplied "AS IS".  The Contributing Authors
- * and Group 42, Inc. disclaim all warranties, expressed or implied,
- * including, without limitation, the warranties of merchantability and of
- * fitness for any purpose.  The Contributing Authors and Group 42, Inc.
- * assume no liability for direct, indirect, incidental, special, exemplary,
- * or consequential damages, which may result from the use of the PNG
- * Reference Library, even if advised of the possibility of such damage.
+ * The PNG Reference Library is supplied "AS IS".  The Contributing
+ * Authors and Group 42, Inc. disclaim all warranties, expressed or
+ * implied, including, without limitation, the warranties of
+ * merchantability and of fitness for any purpose.  The Contributing
+ * Authors and Group 42, Inc. assume no liability for direct, indirect,
+ * incidental, special, exemplary, or consequential damages, which may
+ * result from the use of the PNG Reference Library, even if advised of
+ * the possibility of such damage.
  *
  * Permission is hereby granted to use, copy, modify, and distribute this
  * source code, or portions hereof, for any purpose, without fee, subject
  * to the following restrictions:
  *
- *   1. The origin of this source code must not be misrepresented.
+ *  1. The origin of this source code must not be misrepresented.
  *
- *   2. Altered versions must be plainly marked as such and must not
- *      be misrepresented as being the original source.
+ *  2. Altered versions must be plainly marked as such and must not
+ *     be misrepresented as being the original source.
  *
- *   3. This Copyright notice may not be removed or altered from any
- *      source or altered source distribution.
+ *  3. This Copyright notice may not be removed or altered from any
+ *     source or altered source distribution.
  *
- * The Contributing Authors and Group 42, Inc. specifically permit, without
- * fee, and encourage the use of this source code as a component to
- * supporting the PNG file format in commercial products.  If you use this
- * source code in a product, acknowledgment is not required but would be
- * appreciated.
+ * The Contributing Authors and Group 42, Inc. specifically permit,
+ * without fee, and encourage the use of this source code as a component
+ * to supporting the PNG file format in commercial products.  If you use
+ * this source code in a product, acknowledgment is not required but would
+ * be appreciated.
  *
  * END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
  *
- * TRADEMARK:
+ * TRADEMARK
+ * =========
  *
- * The name "libpng" has not been registered by the Copyright owner
+ * The name "libpng" has not been registered by the Copyright owners
  * as a trademark in any jurisdiction.  However, because libpng has
  * been distributed and maintained world-wide, continually since 1995,
- * the Copyright owner claims "common-law trademark protection" in any
+ * the Copyright owners claim "common-law trademark protection" in any
  * jurisdiction where common-law trademark is recognized.
- *
- * OSI CERTIFICATION:
- *
- * Libpng is OSI Certified Open Source Software.  OSI Certified Open Source is
- * a certification mark of the Open Source Initiative. OSI has not addressed
- * the additional disclaimers inserted at version 1.0.7.
- *
- * EXPORT CONTROL:
- *
- * The Copyright owner believes that the Export Control Classification
- * Number (ECCN) for libpng is EAR99, which means not subject to export
- * controls or International Traffic in Arms Regulations (ITAR) because
- * it is open source, publicly available software, that does not contain
- * any encryption software.  See the EAR, paragraphs 734.3(b)(3) and
- * 734.7(b).
  */
 
 /*
@@ -232,23 +256,25 @@
  *    1.0.7rc1-2               1    10007  2.1.0.7rc1-2 (binary compatible)
  *    1.0.7                    1    10007  (still compatible)
  *    ...
- *    1.0.19                  10    10019  10.so.0.19[.0]
+ *    1.0.69                  10    10069  10.so.0.69[.0]
  *    ...
- *    1.2.59                  13    10257  12.so.0.59[.0]
+ *    1.2.59                  13    10259  12.so.0.59[.0]
  *    ...
- *    1.5.30                  15    10527  15.so.15.30[.0]
+ *    1.4.20                  14    10420  14.so.0.20[.0]
  *    ...
- *    1.6.35                  16    10635  16.so.16.35[.0]
+ *    1.5.30                  15    10530  15.so.15.30[.0]
+ *    ...
+ *    1.6.37                  16    10637  16.so.16.37[.0]
  *
- *    Henceforth the source version will match the shared-library major
- *    and minor numbers; the shared-library major version number will be
- *    used for changes in backward compatibility, as it is intended.  The
- *    PNG_LIBPNG_VER macro, which is not used within libpng but is available
- *    for applications, is an unsigned integer of the form xyyzz corresponding
- *    to the source version x.y.z (leading zeros in y and z).  Beta versions
- *    were given the previous public release number plus a letter, until
- *    version 1.0.6j; from then on they were given the upcoming public
- *    release number plus "betaNN" or "rcNN".
+ *    Henceforth the source version will match the shared-library major and
+ *    minor numbers; the shared-library major version number will be used for
+ *    changes in backward compatibility, as it is intended.
+ *    The PNG_LIBPNG_VER macro, which is not used within libpng but is
+ *    available for applications, is an unsigned integer of the form XYYZZ
+ *    corresponding to the source version X.Y.Z (leading zeros in Y and Z).
+ *    Beta versions were given the previous public release number plus a
+ *    letter, until version 1.0.6j; from then on they were given the upcoming
+ *    public release number plus "betaNN" or "rcNN".
  *
  *    Binary incompatibility exists only when applications make direct access
  *    to the info_ptr or png_ptr members through png.h, and the compiled
@@ -258,65 +284,8 @@
  *    in binary compatibility (e.g., when a new feature is added).
  *
  * See libpng.txt or libpng.3 for more information.  The PNG specification
- * is available as a W3C Recommendation and as an ISO Specification,
- * <https://www.w3.org/TR/2003/REC-PNG-20031110/
- */
-
-/*
- * Y2K compliance in libpng:
- * =========================
- *
- *    July 15, 2018
- *
- *    Since the PNG Development group is an ad-hoc body, we can't make
- *    an official declaration.
- *
- *    This is your unofficial assurance that libpng from version 0.71 and
- *    upward through 1.6.35 are Y2K compliant.  It is my belief that
- *    earlier versions were also Y2K compliant.
- *
- *    Libpng only has two year fields.  One is a 2-byte unsigned integer
- *    that will hold years up to 65535.  The other, which is deprecated,
- *    holds the date in text format, and will hold years up to 9999.
- *
- *    The integer is
- *        "png_uint_16 year" in png_time_struct.
- *
- *    The string is
- *        "char time_buffer[29]" in png_struct.  This is no longer used
- *    in libpng-1.6.x and will be removed from libpng-1.7.0.
- *
- *    There are seven time-related functions:
- *        png.c: png_convert_to_rfc_1123_buffer() in png.c
- *          (formerly png_convert_to_rfc_1123() prior to libpng-1.5.x and
- *          png_convert_to_rfc_1152() in error prior to libpng-0.98)
- *        png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c
- *        png_convert_from_time_t() in pngwrite.c
- *        png_get_tIME() in pngget.c
- *        png_handle_tIME() in pngrutil.c, called in pngread.c
- *        png_set_tIME() in pngset.c
- *        png_write_tIME() in pngwutil.c, called in pngwrite.c
- *
- *    All handle dates properly in a Y2K environment.  The
- *    png_convert_from_time_t() function calls gmtime() to convert from system
- *    clock time, which returns (year - 1900), which we properly convert to
- *    the full 4-digit year.  There is a possibility that libpng applications
- *    are not passing 4-digit years into the png_convert_to_rfc_1123_buffer()
- *    function, or that they are incorrectly passing only a 2-digit year
- *    instead of "year - 1900" into the png_convert_from_struct_tm() function,
- *    but this is not under our control.  The libpng documentation has always
- *    stated that it works with 4-digit years, and the APIs have been
- *    documented as such.
- *
- *    The tIME chunk itself is also Y2K compliant.  It uses a 2-byte unsigned
- *    integer to hold the year, and can hold years as large as 65535.
- *
- *    zlib, upon which libpng depends, is also Y2K compliant.  It contains
- *    no date-related code.
- *
- *       Glenn Randers-Pehrson
- *       libpng maintainer
- *       PNG Development Group
+ * is available as a W3C Recommendation and as an ISO/IEC Standard; see
+ * <https://www.w3.org/TR/2003/REC-PNG-20031110/>
  */
 
 #ifndef PNG_H
@@ -334,8 +303,8 @@
  */
 
 /* Version information for png.h - this should match the version in png.c */
-#define PNG_LIBPNG_VER_STRING "1.6.35"
-#define PNG_HEADER_VERSION_STRING " libpng version 1.6.35 - July 15, 2018\n"
+#define PNG_LIBPNG_VER_STRING "1.6.37"
+#define PNG_HEADER_VERSION_STRING " libpng version 1.6.37 - April 14, 2019\n"
 
 #define PNG_LIBPNG_VER_SONUM   16
 #define PNG_LIBPNG_VER_DLLNUM  16
@@ -343,13 +312,12 @@
 /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
 #define PNG_LIBPNG_VER_MAJOR   1
 #define PNG_LIBPNG_VER_MINOR   6
-#define PNG_LIBPNG_VER_RELEASE 35
-
-/* This should match the numeric part of the final component of
- * PNG_LIBPNG_VER_STRING, omitting any leading zero:
+#define PNG_LIBPNG_VER_RELEASE 37
+
+/* This should be zero for a public release, or non-zero for a
+ * development version.  [Deprecated]
  */
-
-#define PNG_LIBPNG_VER_BUILD  02
+#define PNG_LIBPNG_VER_BUILD  0
 
 /* Release Status */
 #define PNG_LIBPNG_BUILD_ALPHA    1
@@ -366,15 +334,16 @@
 #define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with
                                        PNG_LIBPNG_BUILD_PRIVATE */
 
-#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_BETA
-
-/* Careful here.  At one time, Guy wanted to use 082, but that would be octal.
- * We must not include leading zeros.
- * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
- * version 1.0.0 was mis-numbered 100 instead of 10000).  From
- * version 1.0.1 it's    xxyyzz, where x=major, y=minor, z=release
+#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE
+
+/* Careful here.  At one time, Guy wanted to use 082, but that
+ * would be octal.  We must not include leading zeros.
+ * Versions 0.7 through 1.0.0 were in the range 0 to 100 here
+ * (only version 1.0.0 was mis-numbered 100 instead of 10000).
+ * From version 1.0.1 it is:
+ * XXYYZZ, where XX=major, YY=minor, ZZ=release
  */
-#define PNG_LIBPNG_VER 10635 /* 1.6.35 */
+#define PNG_LIBPNG_VER 10637 /* 1.6.37 */
 
 /* Library configuration: these options cannot be changed after
  * the library has been built.
@@ -484,7 +453,7 @@
 /* This triggers a compiler error in png.c, if png.c and png.h
  * do not agree upon the version number.
  */
-typedef char* png_libpng_version_1_6_35;
+typedef char* png_libpng_version_1_6_37;
 
 /* Basic control structions.  Read libpng-manual.txt or libpng.3 for more info.
  *
@@ -2038,12 +2007,12 @@
 PNG_EXPORT(246, png_uint_32, png_get_eXIf, (png_const_structrp png_ptr,
     png_inforp info_ptr, png_bytep *exif));
 PNG_EXPORT(247, void, png_set_eXIf, (png_const_structrp png_ptr,
-    png_inforp info_ptr, const png_bytep exif));
+    png_inforp info_ptr, png_bytep exif));
 
 PNG_EXPORT(248, png_uint_32, png_get_eXIf_1, (png_const_structrp png_ptr,
     png_const_inforp info_ptr, png_uint_32 *num_exif, png_bytep *exif));
 PNG_EXPORT(249, void, png_set_eXIf_1, (png_const_structrp png_ptr,
-    png_inforp info_ptr, const png_uint_32 num_exif, const png_bytep exif));
+    png_inforp info_ptr, png_uint_32 num_exif, png_bytep exif));
 #endif
 
 #ifdef PNG_gAMA_SUPPORTED
@@ -2789,7 +2758,7 @@
  *
  * When the simplified API needs to convert between sRGB and linear colorspaces,
  * the actual sRGB transfer curve defined in the sRGB specification (see the
- * article at https://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2
+ * article at <https://en.wikipedia.org/wiki/SRGB>) is used, not the gamma=1/2.2
  * approximation used elsewhere in libpng.
  *
  * When an alpha channel is present it is expected to denote pixel coverage
@@ -2992,7 +2961,7 @@
  * 'flags' field of png_image.
  */
 #define PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB 0x01
-   /* This indicates the the RGB values of the in-memory bitmap do not
+   /* This indicates that the RGB values of the in-memory bitmap do not
     * correspond to the red, green and blue end-points defined by sRGB.
     */
 
--- a/src/share/native/sun/awt/libpng/pngconf.h	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/native/sun/awt/libpng/pngconf.h	Thu Sep 03 04:06:33 2020 +0100
@@ -22,18 +22,19 @@
  * questions.
  */
 
-/* pngconf.h - machine configurable file for libpng
+/* pngconf.h - machine-configurable file for libpng
  *
  * This file is available under and governed by the GNU General Public
  * License version 2 only, as published by the Free Software Foundation.
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * libpng version 1.6.35, July 15, 2018
+ * libpng version 1.6.37
  *
+ * Copyright (c) 2018-2019 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
@@ -85,14 +86,13 @@
 
 #endif /* PNG_BUILDING_SYMBOL_TABLE */
 
-/* Prior to 1.6.0 it was possible to turn off 'const' in declarations using
- * PNG_NO_CONST; this is no longer supported except for data declarations which
- * apparently still cause problems in 2011 on some compilers.
+/* Prior to 1.6.0, it was possible to turn off 'const' in declarations,
+ * using PNG_NO_CONST.  This is no longer supported.
  */
 #define PNG_CONST const /* backward compatibility only */
 
-/* This controls optimization of the reading of 16-bit and 32-bit values
- * from PNG files.  It can be set on a per-app-file basis - it
+/* This controls optimization of the reading of 16-bit and 32-bit
+ * values from PNG files.  It can be set on a per-app-file basis: it
  * just changes whether a macro is used when the function is called.
  * The library builder sets the default; if read functions are not
  * built into the library the macro implementation is forced on.
--- a/src/share/native/sun/awt/libpng/pngdebug.h	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/native/sun/awt/libpng/pngdebug.h	Thu Sep 03 04:06:33 2020 +0100
@@ -29,10 +29,10 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.8 [December 19, 2013]
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2013 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
--- a/src/share/native/sun/awt/libpng/pngerror.c	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/native/sun/awt/libpng/pngerror.c	Thu Sep 03 04:06:33 2020 +0100
@@ -29,10 +29,10 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.31 [July 27, 2017]
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
@@ -453,7 +453,7 @@
  * if the character is invalid.
  */
 #define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97))
-static PNG_CONST char png_digit[16] = {
+static const char png_digit[16] = {
    '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
    'A', 'B', 'C', 'D', 'E', 'F'
 };
@@ -913,7 +913,7 @@
 png_safe_error),(png_structp png_nonconst_ptr, png_const_charp error_message),
     PNG_NORETURN)
 {
-   const png_const_structrp png_ptr = png_nonconst_ptr;
+   png_const_structrp png_ptr = png_nonconst_ptr;
    png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr);
 
    /* An error is always logged here, overwriting anything (typically a warning)
@@ -948,7 +948,7 @@
 void /* PRIVATE */ PNGCBAPI
 png_safe_warning(png_structp png_nonconst_ptr, png_const_charp warning_message)
 {
-   const png_const_structrp png_ptr = png_nonconst_ptr;
+   png_const_structrp png_ptr = png_nonconst_ptr;
    png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr);
 
    /* A warning is only logged if there is no prior warning or error. */
--- a/src/share/native/sun/awt/libpng/pngget.c	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/native/sun/awt/libpng/pngget.c	Thu Sep 03 04:06:33 2020 +0100
@@ -29,10 +29,10 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.35 [July 15, 2018]
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
--- a/src/share/native/sun/awt/libpng/pnginfo.h	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/native/sun/awt/libpng/pnginfo.h	Thu Sep 03 04:06:33 2020 +0100
@@ -29,10 +29,10 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.35 [July 15, 2018]
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2013,2018 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
--- a/src/share/native/sun/awt/libpng/pnglibconf.h	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/native/sun/awt/libpng/pnglibconf.h	Thu Sep 03 04:06:33 2020 +0100
@@ -29,18 +29,16 @@
  * THIS FILE WAS MODIFIED BY ORACLE, INC.
  */
 
-/* libpng STANDARD API DEFINITION */
-
 /* pnglibconf.h - library build configuration */
 /* This file is available under and governed by the GNU General Public
  * License version 2 only, as published by the Free Software Foundation.
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  */
+/* libpng version 1.6.37 */
 
-/* libpng version 1.6.35, July 15, 2018 */
-
-/* Copyright (c) 1998-2018 Glenn Randers-Pehrson */
+/* Copyright (c) 2018-2019 Cosmin Truta */
+/* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson */
 
 /* This code is released under the libpng license. */
 /* For conditions of distribution and use, see the disclaimer */
@@ -80,6 +78,8 @@
 #define PNG_IO_STATE_SUPPORTED
 #define PNG_MNG_FEATURES_SUPPORTED
 #define PNG_POINTER_INDEXING_SUPPORTED
+/*#undef PNG_POWERPC_VSX_API_SUPPORTED*/
+/*#undef PNG_POWERPC_VSX_CHECK_SUPPORTED*/
 #define PNG_PROGRESSIVE_READ_SUPPORTED
 #define PNG_READ_16BIT_SUPPORTED
 #define PNG_READ_ALPHA_MODE_SUPPORTED
@@ -118,6 +118,7 @@
 #define PNG_READ_USER_TRANSFORM_SUPPORTED
 #define PNG_READ_bKGD_SUPPORTED
 #define PNG_READ_cHRM_SUPPORTED
+/*#undef PNG_READ_eXIf_SUPPORTED*/
 #define PNG_READ_gAMA_SUPPORTED
 #define PNG_READ_hIST_SUPPORTED
 /*#undef PNG_READ_iCCP_SUPPORTED*/
@@ -187,6 +188,7 @@
 /*#undef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED*/
 /*#undef PNG_WRITE_bKGD_SUPPORTED*/
 /*#undef PNG_WRITE_cHRM_SUPPORTED*/
+/*#undef PNG_WRITE_eXIf_SUPPORTED*/
 /*#undef PNG_WRITE_gAMA_SUPPORTED*/
 /*#undef PNG_WRITE_hIST_SUPPORTED*/
 /*#undef PNG_WRITE_iCCP_SUPPORTED*/
@@ -204,6 +206,7 @@
 /*#undef PNG_WRITE_zTXt_SUPPORTED*/
 #define PNG_bKGD_SUPPORTED
 #define PNG_cHRM_SUPPORTED
+/*#undef PNG_eXIf_SUPPORTED*/
 #define PNG_gAMA_SUPPORTED
 #define PNG_hIST_SUPPORTED
 #define PNG_iCCP_SUPPORTED
@@ -241,7 +244,7 @@
 #define PNG_USER_HEIGHT_MAX 8000
 #define PNG_USER_WIDTH_MAX 8000
 #define PNG_ZBUF_SIZE 8192
-#define PNG_ZLIB_VERNUM 0
+#define PNG_ZLIB_VERNUM 0 /* unknown */
 #define PNG_Z_DEFAULT_COMPRESSION (-1)
 #define PNG_Z_DEFAULT_NOFILTER_STRATEGY 0
 #define PNG_Z_DEFAULT_STRATEGY 1
--- a/src/share/native/sun/awt/libpng/pngmem.c	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/native/sun/awt/libpng/pngmem.c	Thu Sep 03 04:06:33 2020 +0100
@@ -29,10 +29,10 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.26 [October 20, 2016]
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2014,2016 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
--- a/src/share/native/sun/awt/libpng/pngpread.c	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/native/sun/awt/libpng/pngpread.c	Thu Sep 03 04:06:33 2020 +0100
@@ -29,10 +29,10 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.35 [July 15, 2018]
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
@@ -1000,20 +1000,20 @@
    /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
 
    /* Start of interlace block */
-   static PNG_CONST png_byte png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
+   static const png_byte png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
 
    /* Offset to next interlace block */
-   static PNG_CONST png_byte png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
+   static const png_byte png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
 
    /* Start of interlace block in the y direction */
-   static PNG_CONST png_byte png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
+   static const png_byte png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
 
    /* Offset to next interlace block in the y direction */
-   static PNG_CONST png_byte png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
+   static const png_byte png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
 
    /* Height of interlace block.  This is not currently used - if you need
     * it, uncomment it here and in png.h
-   static PNG_CONST png_byte png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
+   static const png_byte png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
    */
 #endif
 
--- a/src/share/native/sun/awt/libpng/pngpriv.h	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/native/sun/awt/libpng/pngpriv.h	Thu Sep 03 04:06:33 2020 +0100
@@ -29,10 +29,10 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.35 [July 15, 2018]
+ * Copyright (c) 2018-2019 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
@@ -202,7 +202,10 @@
 #     else /* !defined __ARM_NEON__ */
          /* The 'intrinsics' code simply won't compile without this -mfpu=neon:
           */
-#        define PNG_ARM_NEON_IMPLEMENTATION 2
+#        if !defined(__aarch64__)
+            /* The assembler code currently does not work on ARM64 */
+#          define PNG_ARM_NEON_IMPLEMENTATION 2
+#        endif /* __aarch64__ */
 #     endif /* __ARM_NEON__ */
 #  endif /* !PNG_ARM_NEON_IMPLEMENTATION */
 
@@ -298,6 +301,7 @@
 #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.
@@ -1564,10 +1568,10 @@
 #endif
 
 PNG_INTERNAL_FUNCTION(void,png_check_chunk_name,(png_const_structrp png_ptr,
-    const png_uint_32 chunk_name),PNG_EMPTY);
+    png_uint_32 chunk_name),PNG_EMPTY);
 
 PNG_INTERNAL_FUNCTION(void,png_check_chunk_length,(png_const_structrp png_ptr,
-    const png_uint_32 chunk_length),PNG_EMPTY);
+    png_uint_32 chunk_length),PNG_EMPTY);
 
 PNG_INTERNAL_FUNCTION(void,png_handle_unknown,(png_structrp png_ptr,
     png_inforp info_ptr, png_uint_32 length, int keep),PNG_EMPTY);
@@ -2144,6 +2148,29 @@
 PNG_INTERNAL_FUNCTION(png_uint_32, png_check_keyword, (png_structrp png_ptr,
    png_const_charp key, png_bytep new_key), PNG_EMPTY);
 
+#if PNG_ARM_NEON_IMPLEMENTATION == 1
+PNG_INTERNAL_FUNCTION(void,
+                      png_riffle_palette_neon,
+                      (png_structrp),
+                      PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(int,
+                      png_do_expand_palette_rgba8_neon,
+                      (png_structrp,
+                       png_row_infop,
+                       png_const_bytep,
+                       const png_bytepp,
+                       const png_bytepp),
+                      PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(int,
+                      png_do_expand_palette_rgb8_neon,
+                      (png_structrp,
+                       png_row_infop,
+                       png_const_bytep,
+                       const png_bytepp,
+                       const png_bytepp),
+                      PNG_EMPTY);
+#endif
+
 /* Maintainer: Put new private prototypes here ^ */
 
 #include "pngdebug.h"
--- a/src/share/native/sun/awt/libpng/pngread.c	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/native/sun/awt/libpng/pngread.c	Thu Sep 03 04:06:33 2020 +0100
@@ -29,10 +29,10 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.35 [July 15, 2018]
+ * Copyright (c) 2018-2019 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
@@ -1022,6 +1022,12 @@
    png_ptr->chunk_list = NULL;
 #endif
 
+#if defined(PNG_READ_EXPAND_SUPPORTED) && \
+    defined(PNG_ARM_NEON_IMPLEMENTATION)
+   png_free(png_ptr, png_ptr->riffled_palette);
+   png_ptr->riffled_palette = NULL;
+#endif
+
    /* NOTE: the 'setjmp' buffer may still be allocated and the memory and error
     * callbacks are still set at this point.  They are required to complete the
     * destruction of the png_struct itself.
@@ -1649,7 +1655,7 @@
     * errors (which are unfortunately quite common.)
     */
    {
-         static PNG_CONST png_byte chunks_to_process[] = {
+         static const png_byte chunks_to_process[] = {
             98,  75,  71,  68, '\0',  /* bKGD */
             99,  72,  82,  77, '\0',  /* cHRM */
            103,  65,  77,  65, '\0',  /* gAMA */
@@ -1786,9 +1792,9 @@
     png_uint_32 alpha, int encoding)
 {
    png_imagep image = display->image;
-   const int output_encoding = (image->format & PNG_FORMAT_FLAG_LINEAR) != 0 ?
+   int output_encoding = (image->format & PNG_FORMAT_FLAG_LINEAR) != 0 ?
        P_LINEAR : P_sRGB;
-   const int convert_to_Y = (image->format & PNG_FORMAT_FLAG_COLOR) == 0 &&
+   int convert_to_Y = (image->format & PNG_FORMAT_FLAG_COLOR) == 0 &&
        (red != green || green != blue);
 
    if (ip > 255)
@@ -1897,13 +1903,13 @@
    /* Store the value. */
    {
 #     ifdef PNG_FORMAT_AFIRST_SUPPORTED
-         const int afirst = (image->format & PNG_FORMAT_FLAG_AFIRST) != 0 &&
+         int afirst = (image->format & PNG_FORMAT_FLAG_AFIRST) != 0 &&
             (image->format & PNG_FORMAT_FLAG_ALPHA) != 0;
 #     else
 #        define afirst 0
 #     endif
 #     ifdef PNG_FORMAT_BGR_SUPPORTED
-         const int bgr = (image->format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0;
+         int bgr = (image->format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0;
 #     else
 #        define bgr 0
 #     endif
@@ -2113,11 +2119,11 @@
 {
    png_image_read_control *display =
       png_voidcast(png_image_read_control*, argument);
-   const png_imagep image = display->image;
-
-   const png_structrp png_ptr = image->opaque->png_ptr;
-   const png_uint_32 output_format = image->format;
-   const int output_encoding = (output_format & PNG_FORMAT_FLAG_LINEAR) != 0 ?
+   png_imagep image = display->image;
+
+   png_structrp png_ptr = image->opaque->png_ptr;
+   png_uint_32 output_format = image->format;
+   int output_encoding = (output_format & PNG_FORMAT_FLAG_LINEAR) != 0 ?
       P_LINEAR : P_sRGB;
 
    unsigned int cmap_entries;
@@ -2830,7 +2836,7 @@
             unsigned int num_trans = png_ptr->num_trans;
             png_const_bytep trans = num_trans > 0 ? png_ptr->trans_alpha : NULL;
             png_const_colorp colormap = png_ptr->palette;
-            const int do_background = trans != NULL &&
+            int do_background = trans != NULL &&
                (output_format & PNG_FORMAT_FLAG_ALPHA) == 0;
             unsigned int i;
 
@@ -3974,7 +3980,7 @@
        */
       if (linear != 0)
       {
-         PNG_CONST png_uint_16 le = 0x0001;
+         png_uint_16 le = 0x0001;
 
          if ((*(png_const_bytep) & le) != 0)
             png_set_swap(png_ptr);
@@ -4136,7 +4142,7 @@
        * original PNG format because it may not occur in the output PNG format
        * and libpng deals with the issues of reading the original.
        */
-      const unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format);
+      unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format);
 
       /* The following checks just the 'row_stride' calculation to ensure it
        * fits in a signed 32-bit value.  Because channels/components can be
@@ -4147,7 +4153,7 @@
       if (image->width <= 0x7fffffffU/channels) /* no overflow */
       {
          png_uint_32 check;
-         const png_uint_32 png_row_stride = image->width * channels;
+         png_uint_32 png_row_stride = image->width * channels;
 
          if (row_stride == 0)
             row_stride = (png_int_32)/*SAFE*/png_row_stride;
--- a/src/share/native/sun/awt/libpng/pngrio.c	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/native/sun/awt/libpng/pngrio.c	Thu Sep 03 04:06:33 2020 +0100
@@ -29,10 +29,10 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.35 [July 15, 2018]
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
--- a/src/share/native/sun/awt/libpng/pngrtran.c	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/native/sun/awt/libpng/pngrtran.c	Thu Sep 03 04:06:33 2020 +0100
@@ -29,10 +29,10 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.35 [July 15, 2018]
+ * Copyright (c) 2018-2019 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
@@ -46,6 +46,17 @@
 
 #include "pngpriv.h"
 
+#ifdef PNG_ARM_NEON_IMPLEMENTATION
+#  if PNG_ARM_NEON_IMPLEMENTATION == 1
+#    define PNG_ARM_NEON_INTRINSICS_AVAILABLE
+#    if defined(_MSC_VER) && defined(_M_ARM64)
+#      include <arm64_neon.h>
+#    else
+#      include <arm_neon.h>
+#    endif
+#  endif
+#endif
+
 #ifdef PNG_READ_SUPPORTED
 
 /* Set the action on getting a CRC error for an ancillary or critical chunk. */
@@ -1199,20 +1210,20 @@
              png_ptr->palette[png_ptr->background.index].blue;
 
 #ifdef PNG_READ_INVERT_ALPHA_SUPPORTED
-        if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0)
-        {
-           if ((png_ptr->transformations & PNG_EXPAND_tRNS) == 0)
-           {
-              /* Invert the alpha channel (in tRNS) unless the pixels are
-               * going to be expanded, in which case leave it for later
-               */
-              int i, istop = png_ptr->num_trans;
-
-              for (i=0; i<istop; i++)
-                 png_ptr->trans_alpha[i] = (png_byte)(255 -
-                    png_ptr->trans_alpha[i]);
-           }
-        }
+         if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0)
+         {
+            if ((png_ptr->transformations & PNG_EXPAND_tRNS) == 0)
+            {
+               /* Invert the alpha channel (in tRNS) unless the pixels are
+                * going to be expanded, in which case leave it for later
+                */
+               int i, istop = png_ptr->num_trans;
+
+               for (i = 0; i < istop; i++)
+                  png_ptr->trans_alpha[i] =
+                      (png_byte)(255 - png_ptr->trans_alpha[i]);
+            }
+         }
 #endif /* READ_INVERT_ALPHA */
       }
    } /* background expand and (therefore) no alpha association. */
@@ -3014,7 +3025,6 @@
  */
 static int
 png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
-
 {
    int rgb_error = 0;
 
@@ -3023,12 +3033,11 @@
    if ((row_info->color_type & PNG_COLOR_MASK_PALETTE) == 0 &&
        (row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
    {
-      PNG_CONST png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff;
-      PNG_CONST png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff;
-      PNG_CONST png_uint_32 bc = 32768 - rc - gc;
-      PNG_CONST png_uint_32 row_width = row_info->width;
-      PNG_CONST int have_alpha =
-         (row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0;
+      png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff;
+      png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff;
+      png_uint_32 bc = 32768 - rc - gc;
+      png_uint_32 row_width = row_info->width;
+      int have_alpha = (row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0;
 
       if (row_info->bit_depth == 8)
       {
@@ -4171,12 +4180,11 @@
    {
       if (row_info->bit_depth == 8)
       {
-         PNG_CONST png_bytep table = png_ptr->gamma_from_1;
+         png_bytep table = png_ptr->gamma_from_1;
 
          if (table != NULL)
          {
-            PNG_CONST int step =
-               (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 4 : 2;
+            int step = (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 4 : 2;
 
             /* The alpha channel is the last component: */
             row += step - 1;
@@ -4190,13 +4198,12 @@
 
       else if (row_info->bit_depth == 16)
       {
-         PNG_CONST png_uint_16pp table = png_ptr->gamma_16_from_1;
-         PNG_CONST int gamma_shift = png_ptr->gamma_shift;
+         png_uint_16pp table = png_ptr->gamma_16_from_1;
+         int gamma_shift = png_ptr->gamma_shift;
 
          if (table != NULL)
          {
-            PNG_CONST int step =
-               (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 8 : 4;
+            int step = (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 8 : 4;
 
             /* The alpha channel is the last component: */
             row += step - 2;
@@ -4227,8 +4234,9 @@
  * upon whether you supply trans and num_trans.
  */
 static void
-png_do_expand_palette(png_row_infop row_info, png_bytep row,
-    png_const_colorp palette, png_const_bytep trans_alpha, int num_trans)
+png_do_expand_palette(png_structrp png_ptr, png_row_infop row_info,
+    png_bytep row, png_const_colorp palette, png_const_bytep trans_alpha,
+    int num_trans)
 {
    int shift, value;
    png_bytep sp, dp;
@@ -4332,14 +4340,27 @@
                sp = row + (size_t)row_width - 1;
                dp = row + ((size_t)row_width << 2) - 1;
 
-               for (i = 0; i < row_width; i++)
+               i = 0;
+#ifdef PNG_ARM_NEON_INTRINSICS_AVAILABLE
+               if (png_ptr->riffled_palette != NULL)
+               {
+                  /* The RGBA optimization works with png_ptr->bit_depth == 8
+                   * but sometimes row_info->bit_depth has been changed to 8.
+                   * In these cases, the palette hasn't been riffled.
+                   */
+                  i = png_do_expand_palette_rgba8_neon(png_ptr, row_info, row,
+                      &sp, &dp);
+               }
+#else
+               PNG_UNUSED(png_ptr)
+#endif
+
+               for (; i < row_width; i++)
                {
                   if ((int)(*sp) >= num_trans)
                      *dp-- = 0xff;
-
                   else
                      *dp-- = trans_alpha[*sp];
-
                   *dp-- = palette[*sp].blue;
                   *dp-- = palette[*sp].green;
                   *dp-- = palette[*sp].red;
@@ -4356,8 +4377,15 @@
             {
                sp = row + (size_t)row_width - 1;
                dp = row + (size_t)(row_width * 3) - 1;
-
-               for (i = 0; i < row_width; i++)
+               i = 0;
+#ifdef PNG_ARM_NEON_INTRINSICS_AVAILABLE
+               i = png_do_expand_palette_rgb8_neon(png_ptr, row_info, row,
+                   &sp, &dp);
+#else
+               PNG_UNUSED(png_ptr)
+#endif
+
+               for (; i < row_width; i++)
                {
                   *dp-- = palette[*sp].blue;
                   *dp-- = palette[*sp].green;
@@ -4771,7 +4799,19 @@
    {
       if (row_info->color_type == PNG_COLOR_TYPE_PALETTE)
       {
-         png_do_expand_palette(row_info, png_ptr->row_buf + 1,
+#ifdef PNG_ARM_NEON_INTRINSICS_AVAILABLE
+         if ((png_ptr->num_trans > 0) && (png_ptr->bit_depth == 8))
+         {
+            if (png_ptr->riffled_palette == NULL)
+            {
+               /* Initialize the accelerated palette expansion. */
+               png_ptr->riffled_palette =
+                   (png_bytep)png_malloc(png_ptr, 256 * 4);
+               png_riffle_palette_neon(png_ptr);
+            }
+         }
+#endif
+         png_do_expand_palette(png_ptr, row_info, png_ptr->row_buf + 1,
              png_ptr->palette, png_ptr->trans_alpha, png_ptr->num_trans);
       }
 
--- a/src/share/native/sun/awt/libpng/pngrutil.c	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/native/sun/awt/libpng/pngrutil.c	Thu Sep 03 04:06:33 2020 +0100
@@ -29,10 +29,10 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.35 [July 15, 2018]
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
@@ -1489,8 +1489,7 @@
                {
                   /* We have the ICC profile header; do the basic header checks.
                    */
-                  const png_uint_32 profile_length =
-                     png_get_uint_32(profile_header);
+                  png_uint_32 profile_length = png_get_uint_32(profile_header);
 
                   if (png_icc_check_length(png_ptr, &png_ptr->colorspace,
                       keyword, profile_length) != 0)
@@ -1507,8 +1506,8 @@
                          * profile.  The header check has already validated
                          * that none of this stuff will overflow.
                          */
-                        const png_uint_32 tag_count = png_get_uint_32(
-                            profile_header+128);
+                        png_uint_32 tag_count =
+                           png_get_uint_32(profile_header + 128);
                         png_bytep profile = png_read_buffer(png_ptr,
                             profile_length, 2/*silent*/);
 
@@ -3160,7 +3159,7 @@
  */
 
 void /* PRIVATE */
-png_check_chunk_name(png_const_structrp png_ptr, const png_uint_32 chunk_name)
+png_check_chunk_name(png_const_structrp png_ptr, png_uint_32 chunk_name)
 {
    int i;
    png_uint_32 cn=chunk_name;
@@ -3179,7 +3178,7 @@
 }
 
 void /* PRIVATE */
-png_check_chunk_length(png_const_structrp png_ptr, const png_uint_32 length)
+png_check_chunk_length(png_const_structrp png_ptr, png_uint_32 length)
 {
    png_alloc_size_t limit = PNG_UINT_31_MAX;
 
@@ -3391,7 +3390,7 @@
          /* Hence the pre-compiled masks indexed by PACKSWAP (or not), depth and
           * then pass:
           */
-         static PNG_CONST png_uint_32 row_mask[2/*PACKSWAP*/][3/*depth*/][6] =
+         static const png_uint_32 row_mask[2/*PACKSWAP*/][3/*depth*/][6] =
          {
             /* Little-endian byte masks for PACKSWAP */
             { S_MASKS(1,0), S_MASKS(2,0), S_MASKS(4,0) },
@@ -3402,7 +3401,7 @@
          /* display_mask has only three entries for the odd passes, so index by
           * pass>>1.
           */
-         static PNG_CONST png_uint_32 display_mask[2][3][3] =
+         static const png_uint_32 display_mask[2][3][3] =
          {
             /* Little-endian byte masks for PACKSWAP */
             { B_MASKS(1,0), B_MASKS(2,0), B_MASKS(4,0) },
@@ -3715,7 +3714,7 @@
 {
    /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
    /* Offset to next interlace block */
-   static PNG_CONST unsigned int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
+   static const unsigned int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
 
    png_debug(1, "in png_do_read_interlace");
    if (row != NULL && row_info != NULL)
@@ -4357,16 +4356,16 @@
    /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
 
    /* Start of interlace block */
-   static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
+   static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
 
    /* Offset to next interlace block */
-   static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
+   static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
 
    /* Start of interlace block in the y direction */
-   static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
+   static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
 
    /* Offset to next interlace block in the y direction */
-   static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
+   static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
 
    png_debug(1, "in png_read_finish_row");
    png_ptr->row_number++;
@@ -4422,16 +4421,16 @@
    /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
 
    /* Start of interlace block */
-   static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
+   static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
 
    /* Offset to next interlace block */
-   static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
+   static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
 
    /* Start of interlace block in the y direction */
-   static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
+   static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
 
    /* Offset to next interlace block in the y direction */
-   static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
+   static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
 
    unsigned int max_pixel_depth;
    size_t row_bytes;
--- a/src/share/native/sun/awt/libpng/pngset.c	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/native/sun/awt/libpng/pngset.c	Thu Sep 03 04:06:33 2020 +0100
@@ -29,10 +29,10 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.35 [July 15, 2018]
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 1998-2018 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
@@ -165,7 +165,7 @@
 #ifdef PNG_eXIf_SUPPORTED
 void PNGAPI
 png_set_eXIf(png_const_structrp png_ptr, png_inforp info_ptr,
-    const png_bytep eXIf_buf)
+    png_bytep eXIf_buf)
 {
   png_warning(png_ptr, "png_set_eXIf does not work; use png_set_eXIf_1");
   PNG_UNUSED(info_ptr)
@@ -174,7 +174,7 @@
 
 void PNGAPI
 png_set_eXIf_1(png_const_structrp png_ptr, png_inforp info_ptr,
-    const png_uint_32 num_exif, const png_bytep eXIf_buf)
+    png_uint_32 num_exif, png_bytep eXIf_buf)
 {
    int i;
 
@@ -1427,7 +1427,7 @@
       /* Ignore all unknown chunks and all chunks recognized by
        * libpng except for IHDR, PLTE, tRNS, IDAT, and IEND
        */
-      static PNG_CONST png_byte chunks_to_ignore[] = {
+      static const png_byte chunks_to_ignore[] = {
          98,  75,  71,  68, '\0',  /* bKGD */
          99,  72,  82,  77, '\0',  /* cHRM */
         101,  88,  73, 102, '\0',  /* eXIf */
--- a/src/share/native/sun/awt/libpng/pngstruct.h	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/native/sun/awt/libpng/pngstruct.h	Thu Sep 03 04:06:33 2020 +0100
@@ -29,10 +29,10 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.35 [July 15, 2018]
+ * Copyright (c) 2018-2019 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
@@ -420,6 +420,12 @@
    /* deleted in 1.5.5: rgb_to_gray_blue_coeff; */
 #endif
 
+/* New member added in libpng-1.6.36 */
+#if defined(PNG_READ_EXPAND_SUPPORTED) && \
+    defined(PNG_ARM_NEON_IMPLEMENTATION)
+   png_bytep riffled_palette; /* buffer for accelerated palette expansion */
+#endif
+
 /* New member added in libpng-1.0.4 (renamed in 1.0.9) */
 #if defined(PNG_MNG_FEATURES_SUPPORTED)
 /* Changed from png_byte to png_uint_32 at version 1.2.0 */
--- a/src/share/native/sun/awt/libpng/pngtrans.c	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/native/sun/awt/libpng/pngtrans.c	Thu Sep 03 04:06:33 2020 +0100
@@ -29,10 +29,10 @@
  * However, the following notice accompanied the original version of this
  * file and, per its terms, should not be removed:
  *
- * Last changed in libpng 1.6.35 [July 15, 2018]
+ * Copyright (c) 2018 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
+ * Copyright (c) 1996-1997 Andreas Dilger
+ * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
@@ -373,7 +373,7 @@
 #endif
 
 #if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)
-static PNG_CONST png_byte onebppswaptable[256] = {
+static const png_byte onebppswaptable[256] = {
    0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0,
    0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0,
    0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8,
@@ -408,7 +408,7 @@
    0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF
 };
 
-static PNG_CONST png_byte twobppswaptable[256] = {
+static const png_byte twobppswaptable[256] = {
    0x00, 0x40, 0x80, 0xC0, 0x10, 0x50, 0x90, 0xD0,
    0x20, 0x60, 0xA0, 0xE0, 0x30, 0x70, 0xB0, 0xF0,
    0x04, 0x44, 0x84, 0xC4, 0x14, 0x54, 0x94, 0xD4,
@@ -443,7 +443,7 @@
    0x2F, 0x6F, 0xAF, 0xEF, 0x3F, 0x7F, 0xBF, 0xFF
 };
 
-static PNG_CONST png_byte fourbppswaptable[256] = {
+static const png_byte fourbppswaptable[256] = {
    0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70,
    0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0,
    0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71,
--- a/src/share/native/sun/awt/medialib/mlib_ImageScanPoly.c	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/native/sun/awt/medialib/mlib_ImageScanPoly.c	Thu Sep 03 04:06:33 2020 +0100
@@ -408,7 +408,9 @@
         if ((dxs < dxCl) || (dxs >= dwCl) || (dys < dyCl) || (dys >= dhCl)) {
           dxs += dx;
           dys += dy;
-          xLeft++;
+          if (xLeft < MLIB_S32_MAX) {
+              xLeft++;
+          }
 
           if ((dxs < dxCl) || (dxs >= dwCl) || (dys < dyCl) || (dys >= dhCl))
             xRight = -1;
@@ -420,7 +422,9 @@
         if ((dxe < dxCl) || (dxe >= dwCl) || (dye < dyCl) || (dye >= dhCl)) {
           dxe -= dx;
           dye -= dy;
-          xRight--;
+          if (xRight > MLIB_S32_MIN) {
+              xRight--;
+          }
 
           if ((dxe < dxCl) || (dxe >= dwCl) || (dye < dyCl) || (dye >= dhCl))
             xRight = -1;
@@ -494,7 +498,9 @@
         if ((dxs > dxCl) || (dxs <= dwCl) || (dys > dyCl) || (dys <= dhCl)) {
           dxs += dx;
           dys += dy;
-          xLeft++;
+          if (xLeft < MLIB_S32_MAX) {
+              xLeft++;
+          }
 
           if ((dxs > dxCl) || (dxs <= dwCl) || (dys > dyCl) || (dys <= dhCl))
             xRight = -1;
@@ -506,7 +512,9 @@
         if ((dxe > dxCl) || (dxe <= dwCl) || (dye > dyCl) || (dye <= dhCl)) {
           dxe -= dx;
           dye -= dy;
-          xRight--;
+          if (xRight > MLIB_S32_MIN) {
+              xRight--;
+          }
 
           if ((dxe > dxCl) || (dxe <= dwCl) || (dye > dyCl) || (dye <= dhCl))
             xRight = -1;
--- a/src/share/native/sun/java2d/cmm/lcms/cmsps2.c	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/share/native/sun/java2d/cmm/lcms/cmsps2.c	Thu Sep 03 04:06:33 2020 +0100
@@ -1443,7 +1443,7 @@
     cmsUInt32Number i, nColors, nColorant;
     cmsUInt32Number OutputFormat;
     char ColorName[cmsMAX_PATH];
-    char Colorant[128];
+    char Colorant[512];
     cmsNAMEDCOLORLIST* NamedColorList;
 
 
--- a/src/solaris/native/sun/awt/gtk2_interface.c	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/solaris/native/sun/awt/gtk2_interface.c	Thu Sep 03 04:06:33 2020 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -390,45 +390,46 @@
     black = gdk_pixbuf_get_pixels (gtk2_black_pixbuf);
     stride = gdk_pixbuf_get_rowstride (gtk2_black_pixbuf);
     padding = stride - width * 4;
-
-    for (i = 0; i < height; i++) {
-        for (j = 0; j < width; j++) {
-            int r1 = *white++;
-            int r2 = *black++;
-            int alpha = 0xff + r2 - r1;
+    if (padding >= 0 && stride > 0) {
+        for (i = 0; i < height; i++) {
+            for (j = 0; j < width; j++) {
+                int r1 = *white++;
+                int r2 = *black++;
+                int alpha = 0xff + r2 - r1;
 
-            switch (alpha) {
-                case 0:       /* transparent pixel */
-                    r = g = b = 0;
-                    black += 3;
-                    white += 3;
-                    is_opaque = FALSE;
-                    break;
+                switch (alpha) {
+                    case 0:       /* transparent pixel */
+                        r = g = b = 0;
+                        black += 3;
+                        white += 3;
+                        is_opaque = FALSE;
+                        break;
 
-                case 0xff:    /* opaque pixel */
-                    r = r2;
-                    g = *black++;
-                    b = *black++;
-                    black++;
-                    white += 3;
-                    break;
+                    case 0xff:    /* opaque pixel */
+                        r = r2;
+                        g = *black++;
+                        b = *black++;
+                        black++;
+                        white += 3;
+                        break;
 
-                default:      /* translucent pixel */
-                    r = 0xff * r2 / alpha;
-                    g = 0xff * *black++ / alpha;
-                    b = 0xff * *black++ / alpha;
-                    black++;
-                    white += 3;
-                    is_opaque = FALSE;
-                    is_bitmask = FALSE;
-                    break;
+                    default:      /* translucent pixel */
+                        r = 0xff * r2 / alpha;
+                        g = 0xff * *black++ / alpha;
+                        b = 0xff * *black++ / alpha;
+                        black++;
+                        white += 3;
+                        is_opaque = FALSE;
+                        is_bitmask = FALSE;
+                        break;
+                }
+
+                *dst++ = (alpha << 24 | r << 16 | g << 8 | b);
             }
 
-            *dst++ = (alpha << 24 | r << 16 | g << 8 | b);
+            white += padding;
+            black += padding;
         }
-
-        white += padding;
-        black += padding;
     }
     return is_opaque ? java_awt_Transparency_OPAQUE :
                        (is_bitmask ? java_awt_Transparency_BITMASK :
--- a/src/solaris/native/sun/awt/swing_GTKEngine.c	Sat Apr 18 19:25:55 2020 +0100
+++ b/src/solaris/native/sun/awt/swing_GTKEngine.c	Thu Sep 03 04:06:33 2020 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,9 +23,10 @@
  * questions.
  */
 
-#include <stdlib.h>
 #include "gtk2_interface.h"
 #include "com_sun_java_swing_plaf_gtk_GTKEngine.h"
+#include <jni_util.h>
+#include <stdlib.h>
 
 /*
  * Class:     com_sun_java_swing_plaf_gtk_GTKEngine
@@ -292,6 +293,11 @@
 Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeStartPainting(
         JNIEnv *env, jobject this, jint w, jint h)
 {
+    if (w > 0x7FFF || h > 0x7FFF || (uintptr_t)4 * w * h > 0x7FFFFFFFL) {
+        // Same limitation as in X11SurfaceData.c
+        JNU_ThrowOutOfMemoryError(env, "Can't create offscreen surface");
+        return;
+    }
     gdk_threads_enter();
     gtk2_init_painting(env, w, h);
     gdk_threads_leave();
--- a/test/java/io/Serializable/serialFilter/SerialFilterTest.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/test/java/io/Serializable/serialFilter/SerialFilterTest.java	Thu Sep 03 04:06:33 2020 +0100
@@ -50,8 +50,10 @@
 import sun.misc.ObjectInputFilter;
 
 /* @test
+ * @bug 8234836
  * @build SerialFilterTest
  * @run testng/othervm  SerialFilterTest
+ * @run testng/othervm  -Djdk.serialSetFilterAfterRead=true SerialFilterTest
  *
  * @summary Test ObjectInputFilters
  */
@@ -77,6 +79,10 @@
      */
     private static final Object otherObject = Integer.valueOf(0);
 
+    // Cache value of jdk.serialSetFilterAfterRead property.
+    static final boolean SET_FILTER_AFTER_READ =
+            Boolean.getBoolean("jdk.serialSetFilterAfterRead");
+
     /**
      * DataProvider for the individual patterns to test.
      * Expand the patterns into cases for each of the Std and Compatibility APIs.
@@ -271,6 +277,46 @@
     }
 
     /**
+     * After reading some objects from the stream, setting a filter is disallowed.
+     * If the filter was allowed to be set, it would have unpredictable behavior.
+     * Objects already read would not be checked again, including class descriptors.
+     *
+     * Note: To mitigate possible incompatibility a system property can be set
+     * to revert to the old behavior but it re-enables the incorrect use.
+     */
+    @Test
+    static void testNonSettableAfterReadObject() throws IOException, ClassNotFoundException {
+        String expected1 = "text1";
+        String expected2 = "text2";
+        byte[] bytes = writeObjects(expected1, expected2);
+
+        for (boolean toggle: new boolean[] {true, false}) {
+            try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+                 ObjectInputStream ois = new ObjectInputStream(bais)) {
+                Object actual1 = toggle ? ois.readObject() : ois.readUnshared();
+                Assert.assertEquals(actual1, expected1, "unexpected string");
+                // Attempt to set filter
+                ObjectInputFilter filter = new ObjectInputFilter() {
+                    @Override
+                    public Status checkInput(FilterInfo filterInfo) {
+                        return null;
+                    }
+                };
+                ObjectInputFilter.Config.setObjectInputFilter(ois, filter);
+                if (!SET_FILTER_AFTER_READ)
+                    Assert.fail("Should not be able to set filter after readObject has been called");
+            } catch (IllegalStateException ise) {
+                // success, the exception was expected
+                if (SET_FILTER_AFTER_READ)
+                    Assert.fail("With jdk.serialSetFilterAfterRead property set = true; " +
+                            "should be able to set the filter after a read");
+            } catch (EOFException eof) {
+                Assert.fail("Should not reach end-of-file", eof);
+            }
+        }
+    }
+
+    /**
      * Test that if an Objects readReadResolve method returns an array
      * that the callback to the filter includes the proper array length.
      * @throws IOException if an error occurs
--- a/test/java/nio/channels/AsyncCloseAndInterrupt.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/test/java/nio/channels/AsyncCloseAndInterrupt.java	Thu Sep 03 04:06:33 2020 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
 
 /* @test
  * @bug 4460583 4470470 4840199 6419424 6710579 6596323 6824135 6395224 7142919
+ *      8151582
  * @run main/othervm AsyncCloseAndInterrupt
  * @summary Comprehensive test of asynchronous closing and interruption
  * @author Mark Reinhold
@@ -89,7 +90,7 @@
 
     private static void initRefuser() throws IOException {
         refuser = ServerSocketChannel.open();
-        refuser.socket().bind(wildcardAddress);
+        refuser.bind(wildcardAddress, 1);      // use minimum backlog
     }
 
     // Dead pipe source and sink
@@ -349,7 +350,7 @@
 
     static final Op CONNECT = new Op("connect") {
             void setup() {
-                waitPump("connect wait for pumping refuser ...");
+                waitPump("connect waiting for pumping refuser ...");
             }
             void doIO(InterruptibleChannel ich) throws IOException {
                 SocketChannel sc = (SocketChannel)ich;
@@ -361,7 +362,7 @@
 
     static final Op FINISH_CONNECT = new Op("finishConnect") {
             void setup() {
-                waitPump("finishConnect wait for pumping refuser ...");
+                waitPump("finishConnect waiting for pumping refuser ...");
             }
             void doIO(InterruptibleChannel ich) throws IOException {
                 SocketChannel sc = (SocketChannel)ich;
@@ -498,12 +499,11 @@
     private static volatile boolean pumpReady = false;
 
     private static void waitPump(String msg){
-        pumpReady = false;
         log.println(msg);
-
         while (!pumpReady){
             sleep(200);
         }
+        log.println(msg + " done");
     }
 
     // Create a pump thread dedicated to saturate refuser's connection backlog
@@ -520,28 +520,34 @@
 
                 // Saturate the refuser's connection backlog so that further connection
                 // attempts will be blocked
+                pumpReady = false;
                 while (!pumpDone) {
                     SocketChannel sc = SocketChannel.open();
                     sc.configureBlocking(false);
                     boolean connected = sc.connect(refuser.socket().getLocalSocketAddress());
 
                     // Assume that the connection backlog is saturated if a
-                    // client cannot connect to the refuser within 50 miliseconds
+                    // client cannot connect to the refuser within 50 milliseconds
                     long start = System.currentTimeMillis();
-                    while (!connected && (System.currentTimeMillis() - start < 50)) {
+                    while (!pumpReady && !connected
+                            && (System.currentTimeMillis() - start < 50)) {
                         connected = sc.finishConnect();
                     }
 
                     if (connected) {
                         // Retain so that finalizer doesn't close
                         refuserClients.add(sc);
-                        pumpReady = false;
                     } else {
                         sc.close();
                         pumpReady = true;
                     }
                 }
 
+                for (SocketChannel sc : refuserClients) {
+                    sc.close();
+                }
+                refuser.close();
+
                 log.println("Stop pumping refuser ...");
                 return refuserClients.size();
             }
@@ -565,8 +571,6 @@
             sleep(50);
         } while (!t.ready);
 
-        sleep(100);
-
         switch (test) {
 
         case TEST_INTR:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/security/cert/X509Certificate/X509BadCertificate.java	Thu Sep 03 04:06:33 2020 +0100
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8028431 8028591
+ * @summary Make sure that proper CertificateException is thrown
+ *          when loading bad x509 certificate
+ * @author Artem Smotrakov
+ */
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+import java.security.cert.CertificateException;
+
+public class X509BadCertificate {
+
+    public static void main(String[] args) throws Exception {
+        test("bad-cert-1.pem");
+        test("bad-cert-2.pem");
+    }
+
+    /**
+     * Parse X509 certificates.
+     */
+    static void test(String filename) throws Exception {
+        try {
+            System.out.println("Parse file " + filename);
+            File f = new File(System.getProperty("test.src", "."), filename);
+            try (FileInputStream fis = new FileInputStream(f)) {
+                CertificateFactory cf = CertificateFactory.getInstance("X509");
+                X509Certificate cert = (X509Certificate)
+                cf.generateCertificate(fis);
+            }
+            throw new Exception("Test failed: " +
+                "expected CertificateParsingException was not thrown");
+        } catch (CertificateException e) {
+            System.out.println("Test passed: expected exception was thrown: " +
+                e.toString());
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/security/cert/X509Certificate/bad-cert-1.pem	Thu Sep 03 04:06:33 2020 +0100
@@ -0,0 +1,21 @@
+-----BEGIN CERTIFICATE-----
+MIIDZzCCAk+gAwIBAgIJAJYB3qu9C2kiMA0GCSqGSIb3DQEBBQUAMEoxDTALBgNV
+BAMMBFRlc3QxDTALBgNVBAsMBEphdmExDzANBgNVBAoMBk9yYWNsZTEMMAoGA1UE
+BwwDU1BCMQswCQYDVQQGEwJSVTAeFw0xMzEyMjMwNzA4MDhaFw0yMzEyMjEwNzA4
+MDhaMEoxDTALBgNVBAMMBFRlc3QxDTALBgNVBAsMBEphdmExDzANBgNVBAoMBk9y
+YWNsZTEMMAoGA1UMBwwDU1BCMQswCQYDVQQGEwJSVTCCASIwDQYJKoZIhvcNAQEB
+BQADggEPADCCAQoCggEBAOqiCN4gFxehl547Q7/VNGbGApr+wszLdanHPucAH6Wf
+LtcRhKNUSqtBAQxEpFrTpMNEqm2GElAjiPa6m48qIjLVSvOb/9w3G/yXB8zyZbIm
+/Nfp2sT4OEaa1JSEZSpolhS4FfqYzjGQp5cn4Xn4zKjDgiceHgfLls5x2dRydQZO
+Yf91qSIioZxVHUtlo8yztkieiSaqPWt3nJ4PIwhFbsu1HVmWaYZD+nBYCKgVHqrS
+cueO98Ca4Doz73O27X1dVbQBdLS0JI7qVAG8LD388iPL8qbsOkgWPzmEQ+kLRKO4
+g7RpuwlXuwaMSh95NWaxlu4Ob6GRJQmpconYoe13+7ECAwEAAaNQME4wHQYDVR0O
+BBYEFIG8TPobXcbNbDi+zKudd9whpxoNMB8GA1UdIwQYMBaAFIG8TPobXcbNbDi+
+zKudd9whpxoNMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFRQADggEBAAynN+e7
+h+ufT5SBKN/gBuJAnF1mKIPESiipuv5KoYUGZOY8ShgYLcwY+qnbuHYFUlvq6Zns
+K4/e+x/16h32vD7dEPkNvukbvER4YJQQiN6osDfXpTPzixYftWdmtX0u8xQfwb/g
+R8DS7bazz99jVXk+jTK4yWBY+gMwEat+LyNQ5cyq8Qhi1oBKUbGRbiOts19B97fn
+Rv8TsyXN3INLGYhdVxZoD7E5tyG1ydSFmOMadulAC2epBXDHOXZnz2UWauJc0XW5
+1L/YQVri47VkdHS3tisBzELEJdLmdMDb+5tAU+lItXmTXe2/PB53WIvsEIb4t+eQ
+wY0hCj9lVJlajTQ=
+-----END CERTIFICATE-----
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/security/cert/X509Certificate/bad-cert-2.pem	Thu Sep 03 04:06:33 2020 +0100
@@ -0,0 +1,21 @@
+-----BEGIN CERTIFICATE-----
+MIIDZzCCAk+gAwIBAgIJAJYB3qu9C2kiMA0GCSqGSIb3DQEBBQUAMEoxDTALBgNV
+BAMMBFRlc3QxDTALBgNVBAsMBEphdmExDzANBgNVBAoMBk9yYWNsZTEMMAoGA1UE
+BwwDU1BCMQswCQYDVQQGEwJSVTAeFw0xMzEyMjMwNzA4MDhaFw0yMzEyMjEwNzA4
+MDhaMEoxDTALBgNVBAMMBFRlc3QxDTALBgNVBAsMBEphdmExDzANBgNVBAoMBk9y
+YWNsZTEMMAoGA1UEBwwDU1BCMQswCQYDVQQGEwJSVTCCASIwDQYJKoZIhvcNAQEB
+BQADgGEPADCCAQoCggEBAOqiCN4gFxehl547Q7/VNGbGApr+wszLdanHPucAH6Wf
+LtcRhKNUSqtBAQxEpFrTpMNEqm2GElAjiPa6m48qIjLVSvOb/9w3G/yXB8zyZbIm
+/Nfp2sT4OEaa1JSEZSpolhS4FfqYzjGQp5cn4Xn4zKjDgiceHgfLls5x2dRydQZO
+Yf91qSIioZxVHUtlo8yztkieiSaqPWt3nJ4PIwhFbsu1HVmWaYZD+nBYCKgVHqrS
+cueO98Ca4Doz73O27X1dVbQBdLS0JI7qVAG8LD388iPL8qbsOkgWPzmEQ+kLRKO4
+g7RpuwlXuwaMSh95NWaxlu4Ob6GRJQmpconYoe13+7ECAwEAAaNQME4wHQYDVR0O
+BBYEFIG8TPobXcbNbDi+zKudd9whpxoNMB8GA1UdIwQYMBaAFIG8TPobXcbNbDi+
+zKudd9whpxoNMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAAynN+e7
+h+ufT5SBKN/gBuJAnF1mKIPESiipuv5KoYUGZOY8ShgYLcwY+qnbuHYFUlvq6Zns
+K4/e+x/16h32vD7dEPkNvukbvER4YJQQiN6osDfXpTPzixYftWdmtX0u8xQfwb/g
+R8DS7bazz99jVXk+jTK4yWBY+gMwEat+LyNQ5cyq8Qhi1oBKUbGRbiOts19B97fn
+Rv8TsyXN3INLGYhdVxZoD7E5tyG1ydSFmOMadulAC2epBXDHOXZnz2UWauJc0XW5
+1L/YQVri47VkdHS3tisBzELEJdLmdMDb+5tAU+lItXmTXe2/PB53WIvsEIb4t+eQ
+wY0hCj9lVJlajTQ=
+-----END CERTIFICATE-----
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/concurrent/ConcurrentLinkedQueue/RemoveLeak.java	Thu Sep 03 04:06:33 2020 +0100
@@ -0,0 +1,60 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Written by Martin Buchholz with assistance from members of JCP
+ * JSR-166 Expert Group and released to the public domain, as
+ * explained at http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+/*
+ * @test
+ * @bug 8054446 8137184 8137185
+ * @summary Regression test for memory leak in remove(Object)
+ * @run main/othervm -Xmx2200k RemoveLeak
+ */
+
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+public class RemoveLeak {
+    public static void main(String[] args) {
+        int i = 0;
+        // Without bug fix, OutOfMemoryError was observed at iteration 65120
+        int iterations = 10 * 65120;
+        try {
+            ConcurrentLinkedQueue<Long> queue = new ConcurrentLinkedQueue<>();
+            queue.add(0L);
+            while (i++ < iterations) {
+                queue.add(1L);
+                queue.remove(1L);
+            }
+        } catch (Error t) {
+            System.err.printf("failed at iteration %d/%d%n", i, iterations);
+            throw t;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/imageio/plugins/gif/GIFCodeSizeTest.java	Thu Sep 03 04:06:33 2020 +0100
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8238842
+ * @summary Test incorrect code size results in IOException
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import javax.imageio.ImageIO;
+
+public class GIFCodeSizeTest {
+
+    static final byte[] DATA =  {
+        (byte)0x47, (byte)0x49, (byte)0x46, (byte)0x38, (byte)0x37,
+        (byte)0x61, (byte)0x02, (byte)0x00, (byte)0x02, (byte)0x00,
+        (byte)0x80, (byte)0x00, (byte)0x80, (byte)0x00, (byte)0xff,
+        (byte)0xff, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x2c,
+        (byte)0x00, (byte)0x00, (byte)0x01, (byte)0x00, (byte)0x02,
+        (byte)0x00, (byte)0x02, (byte)0x00, (byte)0x00, (byte)0x12,
+        (byte)0x02, (byte)0x84, (byte)0x51, (byte)0x00, (byte)0x3b
+    };
+
+    public static void main(String[] args) /*throws Exception */{
+        try {
+            ImageIO.read(new ByteArrayInputStream(DATA));
+        } catch (IOException e) {
+        }
+    }
+}
--- a/test/javax/swing/JRadioButton/8033699/bug8033699.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/test/javax/swing/JRadioButton/8033699/bug8033699.java	Thu Sep 03 04:06:33 2020 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
  * @test
  * @library ../../regtesthelpers
  * @build Util
- * @bug 8033699
+ * @bug 8033699 8226892
  * @summary  Incorrect radio button behavior when pressing tab key
  * @author Vivi An
  * @run main bug8033699
@@ -86,6 +86,9 @@
 
         // down key circle back to first button in grouped radio button
         runTest8();
+
+        // Verify that ActionListener is called when a RadioButton is selected using arrow key.
+        runTest9();
     }
 
     private static void createAndShowGUI() {
@@ -239,6 +242,59 @@
         });
     }
 
+    private static Boolean actRB1 = false;
+    private static Boolean actRB2 = false;
+    private static Boolean actRB3 = false;
+
+    // JDK-8226892: Verify that ActionListener is called when a RadioButton is selected using arrow key.
+    private static void runTest9() throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+              radioBtn1.setSelected(true);
+              radioBtn1.requestFocusInWindow();
+            }
+        });
+
+        ActionListener actLrRB1 = new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+              actRB1 = true;
+            }
+        };
+        ActionListener actLrRB2 = new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+              actRB2 = true;
+            }
+        };
+        ActionListener actLrRB3 = new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+              actRB3 = true;
+            }
+        };
+
+        radioBtn1.addActionListener(actLrRB1);
+        radioBtn2.addActionListener(actLrRB2);
+        radioBtn3.addActionListener(actLrRB3);
+
+        hitKey(robot, KeyEvent.VK_DOWN);
+        hitKey(robot, KeyEvent.VK_DOWN);
+        hitKey(robot, KeyEvent.VK_DOWN);
+
+        String failMessage = "ActionListener not invoked when selected using arrow key.";
+        if (!actRB2) {
+            throw new RuntimeException("RadioButton 2: " + failMessage);
+        }
+        if (!actRB3) {
+            throw new RuntimeException("RadioButton 3: " + failMessage);
+        }
+        if (!actRB1) {
+            throw new RuntimeException("RadioButton 1: " + failMessage);
+        }
+
+        radioBtn1.removeActionListener(actLrRB1);
+        radioBtn2.removeActionListener(actLrRB2);
+        radioBtn3.removeActionListener(actLrRB3);
+    }
+
     private static void hitKey(Robot robot, int keycode) {
         robot.keyPress(keycode);
         robot.keyRelease(keycode);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/security/ssl/SessionIdCollisionTest.java	Thu Sep 03 04:06:33 2020 +0100
@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) 2019, Red Hat Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+import java.lang.reflect.Constructor;
+import java.security.SecureRandom;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * @test
+ * @bug 8203190
+ * @summary Manual test to verify number of collisions in
+ *          sun.security.ssl.SessionId.hashCode()
+ * @run main/manual SessionIdCollisionTest 100 20480 10000000
+ */
+
+/**
+ *
+ * Notes:
+ * - This is a manual test, not run automatically.
+ * - New default value of javax.net.ssl.sessionCacheSize in JDK 12+ is 20480
+ * - According to JDK-8210985 24 hours expired cache may exceed several million
+ *   entries = > 10_000_000
+ *
+ * Example usage: java SessionIdCollissionTest 100 20480 10000000
+ *
+ * Expected outcome of running the test is to see fewer collisions and, more
+ * importantly fewer elements in buckets when there are collisions. See:
+ * http://mail.openjdk.java.net/pipermail/jdk8u-dev/2019-May/009345.html
+ *
+ */
+public class SessionIdCollisionTest {
+
+    private List<Integer> prepareHashCodes(int total) throws Exception {
+        Class<?> sessionIdClass = Class.forName("sun.security.ssl.SessionId");
+        Constructor<?> c = sessionIdClass.getDeclaredConstructor(byte[].class);
+        c.setAccessible(true);
+        // case of rejoinable session ids generates 32 random bytes
+        byte[] sessionIdBytes = new byte[32];
+        List<Integer> hashCodes = new ArrayList<>();
+        for (int i = 0; i < total; i++) {
+            SecureRandom random = new SecureRandom();
+            random.nextBytes(sessionIdBytes);
+            Object sessionId = c.newInstance(sessionIdBytes);
+            int hashCode = sessionId.hashCode();
+            hashCodes.add(hashCode);
+        }
+        return hashCodes;
+    }
+
+    private void printSummary(boolean withDistribution,
+                              List<Integer> hashCodes) throws Exception {
+        final int bound = hashCodes.size();
+        Collections.sort(hashCodes);
+        int collisions = 0;
+        Map<Integer, List<Integer>> collCountsReverse = new HashMap<>();
+        for (int i = 0; i < bound - 1; i++) {
+            int oldval = hashCodes.get(i);
+            int nextval = hashCodes.get(i+1);
+            if (oldval == nextval) {
+                collisions++;
+                if (i == bound - 2) { // last elements
+                    updateCollCountsReverse(collisions, collCountsReverse, oldval);
+                }
+            } else {
+                updateCollCountsReverse(collisions, collCountsReverse, oldval);
+                collisions = 0;
+                if (i == bound - 2) { // last elements
+                    updateCollCountsReverse(collisions, collCountsReverse, nextval);
+                }
+            }
+        }
+        if (withDistribution) {
+            System.out.println("---- distribution ----");
+        }
+        int collCount = 0;
+        int maxLength = 0;
+        List<Integer> sorted = new ArrayList<>(collCountsReverse.size());
+        sorted.addAll(collCountsReverse.keySet());
+        Collections.sort(sorted);
+        for (Integer coll: sorted) {
+            List<Integer> hc = collCountsReverse.get(coll);
+            if (withDistribution) {
+                System.out.printf("Hashcodes with %02d collisions | " +
+                                  "hashCodes: %s\n", coll, hc.toString());
+            }
+            collCount += coll * hc.size();
+            if (coll > maxLength) {
+                maxLength = coll;
+            }
+        }
+        if (withDistribution) {
+            System.out.println("---- distribution ----");
+        }
+        System.out.println("Total number of collisions: " + collCount);
+        if (collCount > 0) {
+            System.out.println("Max length of collision list over all buckets: " +
+                                maxLength);
+        }
+    }
+
+    private void updateCollCountsReverse(int collisions,
+            Map<Integer, List<Integer>> reverse, int val) {
+        List<Integer> hc = reverse.get(collisions);
+        if (hc == null) {
+            hc = new ArrayList<>();
+            hc.add(val);
+            reverse.put(collisions, hc);
+        } else {
+            hc.add(val);
+        }
+    }
+
+    public void doCollissionTest(int total) throws Exception {
+        System.out.println("Collision test for " + total + " sessions:");
+        System.out.println("------------------------------------------------");
+        List<Integer> hashcodes = prepareHashCodes(total);
+        printSummary(false, hashcodes);
+        System.out.println();
+    }
+
+    public static void main(String[] args) throws Exception {
+        if (args.length < 1) {
+            System.err.println("java " + SessionIdCollisionTest.class.getSimpleName() +
+                               "<num-sessions> [<num-sessions> ...]");
+            System.exit(1);
+        }
+        SessionIdCollisionTest collTest = new SessionIdCollisionTest();
+        for (int i = 0; i < args.length; i++) {
+            int total = Integer.parseInt(args[i]);
+            collTest.doCollissionTest(total);
+        }
+    }
+
+}
--- a/test/sun/security/util/DerInputBuffer/TimeParsing.java	Sat Apr 18 19:25:55 2020 +0100
+++ b/test/sun/security/util/DerInputBuffer/TimeParsing.java	Thu Sep 03 04:06:33 2020 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 4558835 4915146
+ * @bug 4558835 4915146 8181841
  * @summary Verify timezone offset and fractional seconds are correctly parsed
  */
 
@@ -76,6 +76,10 @@
   private final static byte[] GEN_FRACT3_ZULU =
     {0x18, 0x13, 0x32, 0x30, 0x30, 0x31, 0x30, 0x38, 0x31, 0x30, 0x31, 0x37, 0x34, 0x33, 0x35, 0x31, 0x2e, 0x37, 0x36, 0x35, 0x5a};
 
+  // 20010810174351.7654Z
+  private final static byte[] GEN_FRACT4_ZULU =
+    {0x18, 0x14, 0x32, 0x30, 0x30, 0x31, 0x30, 0x38, 0x31, 0x30, 0x31, 0x37, 0x34, 0x33, 0x35, 0x31, 0x2e, 0x37, 0x36, 0x35, 0x34, 0x5a};
+
   // 20010810184351.7+0100
   private final static byte[] GEN_FRACT1_PLUS1 =
     {0x18, 0x15, 0x32, 0x30, 0x30, 0x31, 0x30, 0x38, 0x31, 0x30, 0x31, 0x38, 0x34, 0x33, 0x35, 0x31, 0x2e, 0x37, 0x2b, 0x30, 0x31, 0x30, 0x30};
@@ -88,10 +92,17 @@
   private final static byte[] GEN_FRACT3_PLUS1 =
     {0x18, 0x17, 0x32, 0x30, 0x30, 0x31, 0x30, 0x38, 0x31, 0x30, 0x31, 0x38, 0x34, 0x33, 0x35, 0x31, 0x2e, 0x37, 0x36, 0x35, 0x2b, 0x30, 0x31, 0x30, 0x30};
 
+  // 20010810184351.7654+0100
+  private final static byte[] GEN_FRACT4_PLUS1 =
+    {0x18, 0x18, 0x32, 0x30, 0x30, 0x31, 0x30, 0x38, 0x31, 0x30, 0x31, 0x38, 0x34, 0x33, 0x35, 0x31, 0x2e, 0x37, 0x36, 0x35, 0x34, 0x2b, 0x30, 0x31, 0x30, 0x30};
+
   // 20010810184351,765+0100
   private final static byte[] GEN_FRACT3_COMMA_PLUS1 =
     {0x18, 0x17, 0x32, 0x30, 0x30, 0x31, 0x30, 0x38, 0x31, 0x30, 0x31, 0x38, 0x34, 0x33, 0x35, 0x31, 0x2c, 0x37, 0x36, 0x35, 0x2b, 0x30, 0x31, 0x30, 0x30};
 
+  // 20010810184351,7654+0100
+  private final static byte[] GEN_FRACT4_COMMA_PLUS1 =
+    {0x18, 0x18, 0x32, 0x30, 0x30, 0x31, 0x30, 0x38, 0x31, 0x30, 0x31, 0x38, 0x34, 0x33, 0x35, 0x31, 0x2c, 0x37, 0x36, 0x35, 0x34, 0x2b, 0x30, 0x31, 0x30, 0x30};
 
   private static Date decodeUTC(byte[] b) throws IOException {
     DerInputStream derin = new DerInputStream(b);
@@ -145,6 +156,8 @@
     checkGeneralized(d3, GEN_FRACT3_ZULU, "fractional seconds (Zulu)");
     checkGeneralized(d3, GEN_FRACT3_PLUS1, "fractional seconds (+0100)");
     checkGeneralized(d3, GEN_FRACT3_COMMA_PLUS1, "fractional seconds (+0100)");
+    checkGeneralized(d3, GEN_FRACT4_ZULU, "fractional seconds (Zulu)");
+    checkGeneralized(d3, GEN_FRACT4_PLUS1, "fractional seconds (+0100)");
+    checkGeneralized(d3, GEN_FRACT4_COMMA_PLUS1, "fractional seconds (+0100)");
   }
-
 }