Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2017-05-03 11:32:56 +0000
committerAlexander Kurtakov2017-05-03 12:10:58 +0000
commitd7a79717826e366be163d46dfca9bc67e410a4f5 (patch)
tree137d6d1f46fbe23a892bb3a918c92ef6a3dd0658
parent00df93cc413014222e6e309c141fd6de20f77a0b (diff)
downloadrt.equinox.bundles-d7a79717826e366be163d46dfca9bc67e410a4f5.tar.gz
rt.equinox.bundles-d7a79717826e366be163d46dfca9bc67e410a4f5.tar.xz
rt.equinox.bundles-d7a79717826e366be163d46dfca9bc67e410a4f5.zip
Bug 515880 - DNF (crash) in core.tests.net
Cleanup error handling. Change-Id: I1066a3f107086c3cebd6e7b733a443e9653c44a7 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--bundles/org.eclipse.equinox.security.linux.x86_64/keystorelinuxnative/keystoreLinuxNative.c62
-rwxr-xr-xbundles/org.eclipse.equinox.security.linux.x86_64/libkeystorelinuxnative.sobin13000 -> 12992 bytes
2 files changed, 27 insertions, 35 deletions
diff --git a/bundles/org.eclipse.equinox.security.linux.x86_64/keystorelinuxnative/keystoreLinuxNative.c b/bundles/org.eclipse.equinox.security.linux.x86_64/keystorelinuxnative/keystoreLinuxNative.c
index b2c5cbb2..9cb178a7 100644
--- a/bundles/org.eclipse.equinox.security.linux.x86_64/keystorelinuxnative/keystoreLinuxNative.c
+++ b/bundles/org.eclipse.equinox.security.linux.x86_64/keystorelinuxnative/keystoreLinuxNative.c
@@ -39,28 +39,25 @@ static void unlock_secret_service(JNIEnv *env)
GDBusConnection* dbusconnection = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
if (error != NULL) {
(*env)->ExceptionClear(env);
- char buffer [60];
- sprintf(buffer, "Unable to get secret service: %s", error->message);
- (*env)->ThrowNew(env, (* env)->FindClass(env, "java/lang/SecurityException"), buffer);
+ g_prefix_error(&error, "Unable to get DBus session bus: ");
+ (*env)->ThrowNew(env, (* env)->FindClass(env, "java/lang/SecurityException"), error->message);
g_error_free (error);
return;
}
SecretService* secretservice = secret_service_get_sync(SECRET_SERVICE_LOAD_COLLECTIONS, NULL, &error);
if (error != NULL) {
(*env)->ExceptionClear(env);
- char buffer [60];
- sprintf(buffer, "Unable to get secret service: %s", error->message);
- (*env)->ThrowNew(env, (* env)->FindClass(env, "java/lang/SecurityException"), buffer);
+ g_prefix_error(&error, "Unable to get secret service: ");
+ (*env)->ThrowNew(env, (* env)->FindClass(env, "java/lang/SecurityException"), error->message);
g_error_free (error);
return;
}
-
+
SecretCollection* defaultcollection = secret_collection_for_alias_sync(secretservice, SECRET_COLLECTION_DEFAULT, SECRET_COLLECTION_NONE, NULL, &error);
if (error != NULL) {
(*env)->ExceptionClear(env);
- char buffer [60];
- sprintf(buffer, "Unable to get secret service: %s", error->message);
- (*env)->ThrowNew(env, (* env)->FindClass(env, "java/lang/SecurityException"), buffer);
+ g_prefix_error(&error, "Unable to get secret collection: ");
+ (*env)->ThrowNew(env, (* env)->FindClass(env, "java/lang/SecurityException"), error->message);
g_error_free (error);
return;
}
@@ -75,13 +72,12 @@ static void unlock_secret_service(JNIEnv *env)
g_list_free(ul);
if (error != NULL) {
(*env)->ExceptionClear(env);
- char buffer [60];
- sprintf(buffer, "Unable to unlock: %s", error->message);
- (*env)->ThrowNew(env, (* env)->FindClass(env, "java/lang/SecurityException"), buffer);
+ g_prefix_error(&error, "Unable to unlock: ");
+ (*env)->ThrowNew(env, (* env)->FindClass(env, "java/lang/SecurityException"), error->message);
g_error_free (error);
return;
}
-
+
}
return;
}
@@ -89,53 +85,49 @@ static void unlock_secret_service(JNIEnv *env)
JNIEXPORT jstring JNICALL Java_org_eclipse_equinox_internal_security_linux_LinuxPasswordProvider_getMasterPassword(JNIEnv *env, jobject this) {
GError *error = NULL;
jstring result;
-
+
unlock_secret_service(env);
if ((*env)->ExceptionOccurred(env)) {
return NULL;
- }
-
+ }
+
gchar *password = secret_password_lookup_sync(EQUINOX_SCHEMA, NULL, &error, NULL);
-
+
if (error != NULL) {
(*env)->ExceptionClear(env);
- char buffer [60];
- sprintf(buffer, "%s. Result: %d", error->message, error->code);
- (*env)->ThrowNew(env, (* env)->FindClass(env, "java/lang/SecurityException"), buffer);
+ (*env)->ThrowNew(env, (* env)->FindClass(env, "java/lang/SecurityException"), error->message);
g_error_free (error);
return NULL;
} else if (password == NULL) {
(*env)->ExceptionClear(env);
- (*env)->ThrowNew(env, (* env)->FindClass(env, "java/lang/SecurityException"), "Unable to find password");
- return NULL;
+ (*env)->ThrowNew(env, (* env)->FindClass(env, "java/lang/SecurityException"), "Unable to find password");
+ return NULL;
} else {
result = (*env)->NewStringUTF(env, password);
- free(password);
+ free(password);
return result;
}
}
JNIEXPORT void JNICALL Java_org_eclipse_equinox_internal_security_linux_LinuxPasswordProvider_saveMasterPassword(JNIEnv *env, jobject this, jstring password) {
GError *error = NULL;
-
+
unlock_secret_service(env);
if ((*env)->ExceptionOccurred(env)) {
- return;
- }
-
+ return;
+ }
+
const char *passwordUTF = (*env)->GetStringUTFChars(env, password, NULL);
secret_password_store_sync (EQUINOX_SCHEMA, SECRET_COLLECTION_DEFAULT,
- "Equinox master password", passwordUTF, NULL, &error,
- NULL);
-
+ "Equinox master password", passwordUTF, NULL, &error,
+ NULL);
+
// free the UTF strings
(*env)->ReleaseStringUTFChars( env, password, passwordUTF );
if (error != NULL) {
- (*env)->ExceptionClear(env);
- char buffer [60];
- sprintf(buffer, "%s. Result: %d", error->message, error->code);
- (*env)->ThrowNew(env, (* env)->FindClass(env, "java/lang/SecurityException"), buffer);
+ (*env)->ExceptionClear(env);
+ (*env)->ThrowNew(env, (* env)->FindClass(env, "java/lang/SecurityException"), error->message);
g_error_free (error);
}
}
diff --git a/bundles/org.eclipse.equinox.security.linux.x86_64/libkeystorelinuxnative.so b/bundles/org.eclipse.equinox.security.linux.x86_64/libkeystorelinuxnative.so
index 06fc04ba..c32e763c 100755
--- a/bundles/org.eclipse.equinox.security.linux.x86_64/libkeystorelinuxnative.so
+++ b/bundles/org.eclipse.equinox.security.linux.x86_64/libkeystorelinuxnative.so
Binary files differ

Back to the top