diff options
author | jkh <jkh@FreeBSD.org> | 1996-12-09 08:22:19 +0000 |
---|---|---|
committer | jkh <jkh@FreeBSD.org> | 1996-12-09 08:22:19 +0000 |
commit | 78cf4aee6b346217e9f9fbee836c6c67a8cbda61 (patch) | |
tree | 703f1957c7cb4d3138f4dca933a94c51a76a6ae6 /usr.sbin/sysinstall/tcpip.c | |
parent | 316f6be0fa40f1f38890e5f7030d808f4de39e18 (diff) | |
download | FreeBSD-src-78cf4aee6b346217e9f9fbee836c6c67a8cbda61.zip FreeBSD-src-78cf4aee6b346217e9f9fbee836c6c67a8cbda61.tar.gz |
As Paul has just pointed out, much of my strncpy() usage was either
bogus or overly complex and really needed to be done more consistently
and sanely throughout - no question about it. Done.
Suggested-By: Paul Traina <pst@Shockwave.COM>
Diffstat (limited to 'usr.sbin/sysinstall/tcpip.c')
-rw-r--r-- | usr.sbin/sysinstall/tcpip.c | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/usr.sbin/sysinstall/tcpip.c b/usr.sbin/sysinstall/tcpip.c index a774c6d..a8c10fc 100644 --- a/usr.sbin/sysinstall/tcpip.c +++ b/usr.sbin/sysinstall/tcpip.c @@ -1,5 +1,5 @@ /* - * $Id: tcpip.c,v 1.49 1996/11/07 08:03:29 jkh Exp $ + * $Id: tcpip.c,v 1.50 1996/12/09 06:37:46 jkh Exp $ * * Copyright (c) 1995 * Gary J Palmer. All rights reserved. @@ -210,51 +210,51 @@ tcpOpenDialog(Device *devp) if (devp->private) { DevInfo *di = (DevInfo *)devp->private; - strcpy(ipaddr, di->ipaddr); - strcpy(netmask, di->netmask); - strcpy(extras, di->extras); + SAFE_STRCPY(ipaddr, di->ipaddr); + SAFE_STRCPY(netmask, di->netmask); + SAFE_STRCPY(extras, di->extras); } else { /* See if there are any defaults */ char *cp; if (!ipaddr[0]) { if ((cp = variable_get(VAR_IPADDR)) != NULL) - strcpy(ipaddr, cp); + SAFE_STRCPY(ipaddr, cp); else if ((cp = variable_get(string_concat3(devp->name, "_", VAR_IPADDR))) != NULL) - strcpy(ipaddr, cp); + SAFE_STRCPY(ipaddr, cp); } if (!netmask[0]) { if ((cp = variable_get(VAR_NETMASK)) != NULL) - strcpy(netmask, cp); + SAFE_STRCPY(netmask, cp); else if ((cp = variable_get(string_concat3(devp->name, "_", VAR_NETMASK))) != NULL) - strcpy(netmask, cp); + SAFE_STRCPY(netmask, cp); } if (!extras[0]) { if ((cp = variable_get(VAR_EXTRAS)) != NULL) - strcpy(extras, cp); + SAFE_STRCPY(extras, cp); else if ((cp = variable_get(string_concat3(devp->name, "_", VAR_EXTRAS))) != NULL) - strcpy(extras, cp); + SAFE_STRCPY(extras, cp); } } /* Look up values already recorded with the system, or blank the string variables ready to accept some new data */ tmp = variable_get(VAR_HOSTNAME); if (tmp) - strcpy(hostname, tmp); + SAFE_STRCPY(hostname, tmp); else bzero(hostname, sizeof(hostname)); tmp = variable_get(VAR_DOMAINNAME); if (tmp) - strcpy(domainname, tmp); + SAFE_STRCPY(domainname, tmp); else bzero(domainname, sizeof(domainname)); tmp = variable_get(VAR_GATEWAY); if (tmp) - strcpy(gateway, tmp); + SAFE_STRCPY(gateway, tmp); else bzero(gateway, sizeof(gateway)); tmp = variable_get(VAR_NAMESERVER); if (tmp) - strcpy(nameserver, tmp); + SAFE_STRCPY(nameserver, tmp); else bzero(nameserver, sizeof(nameserver)); @@ -314,8 +314,7 @@ tcpOpenDialog(Device *devp) if (n == LAYOUT_HOSTNAME) { /* We are in the Hostname field - calculate the domainname */ if ((tmp = index(hostname, '.')) != NULL) { - strncpy(domainname, tmp + 1, strlen(tmp + 1)); - domainname[strlen(tmp+1)] = '\0'; + sstrncpy(domainname, tmp + 1, strlen(tmp + 1)); RefreshStringObj(layout[LAYOUT_DOMAINNAME].obj); } } @@ -385,8 +384,7 @@ tcpOpenDialog(Device *devp) /* BODGE ALERT! */ if (((tmp = index(hostname, '.')) != NULL) && (strlen(domainname)==0)) { - strncpy(domainname, tmp + 1, strlen(tmp + 1)); - domainname[strlen(tmp+1)] = '\0'; + sstrncpy(domainname, tmp + 1, strlen(tmp + 1)); RefreshStringObj(layout[1].obj); } } @@ -416,9 +414,9 @@ tcpOpenDialog(Device *devp) if (!devp->private) devp->private = (DevInfo *)safe_malloc(sizeof(DevInfo)); di = devp->private; - strcpy(di->ipaddr, ipaddr); - strcpy(di->netmask, netmask); - strcpy(di->extras, extras); + SAFE_STRCPY(di->ipaddr, ipaddr); + SAFE_STRCPY(di->netmask, netmask); + SAFE_STRCPY(di->extras, extras); sprintf(temp, "inet %s %s netmask %s", ipaddr, extras, netmask); sprintf(ifn, "%s%s", VAR_IFCONFIG, devp->name); |