OpenSSL: use nondeprecated HMAC functions under 3.0.0.
[exim.git] / src / src / search.c
index 061a9e8644df9a05dbad8f8f844a18d793781ccf..90af54c36d2fd9ca1d891dd5e1fa4ae89587e9e7 100644 (file)
@@ -3,7 +3,7 @@
 *************************************************/
 
 /* Copyright (c) University of Cambridge 1995 - 2015 */
-/* Copyright (c) The Exim Maintainers 2020 */
+/* Copyright (c) The Exim Maintainers 2020 - 2021 */
 /* See the file NOTICE for conditions of use and distribution. */
 
 /* A set of functions to search databases in various formats. An open
@@ -223,18 +223,31 @@ Arguments:
  search                the search-type string
  query         argument for the search; filename or query
  fnamep                pointer to return filename
+ opts          options
 
 Return:        keyquery        the search-type (for single-key) or query (for query-type)
  */
 uschar *
-search_args(int search_type, uschar * search, uschar * query, uschar ** fnamep)
+search_args(int search_type, uschar * search, uschar * query, uschar ** fnamep,
+  const uschar * opts)
 {
 Uskip_whitespace(&query);
 if (mac_islookup(search_type, lookup_absfilequery))
   {                                    /* query-style but with file (sqlite) */
-  uschar * s = query;
+  int sep = ',';
+
+  /* Check options first for new-style file spec */
+  if (opts) for (uschar * s; s = string_nextinlist(&opts, &sep, NULL, 0); )
+    if (Ustrncmp(s, "file=", 5) == 0)
+      {
+      *fnamep = s+5;
+      return query;
+      }
+
+  /* If no filename from options, use old-tyle space-sep prefix on query */
   if (*query == '/')
     {
+    uschar * s = query;
     while (*query && !isspace(*query)) query++;
     *fnamep = string_copyn(s, query - s);
     Uskip_whitespace(&query);
@@ -379,12 +392,8 @@ lookup_info *lk = lookup_list[search_type];
 uschar keybuffer[256];
 int old_pool = store_pool;
 
-if (filename && is_tainted(filename))
-  {
-  log_write(0, LOG_MAIN|LOG_PANIC,
-    "Tainted filename for search: '%s'", filename);
+if (filename && is_tainted2(filename, LOG_MAIN|LOG_PANIC, "Tainted filename for search: '%s'", filename))
   return NULL;
-  }
 
 /* Change to the search store pool and remember our reset point */
 
@@ -701,7 +710,7 @@ if (opts)
 /* Arrange to put this database at the top of the LRU chain if it is a type
 that opens real files. */
 
-if (  open_top != (tree_node *)handle 
+if (  open_top != (tree_node *)handle
    && lookup_list[t->name[0]-'0']->type == lookup_absfile)
   {
   search_cache *c = (search_cache *)(t->data.ptr);