From 501608c08cfad5f0c40fd4b8d91f1fd1ad07469c Mon Sep 17 00:00:00 2001 From: christos Date: Fri, 6 Nov 1998 20:00:07 +0000 Subject: [PATCH] bcpy->memcpy, and don't trash memory if hp->h_length is > sizeof(struct sockaddr_in); --- usr.bin/tn3270/api/api_bsd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/usr.bin/tn3270/api/api_bsd.c b/usr.bin/tn3270/api/api_bsd.c index 0d5ebe5920f6..51d34a9dba57 100644 --- a/usr.bin/tn3270/api/api_bsd.c +++ b/usr.bin/tn3270/api/api_bsd.c @@ -1,4 +1,4 @@ -/* $NetBSD: api_bsd.c,v 1.6 1998/03/10 13:49:55 christos Exp $ */ +/* $NetBSD: api_bsd.c,v 1.7 1998/11/06 20:00:07 christos Exp $ */ /*- * Copyright (c) 1988 The Regents of the University of California. @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)api_bsd.c 4.2 (Berkeley) 4/26/91"; #else -__RCSID("$NetBSD: api_bsd.c,v 1.6 1998/03/10 13:49:55 christos Exp $"); +__RCSID("$NetBSD: api_bsd.c,v 1.7 1998/11/06 20:00:07 christos Exp $"); #endif #endif /* not lint */ @@ -116,7 +116,9 @@ char *string; /* if non-zero, where to connect to */ fprintf(stderr, "%s specifies bad host name.\n", string); return -1; } - bcopy(hp->h_addr, (char *)&server.sin_addr, hp->h_length); + if (sizeof(server.sin_addr.s_addr) < hp->h_length) + hp->h_length = sizeof(server.sin_addr.s_addr); + (void)memcpy(&server.sin_addr.s_addr, hp->h_addr, hp->h_length); server.sin_port = htons(port); if (connect(sock, (struct sockaddr *)&server, sizeof server) < 0) {