mirror of
https://github.com/moparisthebest/pacman
synced 2024-11-11 20:05:07 -05:00
Update base64 PolarSSL code
Also adjust our code using it for the size_t adjustments made by upstream. Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
835365b817
commit
83f076d3a8
@ -65,10 +65,10 @@ static const unsigned char base64_dec_map[128] =
|
||||
/*
|
||||
* Encode a buffer into base64 format
|
||||
*/
|
||||
int base64_encode( unsigned char *dst, int *dlen,
|
||||
const unsigned char *src, int slen )
|
||||
int base64_encode( unsigned char *dst, size_t *dlen,
|
||||
const unsigned char *src, size_t slen )
|
||||
{
|
||||
int i, n;
|
||||
size_t i, n;
|
||||
int C1, C2, C3;
|
||||
unsigned char *p;
|
||||
|
||||
@ -128,10 +128,10 @@ int base64_encode( unsigned char *dst, int *dlen,
|
||||
/*
|
||||
* Decode a base64-formatted buffer
|
||||
*/
|
||||
int base64_decode( unsigned char *dst, int *dlen,
|
||||
const unsigned char *src, int slen )
|
||||
int base64_decode( unsigned char *dst, size_t *dlen,
|
||||
const unsigned char *src, size_t slen )
|
||||
{
|
||||
int i, j, n;
|
||||
size_t i, j, n;
|
||||
unsigned long x;
|
||||
unsigned char *p;
|
||||
|
||||
|
@ -25,8 +25,10 @@
|
||||
#ifndef _BASE64_H
|
||||
#define _BASE64_H
|
||||
|
||||
#define POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL 0x0010
|
||||
#define POLARSSL_ERR_BASE64_INVALID_CHARACTER 0x0012
|
||||
#include <string.h>
|
||||
|
||||
#define POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL -0x0010 /**< Output buffer too small. */
|
||||
#define POLARSSL_ERR_BASE64_INVALID_CHARACTER -0x0012 /**< Invalid character in input. */
|
||||
|
||||
/**
|
||||
* \brief Encode a buffer into base64 format
|
||||
@ -43,8 +45,8 @@
|
||||
* \note Call this function with *dlen = 0 to obtain the
|
||||
* required buffer size in *dlen
|
||||
*/
|
||||
int base64_encode( unsigned char *dst, int *dlen,
|
||||
const unsigned char *src, int slen );
|
||||
int base64_encode( unsigned char *dst, size_t *dlen,
|
||||
const unsigned char *src, size_t slen );
|
||||
|
||||
/**
|
||||
* \brief Decode a base64-formatted buffer
|
||||
@ -62,7 +64,7 @@ int base64_encode( unsigned char *dst, int *dlen,
|
||||
* \note Call this function with *dlen = 0 to obtain the
|
||||
* required buffer size in *dlen
|
||||
*/
|
||||
int base64_decode( unsigned char *dst, int *dlen,
|
||||
const unsigned char *src, int slen );
|
||||
int base64_decode( unsigned char *dst, size_t *dlen,
|
||||
const unsigned char *src, size_t slen );
|
||||
|
||||
#endif /* base64.h */
|
||||
|
@ -168,20 +168,21 @@ error:
|
||||
* @return 0 on success, 1 on failure to properly decode
|
||||
*/
|
||||
static int decode_signature(const char *base64_data,
|
||||
unsigned char **data, int *data_len) {
|
||||
unsigned char **data, size_t *data_len) {
|
||||
unsigned char *usline;
|
||||
int len;
|
||||
size_t len;
|
||||
|
||||
len = strlen(base64_data);
|
||||
usline = (unsigned char *)base64_data;
|
||||
int ret, destlen = 0;
|
||||
int ret;
|
||||
size_t destlen = 0;
|
||||
/* get the necessary size for the buffer by passing 0 */
|
||||
ret = base64_decode(NULL, &destlen, usline, len);
|
||||
if(ret != 0 && ret != POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL) {
|
||||
goto error;
|
||||
}
|
||||
/* alloc our memory and repeat the call to decode */
|
||||
MALLOC(*data, (size_t)destlen, goto error);
|
||||
MALLOC(*data, destlen, goto error);
|
||||
ret = base64_decode(*data, &destlen, usline, len);
|
||||
if(ret != 0) {
|
||||
goto error;
|
||||
@ -270,7 +271,7 @@ int _alpm_gpgme_checksig(alpm_handle_t *handle, const char *path,
|
||||
/* next create data object for the signature */
|
||||
if(base64_sig) {
|
||||
/* memory-based, we loaded it from a sync DB */
|
||||
int data_len;
|
||||
size_t data_len;
|
||||
int decode_ret = decode_signature(base64_sig,
|
||||
&decoded_sigdata, &data_len);
|
||||
if(decode_ret) {
|
||||
|
Loading…
Reference in New Issue
Block a user