summaryrefslogtreecommitdiff
path: root/addressbook
diff options
context:
space:
mode:
authorPhilip Withnall <philip.withnall@collabora.co.uk>2014-11-03 16:00:38 +0000
committerPhilip Withnall <philip@tecnocode.co.uk>2014-11-03 22:20:32 +0000
commit08b65f533ca8cf8dd609750f21e705524b11e2e1 (patch)
tree0f746deec27f41582a07c05921b93aee5f58ae3c /addressbook
parentf81b1ec80ae382d83861e8afa4bd13f604131acf (diff)
downloadevolution-data-server-08b65f533ca8cf8dd609750f21e705524b11e2e1.tar.gz
addressbook: Fix ordering of parameters to fwrite()
fwrite() takes two integer parameters: size and nmemb. size should always be constant, as it is a structure size. nmemb may vary. Using these two parameters the correct way around means the return value is consistently related to nmemb, and static analysers such as Coverity can perform taint tests on the values passed to size. https://bugzilla.gnome.org/show_bug.cgi?id=730381
Diffstat (limited to 'addressbook')
-rw-r--r--addressbook/libedata-book/e-book-backend-summary.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/addressbook/libedata-book/e-book-backend-summary.c b/addressbook/libedata-book/e-book-backend-summary.c
index 762cc2974..8e7db25d0 100644
--- a/addressbook/libedata-book/e-book-backend-summary.c
+++ b/addressbook/libedata-book/e-book-backend-summary.c
@@ -541,8 +541,8 @@ static gboolean
e_book_backend_summary_save_magic (FILE *fp)
{
gint rv;
- rv = fwrite (PAS_SUMMARY_MAGIC, PAS_SUMMARY_MAGIC_LEN, 1, fp);
- if (rv != 1)
+ rv = fwrite (PAS_SUMMARY_MAGIC, sizeof (gchar), PAS_SUMMARY_MAGIC_LEN, fp);
+ if (rv != PAS_SUMMARY_MAGIC_LEN)
return FALSE;
return TRUE;
@@ -570,13 +570,14 @@ static gboolean
save_string (const gchar *str,
FILE *fp)
{
- gint rv;
+ size_t rv, len;
if (!str || !*str)
return TRUE;
- rv = fwrite (str, strlen (str), 1, fp);
- return (rv == 1);
+ len = strlen (str);
+ rv = fwrite (str, sizeof (gchar), len, fp);
+ return (rv == len);
}
static gboolean