ghostscript/Bug-707510-fix-LIBIDN-usage.patch

44 lines
1.4 KiB
Diff
Raw Normal View History

From d99396635f3d6ac6a1168e1af21a669e5c8f695f Mon Sep 17 00:00:00 2001
From: Ken Sharp <Ken.Sharp@artifex.com>
Date: Thu, 25 Jan 2024 12:16:56 +0000
Subject: [PATCH 6/6] Bug 707510 - fix LIBIDN usage
This wasn't a reported fault, but it bears fixing anyway.
In case of ignored errors, we need to return the input password.
And not free the buffer if we did that....
---
pdf/pdf_sec.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/pdf/pdf_sec.c b/pdf/pdf_sec.c
index 841eb72..270ed32 100644
--- a/pdf/pdf_sec.c
+++ b/pdf/pdf_sec.c
@@ -182,8 +182,11 @@ static int apply_sasl(pdf_context *ctx, char *Password, int Len, char **NewPassw
* Fortunately, the stringprep error codes are sorted to make
* this easy: the errors we want to ignore are the ones with
* codes less than 100. */
- if ((int)err < 100)
+ if ((int)err < 100) {
+ NewPassword = Password;
+ NewLen = Len;
return 0;
+ }
return_error(gs_error_ioerror);
}
@@ -301,7 +304,8 @@ error:
pdfi_countdown(Key);
gs_free_object(ctx->memory, Test, "R5 password test");
#ifdef HAVE_LIBIDN
- gs_free_object(ctx->memory, UTF8_Password, "free sasl result");
+ if (UTF8_Password != Password)
+ gs_free_object(ctx->memory, UTF8_Password, "free sasl result");
#endif
return code;
}
--
2.43.0