src/solaris/native/java/util/FileSystemPreferences.c

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2001, 2012, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2001, 2014, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 37,51 **** JNIEXPORT jint JNICALL Java_java_util_prefs_FileSystemPreferences_chmod(JNIEnv *env, jclass thisclass, jstring java_fname, jint permission) { const char *fname = JNU_GetStringPlatformChars(env, java_fname, JNI_FALSE); ! int result; result = chmod(fname, permission); if (result != 0) result = errno; JNU_ReleaseStringPlatformChars(env, java_fname, fname); return (jint) result; } #if defined(_ALLBSD_SOURCE) typedef struct flock FLOCK; --- 37,53 ---- JNIEXPORT jint JNICALL Java_java_util_prefs_FileSystemPreferences_chmod(JNIEnv *env, jclass thisclass, jstring java_fname, jint permission) { const char *fname = JNU_GetStringPlatformChars(env, java_fname, JNI_FALSE); ! int result = -1; ! if (fname) { result = chmod(fname, permission); if (result != 0) result = errno; JNU_ReleaseStringPlatformChars(env, java_fname, fname); + } return (jint) result; } #if defined(_ALLBSD_SOURCE) typedef struct flock FLOCK;
*** 62,75 **** Java_java_util_prefs_FileSystemPreferences_lockFile0(JNIEnv *env, jclass thisclass, jstring java_fname, jint permission, jboolean shared) { const char *fname = JNU_GetStringPlatformChars(env, java_fname, JNI_FALSE); int fd, rc; int result[2]; ! jintArray javaResult; int old_umask; FLOCK fl; fl.l_whence = SEEK_SET; fl.l_len = 0; fl.l_start = 0; if (shared == JNI_TRUE) { fl.l_type = F_RDLCK; --- 64,80 ---- Java_java_util_prefs_FileSystemPreferences_lockFile0(JNIEnv *env, jclass thisclass, jstring java_fname, jint permission, jboolean shared) { const char *fname = JNU_GetStringPlatformChars(env, java_fname, JNI_FALSE); int fd, rc; int result[2]; ! jintArray javaResult = NULL; int old_umask; FLOCK fl; + if (!fname) + return javaResult; + fl.l_whence = SEEK_SET; fl.l_len = 0; fl.l_start = 0; if (shared == JNI_TRUE) { fl.l_type = F_RDLCK;
*** 102,111 **** --- 107,117 ---- result[0] = fd; } } JNU_ReleaseStringPlatformChars(env, java_fname, fname); javaResult = (*env)->NewIntArray(env,2); + if (javaResult) (*env)->SetIntArrayRegion(env, javaResult, 0, 2, result); return javaResult; }