summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2016-07-17 16:52:29 +0800
committerSebastian Rasmussen <sebras@gmail.com>2016-07-17 22:33:52 +0800
commitbbb324fad31db437d668eb4891473231c3520792 (patch)
tree627260d912dcd6528e29e62096a84930309ba7f5 /platform
parent8b6cc5f00e4d3f1a43e677a43a2a809f6132a196 (diff)
downloadmupdf-bbb324fad31db437d668eb4891473231c3520792.tar.xz
JNI: Validate that page indicies are always positive.
Diffstat (limited to 'platform')
-rw-r--r--platform/java/mupdf_native.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/platform/java/mupdf_native.c b/platform/java/mupdf_native.c
index 332f87ab..762e59c9 100644
--- a/platform/java/mupdf_native.c
+++ b/platform/java/mupdf_native.c
@@ -5172,13 +5172,14 @@ FUN(PDFDocument_countPages)(JNIEnv *env, jobject self)
}
JNIEXPORT jobject JNICALL
-FUN(PDFDocument_findPage)(JNIEnv *env, jobject self, jint at)
+FUN(PDFDocument_findPage)(JNIEnv *env, jobject self, jint jat)
{
fz_context *ctx = get_context(env);
pdf_document *pdf = from_PDFDocument(env, self);
+ size_t at = (size_t) jat;
pdf_obj *obj = NULL;
- if (ctx == NULL || pdf == NULL)
+ if (ctx == NULL || pdf == NULL || jat < 0)
return NULL;
fz_try(ctx)
@@ -5299,13 +5300,14 @@ FUN(PDFDocument_addPage)(JNIEnv *env, jobject self, jobject jmediabox, jint rota
}
JNIEXPORT void JNICALL
-FUN(PDFDocument_insertPage)(JNIEnv *env, jobject self, jint at, jobject jpage)
+FUN(PDFDocument_insertPage)(JNIEnv *env, jobject self, jint jat, jobject jpage)
{
fz_context *ctx = get_context(env);
pdf_document *pdf = from_PDFDocument(env, self);
+ size_t at = (size_t) jat;
pdf_obj *page = from_PDFObject(env, jpage);
- if (ctx == NULL || pdf == NULL || page == NULL)
+ if (ctx == NULL || pdf == NULL || jat < 0 || page == NULL)
return;
fz_try(ctx)
@@ -5315,12 +5317,13 @@ FUN(PDFDocument_insertPage)(JNIEnv *env, jobject self, jint at, jobject jpage)
}
JNIEXPORT void JNICALL
-FUN(PDFDocument_deletePage)(JNIEnv *env, jobject self, jint at)
+FUN(PDFDocument_deletePage)(JNIEnv *env, jobject self, jint jat)
{
fz_context *ctx = get_context(env);
pdf_document *pdf = from_PDFDocument(env, self);
+ size_t at = (size_t) jat;
- if (ctx == NULL || pdf == NULL)
+ if (ctx == NULL || pdf == NULL || jat < 0)
return;
fz_try(ctx)