Uninitialized read: make the pointer non-volatile rather than the buffer

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine 2023-11-10 11:35:36 +01:00
parent da6e7a2ac2
commit ccb121500d

View File

@ -96,12 +96,13 @@ void double_free(const char *name)
void read_uninitialized_stack(const char *name)
{
(void) name;
volatile char buf[1];
char buf[1];
if (false_but_the_compiler_does_not_know) {
buf[0] = '!';
}
if (*buf != 0) {
mbedtls_printf("%u\n", (unsigned) *buf);
char *volatile p = buf;
if (*p != 0) {
mbedtls_printf("%u\n", (unsigned) *p);
}
}