[evolution-data-server/evolution-data-server-3-12] e-proxy: Eliminate use of undefined C behaviour



commit ce42fea421227c818e284f59f1e395224da85f21
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Mon May 19 14:55:02 2014 +0100

    e-proxy: Eliminate use of undefined C behaviour
    
    As much as this works fine in practice (because the function returns an
    error, so mask->s_addr should never be used), we should avoid undefined
    behaviour. Apparently it kills kittens.
    
    Coverity issue: #1214484
    
    https://bugzilla.gnome.org/show_bug.cgi?id=730379

 libedataserver/e-proxy.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/libedataserver/e-proxy.c b/libedataserver/e-proxy.c
index 1fa40e3..7f64c0d 100644
--- a/libedataserver/e-proxy.c
+++ b/libedataserver/e-proxy.c
@@ -449,9 +449,11 @@ ep_manipulate_ipv4 (ProxyHostAddr *host_addr,
 
                if (*endptr != '\0' || width < 0 || width > 32) {
                        has_error = TRUE;
+                       mask->s_addr = 0xFFFFFFFF;
+               } else {
+                       mask->s_addr = htonl (~0 << width);
+                       addr->s_addr &= mask->s_addr;
                }
-               mask->s_addr = htonl (~0 << width);
-               addr->s_addr &= mask->s_addr;
        } else {
                mask->s_addr = 0xFFFFFFFF;
        }


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