Module Name: src Committed By: riastradh Date: Sun Mar 13 21:42:39 UTC 2022
Modified Files: src/sys/net: if_tun.c Log Message: tun(4): Fix some error branches in tunwrite. To generate a diff of this commit: cvs rdiff -u -r1.170 -r1.171 src/sys/net/if_tun.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/net/if_tun.c diff -u src/sys/net/if_tun.c:1.170 src/sys/net/if_tun.c:1.171 --- src/sys/net/if_tun.c:1.170 Sun Mar 13 21:32:43 2022 +++ src/sys/net/if_tun.c Sun Mar 13 21:42:39 2022 @@ -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 <j...@cs.nott.ac.uk> @@ -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 @@ tunwrite(dev_t dev, struct uio *uio, int 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 @@ tunwrite(dev_t dev, struct uio *uio, int 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 @@ tunwrite(dev_t dev, struct uio *uio, int /* get a header mbuf */ MGETHDR(m, M_DONTWAIT, MT_DATA); if (m == NULL) { - return ENOBUFS; + error = ENOBUFS; + goto out0; } mlen = MHLEN;