mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +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) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 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
|
||||
|
@ -1271,6 +1271,8 @@ public class FileChannelImpl
|
|||
throw new NonReadableChannelException();
|
||||
if (!shared && !writable)
|
||||
throw new NonWritableChannelException();
|
||||
if (size == 0)
|
||||
size = Long.MAX_VALUE - Math.max(0, position);
|
||||
FileLockImpl fli = new FileLockImpl(this, position, size, shared);
|
||||
FileLockTable flt = fileLockTable();
|
||||
flt.add(fli);
|
||||
|
@ -1316,6 +1318,8 @@ public class FileChannelImpl
|
|||
throw new NonReadableChannelException();
|
||||
if (!shared && !writable)
|
||||
throw new NonWritableChannelException();
|
||||
if (size == 0)
|
||||
size = Long.MAX_VALUE - Math.max(0, position);
|
||||
FileLockImpl fli = new FileLockImpl(this, position, size, shared);
|
||||
FileLockTable flt = fileLockTable();
|
||||
flt.add(fli);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue