From: Jeremy Harris Date: Sun, 27 Feb 2022 16:33:24 +0000 (+0000) Subject: NDBM: check for bogus name given to create call X-Git-Tag: exim-4.96-RC0~49 X-Git-Url: https://git.exim.org/exim.git/commitdiff_plain/7d238090f5fbd23d7077eba95c1ba8f2ee016a00 NDBM: check for bogus name given to create call --- diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index ca219cf51..282b14f6f 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -83,6 +83,12 @@ JH/18 Bug 2751: Fix include_directory in redirect routers. Previously a JH/19 Support for Berkeley DB versions 1 and 2 is withdrawn. +JH/20 When built with NDBM for hints DB's check for nonexistence of a name + supplied as the db file-pair basename. Previously, if a directory + path was given, for example via the autoreply "once" option, the DB + file.pag and file.dir files would be created in that directory's + parent. + Exim version 4.95 ----------------- diff --git a/src/src/dbstuff.h b/src/src/dbstuff.h index a5905231e..296a8e18c 100644 --- a/src/src/dbstuff.h +++ b/src/src/dbstuff.h @@ -434,8 +434,19 @@ interface */ /* Access functions */ /* EXIM_DBOPEN - returns a EXIM_DB *, NULL if failed */ -# define EXIM_DBOPEN__(name, dirname, flags, mode, dbpp) \ - *(dbpp) = dbm_open(CS name, flags, mode) +/* Check that the name given is not present. This catches +a directory name; otherwise we would create the name.pag and +name.dir files in the directory's parent. */ + +# define EXIM_DBOPEN__(name, dirname, flags, mode, dbpp) \ + { \ + struct stat st; \ + *(dbpp) = !(flags & O_CREAT) \ + || lstat(CCS (name), &st) != 0 && errno == ENOENT \ + ? dbm_open(CS (name), (flags), (mode)) \ + : (errno = (st.st_mode & S_IFMT) == S_IFDIR ? EISDIR : EEXIST, \ + NULL); \ + } /* EXIM_DBGET - returns TRUE if successful, FALSE otherwise */ # define EXIM_DBGET(db, key, data) \ diff --git a/src/src/transports/autoreply.c b/src/src/transports/autoreply.c index 6110f87bf..f630c6eb3 100644 --- a/src/src/transports/autoreply.c +++ b/src/src/transports/autoreply.c @@ -57,27 +57,11 @@ BOOL autoreply_transport_entry(transport_instance *tblock, address_item *addr) { #else /*!MACRO_PREDEF*/ -/* Default private options block for the autoreply transport. */ +/* Default private options block for the autoreply transport. +All non-mentioned lements zero/null/false. */ autoreply_transport_options_block autoreply_transport_option_defaults = { - NULL, /* from */ - NULL, /* reply_to */ - NULL, /* to */ - NULL, /* cc */ - NULL, /* bcc */ - NULL, /* subject */ - NULL, /* headers */ - NULL, /* text */ - NULL, /* file */ - NULL, /* logfile */ - NULL, /* oncelog */ - NULL, /* once_repeat */ - NULL, /* never_mail */ - 0600, /* mode */ - 0, /* once_file_size */ - FALSE, /* file_expand */ - FALSE, /* file_optional */ - FALSE /* return message */ + .mode = 0600, }; @@ -362,16 +346,13 @@ else return FALSE; if (oncerepeat) - { - once_repeat_sec = readconf_readtime(oncerepeat, 0, FALSE); - if (once_repeat_sec < 0) + if ((once_repeat_sec = readconf_readtime(oncerepeat, 0, FALSE)) < 0) { addr->transport_return = FAIL; addr->message = string_sprintf("Invalid time value \"%s\" for " "\"once_repeat\" in %s transport", oncerepeat, tblock->name); return FALSE; } - } } /* If the never_mail option is set, we have to scan all the recipients and