Skip to content

tests: Fix "Invalid read of size 1"

Bastien Nocera requested to merge wip/hadess/tests-fix-invalid-read into master

The data might not be NULL-terminated, so don't read past the size:

==8841== Invalid read of size 1
==8841==    at 0x483BBF4: strlen (vg_replace_strmem.c:461)
==8841==    by 0x7F5552D: __vfprintf_internal (in /usr/lib64/libc-2.29.so)
==8841==    by 0x7F66BC4: __vasprintf_internal (in /usr/lib64/libc-2.29.so)
==8841==    by 0x7E5E5AD: g_vasprintf (gprintf.c:330)
==8841==    by 0x7E378FF: g_strdup_vprintf (gstrfuncs.c:514)
==8841==    by 0x7E3799B: g_strdup_printf (gstrfuncs.c:540)
==8841==    by 0x403651: test_doc_resources (test-gepub.c:257)
==8841==    by 0x403651: main (test-gepub.c:452)
==8841==  Address 0x1d5931ff is 0 bytes after a block of size 3,247 alloc'd
==8841==    at 0x483AB1A: calloc (vg_replace_malloc.c:762)
==8841==    by 0x7E1E580: g_malloc0 (gmem.c:129)
==8841==    by 0x484BDAE: gepub_archive_read_entry (gepub-archive.c:149)
==8841==    by 0x484BDAE: gepub_archive_read_entry (gepub-archive.c:132)
==8841==    by 0x484C441: gepub_doc_get_resource_by_id (gepub-doc.c:537)
==8841==    by 0x403632: test_doc_resources (test-gepub.c:255)
==8841==    by 0x403632: main (test-gepub.c:452)
Edited by Bastien Nocera

Merge request reports