From: Jeremy Harris Date: Tue, 10 Dec 2019 20:04:15 +0000 (+0000) Subject: local_scan: align local_scan.h and docs re. store_get() X-Git-Url: https://git.exim.org/users/jgh/exim.git/commitdiff_plain/4ec0fcb6737da9bc2603056d56fbf6e41e061967 local_scan: align local_scan.h and docs re. store_get() --- diff --git a/doc/doc-docbook/spec.xfpt b/doc/doc-docbook/spec.xfpt index fd5170198..5e4822123 100644 --- a/doc/doc-docbook/spec.xfpt +++ b/doc/doc-docbook/spec.xfpt @@ -34327,12 +34327,18 @@ dropping of a TCP/IP connection), you can call &'smtp_fflush()'&, which has no arguments. It flushes the output stream, and returns a non-zero value if there is an error. -.vitem &*void&~*store_get(int)*& +.new +.vitem &*void&~*store_get(int,BOOL)*& This function accesses Exim's internal store (memory) manager. It gets a new -chunk of memory whose size is given by the argument. Exim bombs out if it ever +chunk of memory whose size is given by the first argument. +The second argument should be given as TRUE if the memory will be used for +data possibly coming from an attacker (eg. the message content), +FALSE if it is locally-sourced. +Exim bombs out if it ever runs out of memory. See the next section for a discussion of memory handling. +.wen -.vitem &*void&~*store_get_perm(int)*& +.vitem &*void&~*store_get_perm(int,BOOL)*& This function is like &'store_get()'&, but it always gets memory from the permanent pool. See the next section for a discussion of memory handling. diff --git a/src/src/local_scan.h b/src/src/local_scan.h index e0a97088f..da9a8911a 100644 --- a/src/src/local_scan.h +++ b/src/src/local_scan.h @@ -193,6 +193,14 @@ extern void smtp_vprintf(const char *, BOOL, va_list); string_sprintf_trc(fmt, US __FUNCTION__, __LINE__, __VA_ARGS__) extern uschar *string_sprintf_trc(const char *, const uschar *, unsigned, ...) ALMOST_PRINTF(1,4); +#define store_get(size, tainted) \ + store_get_3(size, tainted, __FUNCTION__, __LINE__) +extern void *store_get_3(int, BOOL, const char *, int) ALLOC ALLOC_SIZE(1) WARN_UNUSED_RESULT; +#define store_get_perm(size, tainted) \ + store_get_perm_3(size, tainted, __FUNCTION__, __LINE__) +extern void *store_get_perm_3(int, BOOL, const char *, int) ALLOC ALLOC_SIZE(1) WARN_UNUSED_RESULT; + + #if defined(LOCAL_SCAN) || defined(DLFUNC_IMPL) /* When compiling a local_scan() file we want to rename a published API, so that we can use an inlined implementation in the compiles of the main Exim files, diff --git a/src/src/store.h b/src/src/store.h index 52f211ef5..39b0f6ecf 100644 --- a/src/src/store.h +++ b/src/src/store.h @@ -34,10 +34,7 @@ tracing information for debugging. */ #define store_free(addr) \ store_free_3(addr, __FUNCTION__, __LINE__) -#define store_get(size, tainted) \ - store_get_3(size, tainted, __FUNCTION__, __LINE__) -#define store_get_perm(size, tainted) \ - store_get_perm_3(size, tainted, __FUNCTION__, __LINE__) +/* store_get & store_get_perm are in local_scan.h */ #define store_malloc(size) \ store_malloc_3(size, __FUNCTION__, __LINE__) #define store_mark(void) \ @@ -55,8 +52,7 @@ typedef void ** rmark; extern BOOL store_extend_3(void *, BOOL, int, int, const char *, int); extern void store_free_3(void *, const char *, int); -extern void *store_get_3(int, BOOL, const char *, int) ALLOC ALLOC_SIZE(1) WARN_UNUSED_RESULT; -extern void *store_get_perm_3(int, BOOL, const char *, int) ALLOC ALLOC_SIZE(1) WARN_UNUSED_RESULT; +/* store_get_3 & store_get_perm_3 are in local_scan.h */ extern void *store_malloc_3(int, const char *, int) ALLOC ALLOC_SIZE(1) WARN_UNUSED_RESULT; extern rmark store_mark_3(const char *, int); extern void *store_newblock_3(void *, BOOL, int, int, const char *, int);