summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrad <brad@openbsd.org>2005-07-06 20:37:27 +0000
committerbrad <brad@openbsd.org>2005-07-06 20:37:27 +0000
commit9b4c90696d21db4c65380414b556b4752387dccc (patch)
treeb8f955c82159990da373f89184bdd3b404202f66
parenturl fits (diff)
downloadwireguard-openbsd-9b4c90696d21db4c65380414b556b4752387dccc.tar.xz
wireguard-openbsd-9b4c90696d21db4c65380414b556b4752387dccc.zip
rev 1.8
Handle a malloc() failure when allocating urgent ports From brian FreeBSD ok deraadt@
-rw-r--r--usr.sbin/ppp/ppp/ncp.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/usr.sbin/ppp/ppp/ncp.c b/usr.sbin/ppp/ppp/ncp.c
index 347049ad556..8c26360d7f8 100644
--- a/usr.sbin/ppp/ppp/ncp.c
+++ b/usr.sbin/ppp/ppp/ncp.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: ncp.c,v 1.2 2002/05/16 01:13:39 brian Exp $
+ * $OpenBSD: ncp.c,v 1.3 2005/07/06 20:37:27 brad Exp $
*/
#include <sys/param.h>
@@ -101,10 +101,15 @@ ncp_Init(struct ncp *ncp, struct bundle *bundle)
ncp->afq = AF_INET;
ncp->route = NULL;
- ncp->cfg.urgent.tcp.nports = ncp->cfg.urgent.tcp.maxports = NDEFTCPPORTS;
ncp->cfg.urgent.tcp.port = (u_short *)malloc(NDEFTCPPORTS * sizeof(u_short));
- memcpy(ncp->cfg.urgent.tcp.port, default_urgent_tcp_ports,
- NDEFTCPPORTS * sizeof(u_short));
+ if (ncp->cfg.urgent.tcp.port == NULL) {
+ log_Printf(LogERROR, "ncp_Init: Out of memory allocating urgent ports\n");
+ ncp->cfg.urgent.tcp.nports = ncp->cfg.urgent.tcp.maxports = 0;
+ } else {
+ ncp->cfg.urgent.tcp.nports = ncp->cfg.urgent.tcp.maxports = NDEFTCPPORTS;
+ memcpy(ncp->cfg.urgent.tcp.port, default_urgent_tcp_ports,
+ NDEFTCPPORTS * sizeof(u_short));
+ }
ncp->cfg.urgent.tos = 1;
ncp->cfg.urgent.udp.nports = ncp->cfg.urgent.udp.maxports = NDEFUDPPORTS;