Path: blob/main/devel/ElectricFence/files/patch-efence.c
16465 views
--- efence.c.orig 2019-02-26 17:53:52.941236000 +01001+++ efence.c 2019-02-26 17:56:18.688752000 +01002@@ -38,6 +38,7 @@3# include <pthread.h>4# include <semaphore.h>5#endif6+#include <errno.h>78#ifdef malloc9#undef malloc10@@ -670,6 +671,27 @@11release();1213return address;14+}15+16+extern C_LINKAGE int17+posix_memalign(void **memptr, size_t alignment, size_t userSize)18+{19+ /*20+ * Per standard, posix_memalign returns EINVAL when alignment21+ * is not a power of two or power of sizeof(void*). efence22+ * doesn't check the value of alignment in memalign, but then23+ * again, memalign was never specified very well, and on some24+ * systems odd alignments could indeed have been allowed.25+ */26+ if ((alignment & (alignment - 1))27+ || alignment % sizeof (void *))28+ return EINVAL;29+30+ void *ptr = memalign (alignment, userSize);31+ if (ptr == NULL)32+ return ENOMEM;33+ *memptr = ptr;34+ return 0;35}3637/*383940