1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-21 10:26:06 +03:00

Some fixes after going through the test harness

git-svn-id: svn://svn.code.sf.net/p/axtls/code/trunk@222 9a5d90b5-6617-0410-8a86-bb477d3ed2e3
This commit is contained in:
cameronrich 2012-02-11 11:30:45 +00:00
parent ffa4da45ee
commit af155d91d9
3 changed files with 29 additions and 24 deletions

View File

@ -349,14 +349,19 @@ EXP_FUNC int STDCALL base64_decode(const char *in, int len,
y = t = 0; y = t = 0;
} }
if (z >= *outlen) /* check that we don't go past the output buffer */ /* check that we don't go past the output buffer */
if (outlen && z >= *outlen)
{
printf("Stuff %d, %d\n", z, *outlen);
goto error; goto error;
}
} }
if (y != 0) if (y != 0)
goto error; goto error;
*outlen = z; *outlen = z;
ret = 0; ret = 0;
error: error:

View File

@ -291,34 +291,34 @@ static int asn1_get_printable_str(const uint8_t *buf, int *offset, char **str)
int asn1_type = buf[*offset]; int asn1_type = buf[*offset];
/* some certs have this awful crud in them for some reason */ /* some certs have this awful crud in them for some reason */
if (buf[asn1_type] != ASN1_PRINTABLE_STR && if (asn1_type != ASN1_PRINTABLE_STR &&
buf[asn1_type] != ASN1_PRINTABLE_STR2 && asn1_type != ASN1_PRINTABLE_STR2 &&
buf[asn1_type] != ASN1_TELETEX_STR && asn1_type != ASN1_TELETEX_STR &&
buf[asn1_type] != ASN1_IA5_STR && asn1_type != ASN1_IA5_STR &&
buf[asn1_type] != ASN1_UNICODE_STR) asn1_type != ASN1_UNICODE_STR)
goto end_pnt_str; goto end_pnt_str;
(*offset)++; (*offset)++;
len = get_asn1_length(buf, offset); len = get_asn1_length(buf, offset);
if (buf[asn1_type - 1] == ASN1_UNICODE_STR) if (asn1_type == ASN1_UNICODE_STR)
{ {
int i; int i;
*str = (char *)malloc(len/2+1); /* allow for null */ *str = (char *)malloc(len/2+1); /* allow for null */
for (i = 0; i < len; i += 2) for (i = 0; i < len; i += 2)
(*str)[i/2] = buf[*offset + i + 1]; (*str)[i/2] = buf[*offset + i + 1];
(*str)[len/2] = 0; /* null terminate */ (*str)[len/2] = 0; /* null terminate */
} }
else else
{ {
*str = (char *)malloc(len+1); /* allow for null */ *str = (char *)malloc(len+1); /* allow for null */
memcpy(*str, &buf[*offset], len); memcpy(*str, &buf[*offset], len);
(*str)[len] = 0; /* null terminate */ (*str)[len] = 0; /* null terminate */
} }
*offset += len; *offset += len;
end_pnt_str: end_pnt_str:
return len; return len;

View File

@ -259,7 +259,6 @@ static int pem_decrypt(const char *where, const char *end,
/* turn base64 into binary */ /* turn base64 into binary */
pem_size = (int)(end-start); pem_size = (int)(end-start);
ssl_obj->len = sizeof(ssl_obj->buf);
if (base64_decode(start, pem_size, ssl_obj->buf, &ssl_obj->len) != 0) if (base64_decode(start, pem_size, ssl_obj->buf, &ssl_obj->len) != 0)
goto error; goto error;
@ -315,6 +314,7 @@ static int new_pem_obj(SSL_CTX *ssl_ctx, int is_cacert, char *where,
/* 4/3 bigger than what we need but so what */ /* 4/3 bigger than what we need but so what */
ssl_obj->buf = (uint8_t *)calloc(1, pem_size); ssl_obj->buf = (uint8_t *)calloc(1, pem_size);
ssl_obj->len = pem_size;
if (i == IS_RSA_PRIVATE_KEY && if (i == IS_RSA_PRIVATE_KEY &&
strstr(start, "Proc-Type:") && strstr(start, "Proc-Type:") &&