dbfn_open(const uschar * name, int flags, open_db * dbblock,
BOOL lof, BOOL panic)
{
-int rc, save_errno;
+int rc, save_errno, dlen, flen;
flock_t lock_data;
uschar dirname[PATHLEN], filename[PATHLEN];
unnecessarily, because usually the lock file will be there. If the directory
exists, there is no error. */
-snprintf(CS dirname, sizeof(dirname), "%s/db", spool_directory);
-snprintf(CS filename, sizeof(filename), "%s/%s.lockfile", dirname, name);
+dlen = snprintf(CS dirname, sizeof(dirname), "%s/db", spool_directory);
+flen = Ustrlen(name);
+snprintf(CS filename, sizeof(filename), "%.*s/%.*s.lockfile",
+ (int)sizeof(filename) - dlen - flen - 11, dirname,
+ flen, name);
dbblock->lockfd = -1;
if (!exim_lockfile_needed())
open call. */
flags &= O_RDONLY | O_RDWR;
-snprintf(CS filename, sizeof(filename), "%s/%s", dirname, name);
+snprintf(CS filename, sizeof(filename), "%.*s/%s", dlen, dirname, name);
priv_drop_temp(exim_uid, exim_gid);
dbblock->dbptr = exim_dbopen(filename, dirname, flags, EXIMDB_MODE);
open_db *
dbfn_open_multi(const uschar * name, int flags, open_db * dbblock)
{
-int rc, save_errno;
+int rc, save_errno, dlen;
flock_t lock_data;
uschar dirname[PATHLEN], filename[PATHLEN];
dbblock->lockfd = -1;
db_dir_make(TRUE);
-snprintf(CS dirname, sizeof(dirname), "%s/db", spool_directory);
-snprintf(CS filename, sizeof(filename), "%s/%s", dirname, name);
+dlen = snprintf(CS dirname, sizeof(dirname), "%s/db", spool_directory);
+snprintf(CS filename, sizeof(filename), "%.*s/%s", dlen, dirname, name);
priv_drop_temp(exim_uid, exim_gid);
dbblock->dbptr = exim_dbopen_multi(filename, dirname, flags, EXIMDB_MODE);
static inline uschar *
string_timediff(const struct timeval * diff)
{
-static uschar buf[sizeof("0.000s")];
+static uschar buf[16];
if (diff->tv_sec >= 5 || !LOGGING(millisec))
return readconf_printtime((int)diff->tv_sec);
-snprintf(CS buf, sizeof(buf), "%u.%03us", (uint)diff->tv_sec, (uint)diff->tv_usec/1000);
+snprintf(CS buf, sizeof(buf), "%u.%03us",
+ (uint)diff->tv_sec, (uint)diff->tv_usec/1000);
return buf;
}
#endif
-/* If gcc is being used to compile Exim, we can use its facility for checking
-the arguments of printf-like functions. This is done by a macro.
-OpenBSD has unfortunately taken to objecting to use of %n in printf
-so we have to give up on all of the available parameter checking. */
+/* We gave up on trying to get compilers to check on printf-like functions
+because they are both whiney about value sizes where they cannot do decent
+static analysis, and incapable of handling extensions to printf formats.
+The annotation on functions is still in place but does nothing. */
#if defined(__GNUC__) || defined(__clang__)
-# ifndef __OpenBSD__
-# define PRINTF_FUNCTION(A,B) __attribute__((format(printf,A,B)))
-# endif
+/* # define PRINTF_FUNCTION(A,B) __attribute__((format(printf,A,B))) */
# define ARG_UNUSED __attribute__((__unused__))
# define FUNC_MAYBE_UNUSED __attribute__((__unused__))
# define WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))