+if (!store_extend(g->s, tainted, oldsize, g->size))
+ g->s = store_newblock(g->s, tainted, g->size, p);
+}
+
+
+
+/*************************************************
+* Add chars to string *
+*************************************************/
+/* This function is used when building up strings of unknown length. Room is
+always left for a terminating zero to be added to the string that is being
+built. This function does not require the string that is being added to be NUL
+terminated, because the number of characters to add is given explicitly. It is
+sometimes called to extract parts of other strings.
+
+Arguments:
+ g growable-string that is being built, or NULL if not assigned yet
+ s points to characters to add
+ count count of characters to add; must not exceed the length of s, if s
+ is a C string.
+
+Returns: growable string, changed if copied for expansion.
+ Note that a NUL is not added, though space is left for one. This is
+ because string_cat() is often called multiple times to build up a
+ string - there's no point adding the NUL till the end.
+ NULL is a possible return.
+
+*/
+/* coverity[+alloc] */
+
+gstring *
+string_catn(gstring * g, const uschar *s, int count)
+{
+int p;
+BOOL srctaint = is_tainted(s);
+
+if (count < 0)
+ log_write(0, LOG_MAIN|LOG_PANIC_DIE,
+ "internal error in string_catn (count %d)", count);
+if (count == 0) return g;
+
+if (!g)