From eedac4a5e937d49ee0d4c7d2b1af8f980408b3d2 Mon Sep 17 00:00:00 2001 From: Marco Bettini Date: Fri, 3 Feb 2023 16:25:19 +0000 Subject: [PATCH] lib-storage: set_line() - Add check against empty lines and keys, drop suffixing lines without '=' The previous check is no longer necessary as keys are now always followed by '=', but in case of empty lines now the function would crash instead of setting "plugin/=yes" (which didn't make sense either) --- src/lib-storage/mail-storage-service.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib-storage/mail-storage-service.c b/src/lib-storage/mail-storage-service.c index cccb420f54..6fb3d05a35 100644 --- a/src/lib-storage/mail-storage-service.c +++ b/src/lib-storage/mail-storage-service.c @@ -142,10 +142,13 @@ static int set_line(struct mail_storage_service_ctx *ctx, size_t len; int ret; - if (strchr(line, '=') == NULL) - line = t_strconcat(line, "=yes", NULL); orig_key = key = t_strcut(line, '='); + /* Ignore empty keys (and lines) rather than prepend 'plugin/=' to them. + Also, prevent emtpy lines from crashing later in settings_parse_line() */ + if (*key == '\0') + return 1; + len = strlen(key); if (len > 0 && key[len-1] == '+') { /* key+=value */ -- 2.47.3