X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fsrc%2Fexpand.c;h=de53fe41160f9f3c3cb9e0916c8e647d0c1811dd;hb=a5dc727afcc92deab722a84ae5cf3d00ae74c5f6;hp=660fe98cfc7ffe4f971a642ebd989ed47a34abff;hpb=759502e5af0acfb310b8571f056d2dbf59adb1d3;p=user%2Fhenk%2Fcode%2Fexim.git diff --git a/src/src/expand.c b/src/src/expand.c index 660fe98cf..de53fe411 100644 --- a/src/src/expand.c +++ b/src/src/expand.c @@ -1791,11 +1791,12 @@ debug_printf("local addr '%s%s'\n", #ifdef EXIM_HAVE_ABSTRACT_UNIX_SOCKETS sa_un.sun_path[0] = 0; /* Abstract local socket addr - Linux-specific? */ len = offsetof(struct sockaddr_un, sun_path) + 1 - + snprintf(sa_un.sun_path+1, sizeof(sa_un.sun_path)-1, "%s", NOTIFIER_SOCKET_NAME); + + snprintf(sa_un.sun_path+1, sizeof(sa_un.sun_path)-1, "%s", + expand_string(notifier_socket)); #else len = offsetof(struct sockaddr_un, sun_path) - + snprintf(sa_un.sun_path, sizeof(sa_un.sun_path), "%s/%s", - spool_directory, NOTIFIER_SOCKET_NAME); + + snprintf(sa_un.sun_path, sizeof(sa_un.sun_path), "%s", + expand_string(notifier_socket)); #endif if (connect(fd, (const struct sockaddr *)&sa_un, len) < 0) @@ -4778,7 +4779,7 @@ while (*s != 0) int expand_setup = 0; int nameptr = 0; uschar *key, *filename; - const uschar *affix; + const uschar * affix, * opts; uschar *save_lookup_value = lookup_value; int save_expand_nmax = save_expand_strings(save_expand_nstring, save_expand_nlength); @@ -4829,9 +4830,8 @@ while (*s != 0) /* Now check for the individual search type and any partial or default options. Only those types that are actually in the binary are valid. */ - stype = search_findtype_partial(name, &partial, &affix, &affixlen, - &starflags); - if (stype < 0) + if ((stype = search_findtype_partial(name, &partial, &affix, &affixlen, + &starflags, &opts)) < 0) { expand_string_message = search_error_message; goto EXPAND_FAILED; @@ -4891,16 +4891,13 @@ while (*s != 0) if (mac_islookup(stype, lookup_querystyle)) filename = NULL; else - { - if (*filename != '/') - { - expand_string_message = string_sprintf( - "absolute file name expected for \"%s\" lookup", name); - goto EXPAND_FAILED; - } - while (*key != 0 && !isspace(*key)) key++; - if (*key != 0) *key++ = 0; - } + if (*filename == '/') + { + while (*key && !isspace(*key)) key++; + if (*key) *key++ = '\0'; + } + else + filename = NULL; } /* If skipping, don't do the next bit - just lookup_value == NULL, as if @@ -4927,7 +4924,7 @@ while (*s != 0) goto EXPAND_FAILED; } lookup_value = search_find(handle, filename, key, partial, affix, - affixlen, starflags, &expand_setup); + affixlen, starflags, &expand_setup, opts); if (f.search_find_defer) { expand_string_message = @@ -5334,8 +5331,9 @@ while (*s != 0) uschar * item; int sep = 0; - item = string_nextinlist(&list, &sep, NULL, 0); - if ((timeout = readconf_readtime(item, 0, FALSE)) < 0) + if ( !(item = string_nextinlist(&list, &sep, NULL, 0)) + || !*item + || (timeout = readconf_readtime(item, 0, FALSE)) < 0) { expand_string_message = string_sprintf("bad time value %s", item); goto EXPAND_FAILED; @@ -5623,7 +5621,8 @@ while (*s != 0) /* Create the child process, making it a group leader. */ - if ((pid = child_open(USS argv, NULL, 0077, &fd_in, &fd_out, TRUE)) < 0) + if ((pid = child_open(USS argv, NULL, 0077, &fd_in, &fd_out, TRUE, + US"expand-run")) < 0) { expand_string_message = string_sprintf("couldn't create child process: %s", strerror(errno)); @@ -7631,7 +7630,7 @@ while (*s != 0) case EOP_QUOTE_LOCAL_PART: if (!arg) { - BOOL needs_quote = (*sub == 0); /* TRUE for empty string */ + BOOL needs_quote = (!*sub); /* TRUE for empty string */ uschar *t = sub - 1; if (c == EOP_QUOTE) @@ -7751,10 +7750,10 @@ while (*s != 0) case EOP_FROM_UTF8: { - while (*sub != 0) + uschar * buff = store_get(4, is_tainted(sub)); + while (*sub) { int c; - uschar buff[4]; GETUTF8INC(c, sub); if (c > 255) c = '_'; buff[0] = c; @@ -7763,7 +7762,7 @@ while (*s != 0) continue; } - /* replace illegal UTF-8 sequences by replacement character */ + /* replace illegal UTF-8 sequences by replacement character */ #define UTF8_REPLACEMENT_CHAR US"?" @@ -7775,7 +7774,17 @@ while (*s != 0) int complete; uschar seq_buff[4]; /* accumulate utf-8 here */ - while (*sub != 0) + /* Manually track tainting, as we deal in individual chars below */ + + if (is_tainted(sub)) + if (yield->s && yield->ptr) + gstring_rebuffer(yield); + else + yield->s = store_get(yield->size = Ustrlen(sub), TRUE); + + /* Check the UTF-8, byte-by-byte */ + + while (*sub) { complete = 0; uschar c = *sub++; @@ -7801,7 +7810,7 @@ while (*s != 0) } else /* no bytes left: new sequence */ { - if((c & 0x80) == 0) /* 1-byte sequence, US-ASCII, keep it */ + if(!(c & 0x80)) /* 1-byte sequence, US-ASCII, keep it */ { yield = string_catn(yield, &c, 1); continue; @@ -7846,9 +7855,8 @@ while (*s != 0) * Eg, ${length_1:フィル} is one byte, not one character, so we expect * ${utf8clean:${length_1:フィル}} to yield '?' */ if (bytes_left != 0) - { yield = string_catn(yield, UTF8_REPLACEMENT_CHAR, 1); - } + continue; }