diff options
author | Svet Ganov <svetoslavganov@google.com> | 2014-10-31 16:56:52 -0700 |
---|---|---|
committer | Svetoslav Ganov <svetoslavganov@google.com> | 2014-11-01 00:06:08 +0000 |
commit | fce84f035c35606c5707e735f503f7bdcfd5b2a1 (patch) | |
tree | c1c7d85246023ab80c6f25df8e47e390f907ddfa /core/jni/android | |
parent | e1678ddf7a8311c79ccba5a6b6183f9484fa1f1f (diff) | |
download | frameworks_base-fce84f035c35606c5707e735f503f7bdcfd5b2a1.zip frameworks_base-fce84f035c35606c5707e735f503f7bdcfd5b2a1.tar.gz frameworks_base-fce84f035c35606c5707e735f503f7bdcfd5b2a1.tar.bz2 |
Crash apps that print malformed or password protected PDFs.
If apps are writing malformed content (typically not a PDF file) or if the
PDF content they provide to the print system is password protected, are now
crashed as both of these are app bugs.
bug:17636435
Change-Id: Ifce6a3199e587448dd38f6a84290a965c24b698b
Diffstat (limited to 'core/jni/android')
-rw-r--r-- | core/jni/android/graphics/pdf/PdfEditor.cpp | 13 | ||||
-rw-r--r-- | core/jni/android/graphics/pdf/PdfRenderer.cpp | 13 |
2 files changed, 22 insertions, 4 deletions
diff --git a/core/jni/android/graphics/pdf/PdfEditor.cpp b/core/jni/android/graphics/pdf/PdfEditor.cpp index 2b756e2..ed6f1d6 100644 --- a/core/jni/android/graphics/pdf/PdfEditor.cpp +++ b/core/jni/android/graphics/pdf/PdfEditor.cpp @@ -89,8 +89,17 @@ static jlong nativeOpen(JNIEnv* env, jclass thiz, jint fd, jlong size) { if (!document) { const long error = FPDF_GetLastError(); - jniThrowException(env, "java/io/IOException", - "cannot create document. Error:" + error); + switch (error) { + case FPDF_ERR_PASSWORD: + case FPDF_ERR_SECURITY: { + jniThrowException(env, "java/lang/SecurityException", + "cannot create document. Error:" + error); + } break; + default: { + jniThrowException(env, "java/io/IOException", + "cannot create document. Error:" + error); + } break; + } destroyLibraryIfNeeded(); return -1; } diff --git a/core/jni/android/graphics/pdf/PdfRenderer.cpp b/core/jni/android/graphics/pdf/PdfRenderer.cpp index 303ddea..357d3c0 100644 --- a/core/jni/android/graphics/pdf/PdfRenderer.cpp +++ b/core/jni/android/graphics/pdf/PdfRenderer.cpp @@ -82,8 +82,17 @@ static jlong nativeCreate(JNIEnv* env, jclass thiz, jint fd, jlong size) { if (!document) { const long error = FPDF_GetLastError(); - jniThrowException(env, "java/io/IOException", - "cannot create document. Error:" + error); + switch (error) { + case FPDF_ERR_PASSWORD: + case FPDF_ERR_SECURITY: { + jniThrowException(env, "java/lang/SecurityException", + "cannot create document. Error:" + error); + } break; + default: { + jniThrowException(env, "java/io/IOException", + "cannot create document. Error:" + error); + } break; + } destroyLibraryIfNeeded(); return -1; } |