W-M-R commented on code in PR #2762:
URL: https://github.com/apache/nuttx-apps/pull/2762#discussion_r1809758646
##########
testing/kasantest/kasantest.c:
##########
@@ -39,6 +39,16 @@
#include <nuttx/mm/mm.h>
#include <nuttx/mm/kasan.h>
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define LABEL_CHAR_POINTER(p) \
+ do { \
+ uint32_t stack; \
+ *(uint32_t *)p = stack ? stack : 0xdeadbeef; \
Review Comment:
Yes, I want the following two examples to return false by replace the random
value with the uninitialized value on the stackļ¼even though Kasan does not
detect it
static bool test_heap_illegal_strcmp(FAR struct mm_heap_s *heap, size_t size)
{
FAR char *mem = mm_malloc(heap, size);
size = mm_malloc_size(heap, mem);
LABEL_CHAR_POINTER(mem);
return strcmp(mem, mem + size) == 0;
}
static bool test_heap_illegal_strncmp(FAR struct mm_heap_s *heap,
size_t size)
{
FAR char *mem1 = mm_malloc(heap, size / 2);
FAR char *mem2 = mm_malloc(heap, size / 2);
size = mm_malloc_size(heap, mem2);
LABEL_CHAR_POINTER(mem1);
return strncmp(mem1, mem2 + size, size) == 0; }
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]