Projet

Général

Profil

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

Benjamin Dauvergne, 17 novembre 2022 18:54

Télécharger (2,24 ko)

Voir les différences:

Subject: [PATCH 3/4] 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
73 73
#include <stdarg.h>
74 74
#include <ctype.h>
75 75
#include "../lasso_config.h"
76
#include "config.h"
76 77

  
77 78
/**
78 79
 * SECTION:saml2_utils
......
2521 2522
gboolean
2522 2523
lasso_base64_decode(const char *from, char **buffer, int *buffer_len)
2523 2524
{
2524
	size_t len = strlen(from);
2525
	int ret;
2525
	int fromlen = 0;
2526
	xmlChar *out = NULL;
2527
	xmlSecSize outlen = 0;
2528
	xmlSecSize decodedlen = 0;
2529
	int rc = TRUE;
2530
	int ret = 0;
2531

  
2532
	if (! from) {
2533
		return FALSE;
2534
	}
2535

  
2536
	fromlen = strlen(from);
2526 2537

  
2527 2538
	/* base64 map 4 bytes to 3 */
2528
	len = len / 4 + (len % 4 ? 1 : 0);
2529
	len *= 3;
2530
	len += 1; /* zero byte */
2531
	*buffer = g_malloc0(len);
2539
	outlen = fromlen / 4 + (fromlen % 4 ? 1 : 0);
2540
	outlen *= 3;
2541
	outlen += 1; /* zero byte */
2542
	out = g_malloc0(outlen);
2532 2543

  
2544
#if LASSO_XMLSEC_VERSION_NUMBER >= 0x010223
2533 2545
	xmlSecErrorsDefaultCallbackEnableOutput(FALSE);
2534
	ret = xmlSecBase64Decode(BAD_CAST from, BAD_CAST *buffer, len);
2546
	ret = xmlSecBase64Decode_ex(BAD_CAST from, out, outlen, &decodedlen);
2535 2547
	xmlSecErrorsDefaultCallbackEnableOutput(TRUE);
2536
	if (ret <= 0) {
2537
		lasso_release_string(*buffer);
2538
		return FALSE;
2548
	if (ret == 0) {
2549
		out[outlen - 1] = 0;
2550
		lasso_transfer_string(*buffer, *((char**)&out));
2551
		*buffer_len = decodedlen;
2552
	} else {
2553
		rc = FALSE;
2539 2554
	}
2540
	*buffer_len = ret;
2541
	return TRUE;
2555
#else
2556
	xmlSecErrorsDefaultCallbackEnableOutput(FALSE);
2557
	ret = xmlSecBase64Decode(BAD_CAST from, out, outlen);
2558
	xmlSecErrorsDefaultCallbackEnableOutput(TRUE);
2559

  
2560
	if (ret >= 0) {
2561
		out[outlen - 1] = 0;
2562
		lasso_transfer_string(*buffer, *((char**)&out));
2563
		*buffer_len = ret;
2564
	} else {
2565
		rc = FALSE;
2566
	}
2567
#endif
2568
	if (out) {
2569
		lasso_release_string(out);
2570
	}
2571
	return rc;
2542 2572
}
2543 2573

  
2544 2574
/**
2545
-