Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys CID/1203196: Don't confuse coverity with out of bounds a...



details:   https://anonhg.NetBSD.org/src/rev/2078aa5ce90b
branches:  trunk
changeset: 328769:2078aa5ce90b
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Apr 17 16:14:22 2014 +0000

description:
CID/1203196: Don't confuse coverity with out of bounds access

diffstat:

 sys/kern/uipc_domain.c |  12 ++++++------
 sys/sys/socket.h       |   4 +++-
 2 files changed, 9 insertions(+), 7 deletions(-)

diffs (66 lines):

diff -r 89552fbb9632 -r 2078aa5ce90b sys/kern/uipc_domain.c
--- a/sys/kern/uipc_domain.c    Thu Apr 17 16:08:42 2014 +0000
+++ b/sys/kern/uipc_domain.c    Thu Apr 17 16:14:22 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uipc_domain.c,v 1.91 2014/04/02 15:35:45 seanb Exp $   */
+/*     $NetBSD: uipc_domain.c,v 1.92 2014/04/17 16:14:22 christos Exp $        */
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_domain.c,v 1.91 2014/04/02 15:35:45 seanb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_domain.c,v 1.92 2014/04/17 16:14:22 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/socket.h>
@@ -418,7 +418,7 @@
        pcb->ki_rcvq = so->so_rcv.sb_cc;
        pcb->ki_sndq = so->so_snd.sb_cc;
 
-       un = (struct sockaddr_un *)&pcb->ki_src;
+       un = (struct sockaddr_un *)pcb->ki_spad;
        /*
         * local domain sockets may bind without having a local
         * endpoint.  bleah!
@@ -430,17 +430,17 @@
                 * makeun().
                 */
                memcpy(un, unp->unp_addr,
-                   min(sizeof(pcb->ki_s), unp->unp_addr->sun_len + 1));
+                   min(sizeof(pcb->ki_spad), unp->unp_addr->sun_len + 1));
        }
        else {
                un->sun_len = offsetof(struct sockaddr_un, sun_path);
                un->sun_family = pcb->ki_family;
        }
        if (unp->unp_conn != NULL) {
-               un = (struct sockaddr_un *)&pcb->ki_dst;
+               un = (struct sockaddr_un *)pcb->ki_dpad;
                if (unp->unp_conn->unp_addr != NULL) {
                        memcpy(un, unp->unp_conn->unp_addr,
-                           min(sizeof(pcb->ki_s), unp->unp_conn->unp_addr->sun_len + 1));
+                           min(sizeof(pcb->ki_dpad), unp->unp_conn->unp_addr->sun_len + 1));
                }
                else {
                        un->sun_len = offsetof(struct sockaddr_un, sun_path);
diff -r 89552fbb9632 -r 2078aa5ce90b sys/sys/socket.h
--- a/sys/sys/socket.h  Thu Apr 17 16:08:42 2014 +0000
+++ b/sys/sys/socket.h  Thu Apr 17 16:14:22 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: socket.h,v 1.108 2013/01/31 14:30:47 joerg Exp $       */
+/*     $NetBSD: socket.h,v 1.109 2014/04/17 16:14:22 christos Exp $    */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -428,6 +428,8 @@
 
 #define ki_src ki_s._kis_src
 #define ki_dst ki_d._kid_dst
+#define ki_spad ki_s._kis_pad
+#define ki_dpad ki_d._kid_pad
 
 #define PCB_SLOP               20
 #define PCB_ALL                        0



Home | Main Index | Thread Index | Old Index