summaryrefslogtreecommitdiff
path: root/libarchive/archive_read_support_format_warc.c
diff options
context:
space:
mode:
authorAlex Richardson <Alexander.Richardson@cl.cam.ac.uk>2020-12-09 16:17:22 +0000
committerAlex Richardson <Alexander.Richardson@cl.cam.ac.uk>2020-12-09 16:18:36 +0000
commit053e00de97dca3fb9fd53ea2bf26f3edf20b4233 (patch)
treed50815f365b595a29e18da8438e061030362dbbf /libarchive/archive_read_support_format_warc.c
parentc581b317cc71f964b2446b5534ebcc07be2f7cab (diff)
downloadlibarchive-053e00de97dca3fb9fd53ea2bf26f3edf20b4233.tar.gz
warc: Fix undefined behaviour in deconst() function
Creating a pointer by adding an offset to 0x1 is undefined behaviour and results in an invalid pointer when running on CHERI systems. Use a standards-compliant cast via uintptr_t instead. This was found due to a crash while running the libarchive test suite on a CHERI-RISC-V system.
Diffstat (limited to 'libarchive/archive_read_support_format_warc.c')
-rw-r--r--libarchive/archive_read_support_format_warc.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libarchive/archive_read_support_format_warc.c b/libarchive/archive_read_support_format_warc.c
index a582b81a..27329962 100644
--- a/libarchive/archive_read_support_format_warc.c
+++ b/libarchive/archive_read_support_format_warc.c
@@ -443,7 +443,7 @@ _warc_skip(struct archive_read *a)
static void*
deconst(const void *c)
{
- return (char *)0x1 + (((const char *)c) - (const char *)0x1);
+ return (void *)(uintptr_t)c;
}
static char*