|
|
1164f7 |
From: Ken Sharp <ken.sharp@artifex.com>
|
|
|
1164f7 |
Date: Thu, 23 Aug 2018 14:42:02 +0000 (+0100)
|
|
|
1164f7 |
Subject: Bug 699665 "memory corruption in aesdecode"
|
|
|
1164f7 |
|
|
|
1164f7 |
Bug 699665 "memory corruption in aesdecode"
|
|
|
1164f7 |
|
|
|
1164f7 |
The specimen file calls aesdecode without specifying the key to be
|
|
|
1164f7 |
used, though it does manage to do enough work with the PDF interpreter
|
|
|
1164f7 |
routines to get access to aesdecode (which isn't normally available).
|
|
|
1164f7 |
|
|
|
1164f7 |
This causes us to read uninitialised memory, which can (and often does)
|
|
|
1164f7 |
lead to a segmentation fault.
|
|
|
1164f7 |
|
|
|
1164f7 |
In this commit we set the key to NULL explicitly during intialisation
|
|
|
1164f7 |
and then check it before we read it. If its NULL we just return.
|
|
|
1164f7 |
|
|
|
1164f7 |
It seems bizarre that we don't return error codes, we should probably
|
|
|
1164f7 |
look into that at some point, but this prevents the code trying to
|
|
|
1164f7 |
read uninitialised memory.
|
|
|
1164f7 |
|
|
|
1164f7 |
https://git.ghostscript.com/?p=ghostpdl.git;a=commit;h=8e9ce5016db968b40e4ec255a3005f2786cce45f
|
|
|
1164f7 |
---
|
|
|
1164f7 |
|
|
|
1164f7 |
diff -up ghostscript-9.07/base/aes.c.cve-2018-15911 ghostscript-9.07/base/aes.c
|
|
|
1164f7 |
--- ghostscript-9.07/base/aes.c.cve-2018-15911 2018-11-23 11:23:38.826259192 +0100
|
|
|
1164f7 |
+++ ghostscript-9.07/base/aes.c 2018-11-23 11:25:19.684507346 +0100
|
|
|
1164f7 |
@@ -662,6 +662,9 @@ void aes_crypt_ecb( aes_context *ctx,
|
|
|
1164f7 |
}
|
|
|
1164f7 |
#endif
|
|
|
1164f7 |
|
|
|
1164f7 |
+ if (ctx == NULL || ctx->rk == NULL)
|
|
|
1164f7 |
+ return;
|
|
|
1164f7 |
+
|
|
|
1164f7 |
RK = ctx->rk;
|
|
|
1164f7 |
|
|
|
1164f7 |
GET_ULONG_LE( X0, input, 0 ); X0 ^= *RK++;
|
|
|
1164f7 |
diff -up ghostscript-9.07/base/saes.c.cve-2018-15911 ghostscript-9.07/base/saes.c
|
|
|
1164f7 |
--- ghostscript-9.07/base/saes.c.cve-2018-15911 2018-11-23 11:25:48.914999536 +0100
|
|
|
1164f7 |
+++ ghostscript-9.07/base/saes.c 2018-11-23 11:26:29.903287483 +0100
|
|
|
1164f7 |
@@ -120,6 +120,7 @@ s_aes_process(stream_state * ss, stream_
|
|
|
1164f7 |
gs_throw(gs_error_VMerror, "could not allocate aes context");
|
|
|
1164f7 |
return ERRC;
|
|
|
1164f7 |
}
|
|
|
1164f7 |
+ memset(state->ctx, 0x00, sizeof(aes_context));
|
|
|
1164f7 |
if (state->keylength < 1 || state->keylength > SAES_MAX_KEYLENGTH) {
|
|
|
1164f7 |
gs_throw1(gs_error_rangecheck, "invalid aes key length (%d bytes)",
|
|
|
1164f7 |
state->keylength);
|