Signed-off-by: Daiki Ueno <ueno@gnu.org>
#include "num.h"
#include "x509_b64.h"
#include <c-strcase.h>
+#include "intprops.h"
#include "x509_int.h"
#include "extras/hex.h"
#include "common.h"
{
unsigned int j, i;
uint8_t *buffer = NULL;
+ size_t size;
int ret;
if (str == NULL)
return gnutls_assert_val(GNUTLS_E_INVALID_REQUEST);
/* the string will be at most twice the original */
- buffer = gnutls_malloc(str->size * 2 + 2);
+ if (!INT_MULTIPLY_OK(str->size, 2, &size) ||
+ !INT_ADD_OK(size, 2, &size))
+ return gnutls_assert_val(GNUTLS_E_MEMORY_ERROR);
+
+ buffer = gnutls_malloc(size);
if (buffer == NULL)
return gnutls_assert_val(GNUTLS_E_MEMORY_ERROR);