Source-Changes-HG archive

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

[src/trunk]: src/sys/net tun(4): Fix some error branches in tunwrite.



details:   https://anonhg.NetBSD.org/src/rev/aaef93a2e20e
branches:  trunk
changeset: 363502:aaef93a2e20e
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Mar 13 21:42:39 2022 +0000

description:
tun(4): Fix some error branches in tunwrite.

diffstat:

 sys/net/if_tun.c |  11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diffs (46 lines):

diff -r 6d65230a5f77 -r aaef93a2e20e sys/net/if_tun.c
--- a/sys/net/if_tun.c  Sun Mar 13 21:32:43 2022 +0000
+++ b/sys/net/if_tun.c  Sun Mar 13 21:42:39 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_tun.c,v 1.170 2022/03/13 21:32:43 riastradh Exp $   */
+/*     $NetBSD: if_tun.c,v 1.171 2022/03/13 21:42:39 riastradh Exp $   */
 
 /*
  * Copyright (c) 1988, Julian Onions <jpo%cs.nott.ac.uk@localhost>
@@ -19,7 +19,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.170 2022/03/13 21:32:43 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.171 2022/03/13 21:42:39 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -887,6 +887,8 @@
                        goto out0;
                }
                error = uiomove((void *)&dst, sizeof(dst), uio);
+               if (error)
+                       goto out0;
                if (dst.sa_len > sizeof(dst)) {
                        /* Duh.. */
                        int n = dst.sa_len - sizeof(dst);
@@ -904,6 +906,8 @@
                        goto out0;
                }
                error = uiomove((void *)&family, sizeof(family), uio);
+               if (error)
+                       goto out0;
                dst.sa_family = ntohl(family);
        } else {
 #ifdef INET
@@ -939,7 +943,8 @@
        /* get a header mbuf */
        MGETHDR(m, M_DONTWAIT, MT_DATA);
        if (m == NULL) {
-               return ENOBUFS;
+               error = ENOBUFS;
+               goto out0;
        }
        mlen = MHLEN;
 



Home | Main Index | Thread Index | Old Index