[evolution-data-server/evolution-data-server-3-12] addressbook: Add bounds checking to a summary file function



commit 927d3ca66ce85347bc4ef504034e70488ec9ddd2
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Mon May 19 15:01:08 2014 +0100

    addressbook: Add bounds checking to a summary file function
    
    There was not a bug here, as the len parameter always came from a
    guint16, so no overflow was possible. However, a bounds check is always
    a good idea and makes the code more robust in the face of future
    changes.
    
    Coverity issue: #1061517
    
    https://bugzilla.gnome.org/show_bug.cgi?id=730381

 addressbook/libedata-book/e-book-backend-summary.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/addressbook/libedata-book/e-book-backend-summary.c 
b/addressbook/libedata-book/e-book-backend-summary.c
index 227c47e..6a66a2a 100644
--- a/addressbook/libedata-book/e-book-backend-summary.c
+++ b/addressbook/libedata-book/e-book-backend-summary.c
@@ -272,11 +272,15 @@ e_book_backend_summary_load_header (EBookBackendSummary *summary,
 
 static gchar *
 read_string (FILE *fp,
-             gint len)
+             gsize len)
 {
        gchar *buf;
        gint rv;
 
+       /* Avoid overflow for the nul byte. */
+       if (len == G_MAXSIZE)
+               return NULL;
+
        buf = g_new0 (char, len + 1);
 
        rv = fread (buf, len, 1, fp);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]