From 4e18743562ada3d4dcee8121b8ecf750369f0e5b Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Tue, 17 Sep 2024 13:31:57 +0100 Subject: [PATCH] tidying --- src/src/exim.c | 6 ++++++ src/src/functions.h | 2 +- src/src/miscmods/dkim.c | 2 +- src/src/string.c | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/src/exim.c b/src/src/exim.c index 0eb221d43..a95723f0d 100644 --- a/src/src/exim.c +++ b/src/src/exim.c @@ -257,6 +257,12 @@ int nptrs = backtrace(buf, STACKDUMP_MAX); log_write(0, LOG_MAIN|LOG_PANIC, "backtrace"); log_write(0, LOG_MAIN|LOG_PANIC, "---"); + +/* This function is officially not callable from a signal handler, as it +calls malloc() for the returned data. However, it seems to work - and we +know we're going on to crash anyway - so just hold our noses and do it. +A alternative might be backtrace_symbols_fd(). */ + if ((ss = backtrace_symbols(buf, nptrs))) { for (int i = 0; i < nptrs; i++) diff --git a/src/src/functions.h b/src/src/functions.h index 57c4bb45c..b581af78b 100644 --- a/src/src/functions.h +++ b/src/src/functions.h @@ -991,7 +991,7 @@ return g ? (unsigned)g->ptr : 0; static inline uschar gstring_last_char(gstring * g) { -return g ? g->s[g->ptr-1] : '\0'; +return g && g->ptr > 0 ? g->s[g->ptr-1] : '\0'; } static inline void diff --git a/src/src/miscmods/dkim.c b/src/src/miscmods/dkim.c index bd1625187..5b18dbcb0 100644 --- a/src/src/miscmods/dkim.c +++ b/src/src/miscmods/dkim.c @@ -995,7 +995,7 @@ if (dkim_domain) if (!(dkim_private_key_expanded = expand_string(dkim->dkim_private_key))) { errwhen = US"dkim_private_key"; goto expand_bad; } - if ( Ustrlen(dkim_private_key_expanded) == 0 + if ( dkim_private_key_expanded[0] == '\0' || Ustrcmp(dkim_private_key_expanded, "0") == 0 || Ustrcmp(dkim_private_key_expanded, "false") == 0 ) diff --git a/src/src/string.c b/src/src/string.c index 1169f0e2c..d4fb23cb6 100644 --- a/src/src/string.c +++ b/src/src/string.c @@ -957,7 +957,7 @@ if (buffer) die_tainted(US"string_nextinlist", func, line); for (; *s; s++) { - if (*s == sep && (*(++s) != sep || sep_is_special)) break; + if (*s == sep && (*++s != sep || sep_is_special)) break; if (p < buflen - 1) buffer[p++] = *s; } while (p > 0 && isspace(buffer[p-1])) p--; -- 2.30.2