[evolution-data-server] addressbook: Fix ordering of parameters to fwrite()
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] addressbook: Fix ordering of parameters to fwrite()
- Date: Mon, 3 Nov 2014 22:21:10 +0000 (UTC)
commit 08b65f533ca8cf8dd609750f21e705524b11e2e1
Author: Philip Withnall <philip withnall collabora co uk>
Date: Mon Nov 3 16:00:38 2014 +0000
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
addressbook/libedata-book/e-book-backend-summary.c | 11 ++++++-----
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 762cc29..8e7db25 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]