commit 4eed7df3a7d38a2cced8397449a7367e98138ea9
parent 817deab2f1f059caa306fcbc56af728f4a41716c
Author: wwp <wwp@free.fr>
Date: Tue, 22 May 2018 19:30:08 +0200
Fix more unchecked return values reported by Coverity:
1434282, 1434283, 1434284
Diffstat:
3 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/src/common/utils.c b/src/common/utils.c
@@ -3563,8 +3563,9 @@ static void _get_rfc822_date(gchar *buf, gint len, gboolean hidetz)
else
lt = localtime_r(&t, &buf1);
- sscanf(asctime_r(lt, buf2), "%3s %3s %d %d:%d:%d %d\n",
- day, mon, &dd, &hh, &mm, &ss, &yyyy);
+ if (sscanf(asctime_r(lt, buf2), "%3s %3s %d %d:%d:%d %d\n",
+ day, mon, &dd, &hh, &mm, &ss, &yyyy) != 7)
+ g_warning("failed reading date/time");
g_snprintf(buf, len, "%s, %d %s %d %02d:%02d:%02d %s",
day, dd, mon, yyyy, hh, mm, ss, (hidetz? "-0000": tzoffset(&t)));
diff --git a/src/plugins/managesieve/sieve_prefs.c b/src/plugins/managesieve/sieve_prefs.c
@@ -507,9 +507,9 @@ struct SieveAccountConfig *sieve_prefs_account_get_config(
enc_userid[0] = '\0';
enc_passwd[0] = '\0';
#if defined(G_OS_WIN32) || defined(__OpenBSD__) || defined(__FreeBSD__)
- sscanf(confstr, "%c%c %255s %c%hu %hhu %hhu %hhu %255s %255s",
+ if (sscanf(confstr, "%c%c %255s %c%hu %hhu %hhu %hhu %255s %255s",
#else
- sscanf(confstr, "%c%c %ms %c%hu %hhu %hhu %hhu %255s %255s",
+ if (sscanf(confstr, "%c%c %ms %c%hu %hhu %hhu %hhu %255s %255s",
#endif
&enable, &use_host,
#if defined(G_OS_WIN32) || defined(__OpenBSD__) || defined(__FreeBSD__)
@@ -522,7 +522,8 @@ struct SieveAccountConfig *sieve_prefs_account_get_config(
&auth,
&auth_type,
enc_userid,
- enc_passwd);
+ enc_passwd) != 10)
+ g_warning("failed reading Sieve config elements");
/* Scan enums separately, for endian purposes */
config->tls_type = tls_type;
diff --git a/src/plugins/vcalendar/vcal_manager.c b/src/plugins/vcalendar/vcal_manager.c
@@ -529,8 +529,9 @@ static void get_rfc822_date_from_time_t(gchar *buf, gint len, time_t t)
struct tm buft2;
lt = localtime_r(&t, &buft2);
- sscanf(asctime_r(lt, buft1), "%3s %3s %d %d:%d:%d %d\n",
- day, mon, &dd, &hh, &mm, &ss, &yyyy);
+ if (sscanf(asctime_r(lt, buft1), "%3s %3s %d %d:%d:%d %d\n",
+ day, mon, &dd, &hh, &mm, &ss, &yyyy) != 7)
+ g_warning("failed reading date/time");
g_snprintf(buf, len, "%s, %d %s %d %02d:%02d:%02d %s",
day, dd, mon, yyyy, hh, mm, ss, tzoffset(&t));
#else