8224240: Properties.load fails to throw IAE on malformed unicode in certain circumstances

Reviewed-by: smarks, rriggs, dfuchs
This commit is contained in:
Claes Redestad 2019-06-05 10:23:06 +02:00
parent a2f40ec3e1
commit 27d8c3f7b4
2 changed files with 25 additions and 6 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 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
@ -641,11 +641,16 @@ class Properties extends Hashtable<Object,Object> {
while (off < end) {
aChar = in[off++];
if (aChar == '\\') {
// No need to bounds check since LineReader::readLine excludes
// unescaped \s at the end of the line
aChar = in[off++];
if(aChar == 'u') {
// Read the xxxx
int value=0;
for (int i=0; i<4; i++) {
if (off > end - 4)
throw new IllegalArgumentException(
"Malformed \\uxxxx encoding.");
int value = 0;
for (int i = 0; i < 4; i++) {
aChar = in[off++];
switch (aChar) {
case '0': case '1': case '2': case '3': case '4':