From: Jeremy Harris Date: Fri, 12 Jul 2024 11:22:11 +0000 (+0100) Subject: Build: drop printf-like annotations X-Git-Url: https://git.exim.org/exim.git/commitdiff_plain/380482840626329785618df79dadf5ab04688c49 Build: drop printf-like annotations --- diff --git a/src/src/dbfn.c b/src/src/dbfn.c index d1d8c08d4..d64f1927b 100644 --- a/src/src/dbfn.c +++ b/src/src/dbfn.c @@ -145,7 +145,7 @@ open_db * 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]; @@ -164,8 +164,11 @@ make the directory as well, just in case. We won't be doing this many times 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()) @@ -189,7 +192,7 @@ it easy to pin this down, there are now debug statements on either side of the 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); @@ -244,7 +247,7 @@ starting a transaction. "lof" and "panic" always true; read/write 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]; @@ -253,8 +256,8 @@ DEBUG(D_hints_lookup) acl_level++; 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); diff --git a/src/src/functions.h b/src/src/functions.h index afb6fd46f..21214d15b 100644 --- a/src/src/functions.h +++ b/src/src/functions.h @@ -1256,12 +1256,13 @@ timediff(diff, then); 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; } diff --git a/src/src/mytypes.h b/src/src/mytypes.h index c39083be8..cac4ee3c9 100644 --- a/src/src/mytypes.h +++ b/src/src/mytypes.h @@ -30,15 +30,13 @@ local_scan.h includes it and exim.h includes them both (to get this earlier). */ #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__)) diff --git a/src/src/tod.c b/src/src/tod.c index 364703d53..560f69bee 100644 --- a/src/src/tod.c +++ b/src/src/tod.c @@ -169,6 +169,7 @@ switch(type) diff_min += (local.tm_yday > gmt->tm_yday) ? 1440 : -1440; diff_hour = diff_min/60; diff_min = abs(diff_min - diff_hour*60); + diff_min &= 63; /* compiler quietening */ } else /* subminute offset, eg. TAI */ {