diff --git a/JDK-8247619.patch b/JDK-8247619.patch new file mode 100644 index 0000000..c123c36 --- /dev/null +++ b/JDK-8247619.patch @@ -0,0 +1,93 @@ + +# HG changeset patch +# User mbalao +# Date 1596041533 25200 +# Node ID 6fe9792e7893a43c0718cf6d5082f62f9bc52787 +# Parent 4b5e357b4beb37ce221d1cc84b1d1de9d5b803e8 +8247619: Improve Direct Buffering of Characters +Reviewed-by: alanb, ahgross, rhalade, psandoz, andrew + +diff -r 4b5e357b4beb -r 6fe9792e7893 src/share/classes/java/nio/Buffer.java +--- a/src/share/classes/java/nio/Buffer.java Tue Dec 29 00:56:45 2020 +0000 ++++ b/src/share/classes/java/nio/Buffer.java Wed Jul 29 09:52:13 2020 -0700 +@@ -242,8 +242,8 @@ + public final Buffer position(int newPosition) { + if ((newPosition > limit) || (newPosition < 0)) + throw new IllegalArgumentException(); ++ if (mark > newPosition) mark = -1; + position = newPosition; +- if (mark > position) mark = -1; + return this; + } + +@@ -388,7 +388,8 @@ + * @return The number of elements remaining in this buffer + */ + public final int remaining() { +- return limit - position; ++ int rem = limit - position; ++ return rem > 0 ? rem : 0; + } + + /** +diff -r 4b5e357b4beb -r 6fe9792e7893 src/share/classes/java/nio/Heap-X-Buffer.java.template +--- a/src/share/classes/java/nio/Heap-X-Buffer.java.template Tue Dec 29 00:56:45 2020 +0000 ++++ b/src/share/classes/java/nio/Heap-X-Buffer.java.template Wed Jul 29 09:52:13 2020 -0700 +@@ -1,5 +1,5 @@ + /* +- * Copyright (c) 2000, 2013, 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 +@@ -234,7 +234,9 @@ + public $Type$Buffer compact() { + #if[rw] + int pos = position(); +- int rem = limit() - pos; ++ int lim = limit(); ++ assert (pos <= lim); ++ int rem = (pos <= lim ? lim - pos : 0); + System.arraycopy(hb, ix(pos), hb, ix(0), rem); + position(rem); + limit(capacity()); +diff -r 4b5e357b4beb -r 6fe9792e7893 src/share/classes/java/nio/X-Buffer.java.template +--- a/src/share/classes/java/nio/X-Buffer.java.template Tue Dec 29 00:56:45 2020 +0000 ++++ b/src/share/classes/java/nio/X-Buffer.java.template Wed Jul 29 09:52:13 2020 -0700 +@@ -1,5 +1,5 @@ + /* +- * Copyright (c) 2000, 2013, 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 +@@ -414,15 +414,23 @@ + */ + public int read(CharBuffer target) throws IOException { + // Determine the number of bytes n that can be transferred ++ int limit = limit(); ++ int pos = position(); ++ int remaining = limit - pos; ++ assert remaining >= 0; ++ if (remaining <= 0) // include equality condition when remaining == 0 ++ return -1; ++ + int targetRemaining = target.remaining(); +- int limit = limit(); +- int remaining = limit - position(); +- if (remaining == 0) +- return -1; ++ assert targetRemaining >= 0; ++ if (targetRemaining <= 0) // include condition targetRemaining == 0 ++ return 0; ++ + int n = Math.min(remaining, targetRemaining); ++ + // Set source limit to prevent target overflow + if (targetRemaining < remaining) +- limit(position() + n); ++ limit(pos + n); + try { + if (n > 0) + target.put(this); + diff --git a/java-1_8_0-openjdk.changes b/java-1_8_0-openjdk.changes index 99f5ccf..ff2f61a 100644 --- a/java-1_8_0-openjdk.changes +++ b/java-1_8_0-openjdk.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Fri Jan 29 16:28:08 UTC 2021 - Fridrich Strba + +- Added patch: + * JDK-8247619.patch + + Fix security bug of January 2021 CPU + + 8247619: Improve Direct Buffering of Characters + ------------------------------------------------------------------- Thu Nov 26 19:13:31 UTC 2020 - Fridrich Strba diff --git a/java-1_8_0-openjdk.spec b/java-1_8_0-openjdk.spec index e4bf0c9..aeedf2e 100644 --- a/java-1_8_0-openjdk.spec +++ b/java-1_8_0-openjdk.spec @@ -1,7 +1,7 @@ # # spec file for package java-1_8_0-openjdk # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2021 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -201,6 +201,7 @@ Patch1001: java-1_8_0-openjdk-suse-desktop-files.patch Patch1002: icedtea-3.8.0-s390.patch Patch2001: disable-doclint-by-default.patch Patch2002: JDK_1_8_0-8208602.patch +Patch2003: JDK-8247619.patch BuildRequires: alsa-lib-devel BuildRequires: autoconf @@ -313,7 +314,7 @@ Requires: jpackage-utils # Post requires update-alternatives to install tool update-alternatives. Requires(post): update-alternatives # Postun requires update-alternatives to uninstall tool update-alternatives. -Requires(postun): update-alternatives +Requires(postun):update-alternatives Recommends: tzdata-java8 # Standard JPackage base provides. Provides: java-%{javaver}-headless = %{version}-%{release} @@ -352,7 +353,7 @@ Requires: %{name} = %{version}-%{release} # Post requires update-alternatives to install tool update-alternatives. Requires(post): update-alternatives # Postun requires update-alternatives to uninstall tool update-alternatives. -Requires(postun): update-alternatives +Requires(postun):update-alternatives # Standard JPackage devel provides. Provides: java-%{javaver}-devel = %{version} Provides: java-devel = %{javaver} @@ -388,7 +389,7 @@ Requires: jpackage-utils # Post requires update-alternatives to install javadoc alternative. Requires(post): update-alternatives # Postun requires update-alternatives to uninstall javadoc alternative. -Requires(postun): update-alternatives +Requires(postun):update-alternatives # Standard JPackage javadoc provides. Provides: java-%{javaver}-javadoc = %{version}-%{release} Provides: java-javadoc = %{version}-%{release} @@ -539,6 +540,7 @@ patch -p0 -i %{PATCH103} patch -p0 -i %{PATCH2001} patch -p0 -i %{PATCH2002} +patch -p0 -i %{PATCH2003} (cd openjdk/common/autoconf bash ./autogen.sh