mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
5041655: (ch) FileLock: negative param and overflow issues
Reviewed-by: alanb
This commit is contained in:
parent
7feabee426
commit
6445ee46b5
9 changed files with 247 additions and 45 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2022, 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
|
||||
|
@ -299,8 +299,10 @@ public class WindowsAsynchronousFileChannelImpl
|
|||
if (!shared && !writing)
|
||||
throw new NonWritableChannelException();
|
||||
|
||||
long len = (size != 0) ? size : Long.MAX_VALUE - Math.max(0, position);
|
||||
|
||||
// add to lock table
|
||||
FileLockImpl fli = addToFileLockTable(position, size, shared);
|
||||
FileLockImpl fli = addToFileLockTable(position, len, shared);
|
||||
if (fli == null) {
|
||||
Throwable exc = new ClosedChannelException();
|
||||
if (handler == null)
|
||||
|
@ -332,6 +334,9 @@ public class WindowsAsynchronousFileChannelImpl
|
|||
if (!shared && !writing)
|
||||
throw new NonWritableChannelException();
|
||||
|
||||
if (size == 0)
|
||||
size = Long.MAX_VALUE - Math.max(0, position);
|
||||
|
||||
// add to lock table
|
||||
final FileLockImpl fli = addToFileLockTable(position, size, shared);
|
||||
if (fli == null)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue