diff --git a/src/java.desktop/share/classes/java/awt/color/ICC_Profile.java b/src/java.desktop/share/classes/java/awt/color/ICC_Profile.java index 5574b3c01f8..a3e60217d15 100644 --- a/src/java.desktop/share/classes/java/awt/color/ICC_Profile.java +++ b/src/java.desktop/share/classes/java/awt/color/ICC_Profile.java @@ -57,6 +57,8 @@ import sun.java2d.cmm.Profile; import sun.java2d.cmm.ProfileDataVerifier; import sun.java2d.cmm.ProfileDeferralInfo; +import static sun.java2d.cmm.ProfileDataVerifier.HEADER_SIZE; + /** * A representation of color profile data for device independent and device * dependent color spaces based on the International Color Consortium @@ -764,8 +766,6 @@ public sealed class ICC_Profile implements Serializable */ public static final int icXYZNumberX = 8; - private static final int HEADER_SIZE = 128; - /** * Constructs an {@code ICC_Profile} object with a given ID. */ @@ -913,11 +913,11 @@ public sealed class ICC_Profile implements Serializable static byte[] getProfileDataFromStream(InputStream s) throws IOException { BufferedInputStream bis = new BufferedInputStream(s); - bis.mark(128); // 128 is the length of the ICC profile header + bis.mark(HEADER_SIZE); - byte[] header = bis.readNBytes(128); - if (header.length < 128 || header[36] != 0x61 || header[37] != 0x63 || - header[38] != 0x73 || header[39] != 0x70) { + byte[] header = bis.readNBytes(HEADER_SIZE); + if (header.length < HEADER_SIZE || header[36] != 0x61 || + header[37] != 0x63 || header[38] != 0x73 || header[39] != 0x70) { return null; /* not a valid profile */ } int profileSize = intFromBigEndian(header, 0); diff --git a/src/java.desktop/share/classes/sun/java2d/cmm/ProfileDataVerifier.java b/src/java.desktop/share/classes/sun/java2d/cmm/ProfileDataVerifier.java index e6100bbefd4..0992bf3577c 100644 --- a/src/java.desktop/share/classes/sun/java2d/cmm/ProfileDataVerifier.java +++ b/src/java.desktop/share/classes/sun/java2d/cmm/ProfileDataVerifier.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, 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 @@ -106,7 +106,7 @@ public class ProfileDataVerifier { */ private static final int MAX_TAG_COUNT = 100; - private static final int HEADER_SIZE = 128; + public static final int HEADER_SIZE = 128; private static final int TOC_OFFSET = HEADER_SIZE + 4; private static final int TOC_RECORD_SIZE = 12;