aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src
diff options
context:
space:
mode:
Diffstat (limited to 'OpenKeychain/src')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java57
1 files changed, 39 insertions, 18 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java
index 9db9e700f..da532d2dc 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java
@@ -456,32 +456,53 @@ public class ImportExportOperation extends BaseOperation {
// For each public masterKey id
while (!cursor.isAfterLast()) {
- // Create an output stream
- ArmoredOutputStream arOutStream = new ArmoredOutputStream(outStream);
- String version = PgpHelper.getVersionForHeader(mContext);
- if (version != null) {
- arOutStream.setHeader("Version", version);
- }
-
long keyId = cursor.getLong(0);
+ ArmoredOutputStream arOutStream = null;
+
+ // Create an output stream
+ try {
+ arOutStream = new ArmoredOutputStream(outStream);
+ String version = PgpHelper.getVersionForHeader(mContext);
+ if (version != null) {
+ arOutStream.setHeader("Version", version);
+ }
- log.add(LogType.MSG_EXPORT_PUBLIC, 1, KeyFormattingUtils.beautifyKeyId(keyId));
+ log.add(LogType.MSG_EXPORT_PUBLIC, 1, KeyFormattingUtils.beautifyKeyId(keyId));
- { // export public key part
- byte[] data = cursor.getBlob(1);
- arOutStream.write(data);
- arOutStream.close();
+ { // export public key part
+ byte[] data = cursor.getBlob(1);
+ arOutStream.write(data);
- okPublic += 1;
+ okPublic += 1;
+ }
+ } finally {
+ // make sure this is closed
+ if (arOutStream != null) {
+ arOutStream.close();
+ }
+ arOutStream = null;
}
- // export secret key part
if (exportSecret && cursor.getInt(3) > 0) {
- log.add(LogType.MSG_EXPORT_SECRET, 2, KeyFormattingUtils.beautifyKeyId(keyId));
- byte[] data = cursor.getBlob(2);
- arOutStream.write(data);
+ try {
+ arOutStream = new ArmoredOutputStream(outStream);
+ String version = PgpHelper.getVersionForHeader(mContext);
+ if (version != null) {
+ arOutStream.setHeader("Version", version);
+ }
- okSecret += 1;
+ // export secret key part
+ log.add(LogType.MSG_EXPORT_SECRET, 2, KeyFormattingUtils.beautifyKeyId(keyId));
+ byte[] data = cursor.getBlob(2);
+ arOutStream.write(data);
+
+ okSecret += 1;
+ } finally {
+ // make sure this is closed
+ if (arOutStream != null) {
+ arOutStream.close();
+ }
+ }
}
updateProgress(progress++, numKeys);
e __KERNEL_DS 0x1b #define __KERNEL32_CS 0x3b /* * we cannot use the same code segment descriptor for user and kernel * -- not even in the long flat mode, because of different DPL /kkeil * The segment offset needs to contain a RPL. Grr. -AK * GDT layout to get 64bit syscall right (sysret hardcodes gdt offsets) */ #define __USER32_CS 0x23 /* 4*8+3 */ #define __USER_DS 0x2b /* 5*8+3 */ #define __USER_CS 0x33 /* 6*8+3 */ #define __USER32_DS __USER_DS #define __KERNEL16_CS (GDT_ENTRY_KERNELCS16 * 8) #define __KERNEL_COMPAT32_CS 0x8 #define GDT_ENTRY_TLS 1 #define GDT_ENTRY_TSS 8 /* needs two entries */ #define GDT_ENTRY_LDT 10 #define GDT_ENTRY_TLS_MIN 11 #define GDT_ENTRY_TLS_MAX 13 /* 14 free */ #define GDT_ENTRY_KERNELCS16 15 #define GDT_ENTRY_TLS_ENTRIES 3 /* TLS indexes for 64bit - hardcoded in arch_prctl */ #define FS_TLS 0 #define GS_TLS 1 #define GS_TLS_SEL ((GDT_ENTRY_TLS_MIN+GS_TLS)*8 + 3) #define FS_TLS_SEL ((GDT_ENTRY_TLS_MIN+FS_TLS)*8 + 3) #define IDT_ENTRIES 256 #define GDT_ENTRIES 16 #define GDT_SIZE (GDT_ENTRIES * 8) #define TLS_SIZE (GDT_ENTRY_TLS_ENTRIES * 8) #endif