8314883: Java_java_util_prefs_FileSystemPreferences_lockFile0 write result errno in missing case

Reviewed-by: jpai, shade, vtewari
This commit is contained in:
Matthias Baesken 2023-08-24 10:44:09 +00:00
parent 75e19e0d5e
commit 97b94cb1cd

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -71,7 +71,7 @@ Java_java_util_prefs_FileSystemPreferences_lockFile0(JNIEnv *env,
jclass thisclass, jstring java_fname, jint permission, jboolean shared) { jclass thisclass, jstring java_fname, jint permission, jboolean shared) {
const char *fname = JNU_GetStringPlatformChars(env, java_fname, NULL); const char *fname = JNU_GetStringPlatformChars(env, java_fname, NULL);
int fd, rc; int fd, rc;
int result[2]; int result[2] = {0, 0};
jintArray javaResult = NULL; jintArray javaResult = NULL;
int old_umask; int old_umask;
FLOCK fl; FLOCK fl;
@ -90,6 +90,7 @@ Java_java_util_prefs_FileSystemPreferences_lockFile0(JNIEnv *env,
if (shared == JNI_TRUE) { if (shared == JNI_TRUE) {
fd = open(fname, O_RDONLY, 0); fd = open(fname, O_RDONLY, 0);
result[1] = errno;
} else { } else {
old_umask = umask(0); old_umask = umask(0);
fd = open(fname, O_WRONLY|O_CREAT, permission); fd = open(fname, O_WRONLY|O_CREAT, permission);