Merge pull request #2923 from Patater/reduce-ram-pem-csr

x509write_csr: Reduce stack usage of mbedtls_x509write_csr_pem()
This commit is contained in:
Jaeden Amero 2019-11-14 16:39:48 +00:00 committed by GitHub
commit df8185eae3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -264,17 +264,16 @@ int mbedtls_x509write_csr_pem( mbedtls_x509write_csr *ctx, unsigned char *buf, s
void *p_rng )
{
int ret;
unsigned char output_buf[4096];
size_t olen = 0;
if( ( ret = mbedtls_x509write_csr_der( ctx, output_buf, sizeof(output_buf),
if( ( ret = mbedtls_x509write_csr_der( ctx, buf, size,
f_rng, p_rng ) ) < 0 )
{
return( ret );
}
if( ( ret = mbedtls_pem_write_buffer( PEM_BEGIN_CSR, PEM_END_CSR,
output_buf + sizeof(output_buf) - ret,
buf + size - ret,
ret, buf, size, &olen ) ) != 0 )
{
return( ret );