From 52a95bd3e1a862f8e8b0f51ed552d2f6d27ec88d Mon Sep 17 00:00:00 2001 From: Michael Geramb Date: Sat, 6 Jan 2024 10:23:01 +0100 Subject: [PATCH] Fix crash of stream buffer if PSRAM is used --- src/HAP.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/HAP.cpp b/src/HAP.cpp index 3fc126f..769c829 100644 --- a/src/HAP.cpp +++ b/src/HAP.cpp @@ -1603,12 +1603,12 @@ void Nonce::inc(){ ////////////////////////////////////// HapOut::HapStreamBuffer::HapStreamBuffer(){ - - buffer=(char *)HS_MALLOC(bufSize+1); // add 1 for adding null terminator when printing text - encBuf=(uint8_t *)HS_MALLOC(bufSize+18); // 2-byte AAD + encrypted data + 16-byte authentication tag + // Do not use PRAM form stream buffer, it would fail sometimes + buffer=(char *)malloc(bufSize+1); // add 1 for adding null terminator when printing text + encBuf=(uint8_t *)malloc(bufSize+18); // 2-byte AAD + encrypted data + 16-byte authentication tag - hash=(uint8_t *)HS_MALLOC(48); // space for SHA-384 hash output - ctx = (mbedtls_sha512_context *)HS_MALLOC(sizeof(mbedtls_sha512_context)); // space for hash context + hash=(uint8_t *)malloc(48); // space for SHA-384 hash output + ctx = (mbedtls_sha512_context *)malloc(sizeof(mbedtls_sha512_context)); // space for hash context mbedtls_sha512_init(ctx); // initialize context mbedtls_sha512_starts_ret(ctx,1); // start SHA-384 hash (note second argument=1)