Projet

Général

Profil

0004-Adapt-lasso_base64_decode-to-the-deprecation-of-xmlS.patch

Benjamin Dauvergne, 16 novembre 2022 18:56

Télécharger (2,25 ko)

Voir les différences:

Subject: [PATCH 04/11] Adapt lasso_base64_decode to the deprecation of
 xmlSecBase64Decode (#71313)

We now use the non-deprecated new API (since xmlsec 1.2.35) xmlSecBase64Decode_ex.
 lasso/xml/tools.c | 54 ++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 42 insertions(+), 12 deletions(-)
lasso/xml/tools.c
70 70
#include <stdarg.h>
71 71
#include <ctype.h>
72 72
#include "../lasso_config.h"
73
#include "config.h"
73 74

  
74 75
/**
75 76
 * SECTION:saml2_utils
......
2514 2515
gboolean
2515 2516
lasso_base64_decode(const char *from, char **buffer, int *buffer_len)
2516 2517
{
2517
	size_t len = strlen(from);
2518
	int ret;
2518
	int fromlen = 0;
2519
	xmlChar *out = NULL;
2520
	xmlSecSize outlen = 0;
2521
	xmlSecSize decodedlen = 0;
2522
	int rc = TRUE;
2523
	int ret = 0;
2524

  
2525
	if (! from) {
2526
		return FALSE;
2527
	}
2528

  
2529
	fromlen = strlen(from);
2519 2530

  
2520 2531
	/* base64 map 4 bytes to 3 */
2521
	len = len / 4 + (len % 4 ? 1 : 0);
2522
	len *= 3;
2523
	len += 1; /* zero byte */
2524
	*buffer = g_malloc0(len);
2532
	outlen = fromlen / 4 + (fromlen % 4 ? 1 : 0);
2533
	outlen *= 3;
2534
	outlen += 1; /* zero byte */
2535
	out = g_malloc0(outlen);
2525 2536

  
2537
#if LASSO_XMLSEC_VERSION_NUMBER >= 0x010223
2526 2538
	xmlSecErrorsDefaultCallbackEnableOutput(FALSE);
2527
	ret = xmlSecBase64Decode(BAD_CAST from, BAD_CAST *buffer, len);
2539
	ret = xmlSecBase64Decode_ex(BAD_CAST from, out, outlen, &decodedlen);
2528 2540
	xmlSecErrorsDefaultCallbackEnableOutput(TRUE);
2529
	if (ret <= 0) {
2530
		lasso_release_string(*buffer);
2531
		return FALSE;
2541
	if (ret == 0) {
2542
		out[outlen - 1] = 0;
2543
		lasso_transfer_string(*buffer, *((char**)&out));
2544
		*buffer_len = decodedlen;
2545
	} else {
2546
		rc = FALSE;
2532 2547
	}
2533
	*buffer_len = ret;
2534
	return TRUE;
2548
#else
2549
	xmlSecErrorsDefaultCallbackEnableOutput(FALSE);
2550
	ret = xmlSecBase64Decode(BAD_CAST from, out, outlen);
2551
	xmlSecErrorsDefaultCallbackEnableOutput(TRUE);
2552

  
2553
	if (ret >= 0) {
2554
		out[outlen - 1] = 0;
2555
		lasso_transfer_string(*buffer, *((char**)&out));
2556
		*buffer_len = ret;
2557
	} else {
2558
		rc = FALSE;
2559
	}
2560
#endif
2561
	if (out) {
2562
		lasso_release_string(out);
2563
	}
2564
	return rc;
2535 2565
}
2536 2566

  
2537 2567
/**
2538
-