comparison src/java.base/macosx/native/libosxsecurity/KeystoreImpl.m @ 17467:f8e75da258cd

8205124: aarch32: make build work again with jvm-variant=core Reviewed-by: duke
author enevill
date Fri, 15 Jun 2018 21:24:39 +0100
parents f98d9515afea
children
comparison
equal deleted inserted replaced
1:7f8190d7b015 2:3f7beb0c2e88
1 /* 1 /*
2 * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this 7 * published by the Free Software Foundation. Oracle designates this
431 passwordChars = (*env)->GetCharArrayElements(env, passwordObj, NULL); 431 passwordChars = (*env)->GetCharArrayElements(env, passwordObj, NULL);
432 if (passwordChars == NULL) { 432 if (passwordChars == NULL) {
433 goto errOut; 433 goto errOut;
434 } 434 }
435 passwordStrRef = CFStringCreateWithCharacters(kCFAllocatorDefault, passwordChars, passwordLen); 435 passwordStrRef = CFStringCreateWithCharacters(kCFAllocatorDefault, passwordChars, passwordLen);
436
437 // clear the password and release
438 memset(passwordChars, 0, passwordLen);
439 (*env)->ReleaseCharArrayElements(env, passwordObj, passwordChars,
440 JNI_ABORT);
436 } 441 }
437 } 442 }
438 443
439 paramBlock.version = SEC_KEY_IMPORT_EXPORT_PARAMS_VERSION; 444 paramBlock.version = SEC_KEY_IMPORT_EXPORT_PARAMS_VERSION;
440 // Note that setting the flags field **requires** you to pass in a password of some kind. The keychain will not prompt you. 445 // Note that setting the flags field **requires** you to pass in a password of some kind. The keychain will not prompt you.
517 jsize passwordLen = 0; 522 jsize passwordLen = 0;
518 jchar *passwordChars = NULL; 523 jchar *passwordChars = NULL;
519 524
520 if (passwordObj) { 525 if (passwordObj) {
521 passwordLen = (*env)->GetArrayLength(env, passwordObj); 526 passwordLen = (*env)->GetArrayLength(env, passwordObj);
522 passwordChars = (*env)->GetCharArrayElements(env, passwordObj, NULL); 527
523 passwordStrRef = CFStringCreateWithCharacters(kCFAllocatorDefault, passwordChars, passwordLen); 528 if (passwordLen > 0) {
529 passwordChars = (*env)->GetCharArrayElements(env, passwordObj, NULL);
530 if (passwordChars == NULL) {
531 goto errOut;
532 }
533 passwordStrRef = CFStringCreateWithCharacters(kCFAllocatorDefault, passwordChars, passwordLen);
534
535 // clear the password and release
536 memset(passwordChars, 0, passwordLen);
537 (*env)->ReleaseCharArrayElements(env, passwordObj, passwordChars,
538 JNI_ABORT);
539 }
524 } 540 }
525 541
526 paramBlock.version = SEC_KEY_IMPORT_EXPORT_PARAMS_VERSION; 542 paramBlock.version = SEC_KEY_IMPORT_EXPORT_PARAMS_VERSION;
527 // Note that setting the flags field **requires** you to pass in a password of some kind. The keychain will not prompt you. 543 // Note that setting the flags field **requires** you to pass in a password of some kind. The keychain will not prompt you.
528 paramBlock.flags = 0; 544 paramBlock.flags = 0;