More paranoid input checks, random error injection

Check for NULL input data buffers and set values to NULL after freeing()
local variables to avoid memory corruption on use-after-freee.

Add lots of error injection in the host testing to help find bugs on
the PC where they're easier to debug.
This commit is contained in:
Earle F. Philhower, III committed 2018-01-20 21:08:13 -08:00
1 parent f16cd2b269
commit d04beb1105
3 files changed
+27 -3

No files matched your search

+9 -1
View File
@@ -46,7 +46,7 @@ bool AudioFileSourceHTTPStream::open(const char *url)
return false;
}
size = http.getSize();
free(saveURL);
free(saveURL); saveURL = NULL;
saveURL = strdup(url);
return true;
}
@@ -58,11 +58,19 @@ AudioFileSourceHTTPStream::~AudioFileSourceHTTPStream()
uint32_t AudioFileSourceHTTPStream::read(void *data, uint32_t len)
{
if (data==NULL) {
Serial.printf_P(PSTR("ERROR! AudioFileSourceHTTPStream::read passed NULL data\n"));
return 0;
}
return readInternal(data, len, false);
}
uint32_t AudioFileSourceHTTPStream::readNonBlock(void *data, uint32_t len)
{
if (data==NULL) {
Serial.printf_P(PSTR("ERROR! AudioFileSourceHTTPStream::readNonBlock passed NULL data\n"));
return 0;
}
return readInternal(data, len, true);
}