From 78cf4aee6b346217e9f9fbee836c6c67a8cbda61 Mon Sep 17 00:00:00 2001 From: jkh Date: Mon, 9 Dec 1996 08:22:19 +0000 Subject: 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 --- release/sysinstall/anonFTP.c | 18 +++++++++--------- release/sysinstall/apache.c | 34 +++++++++++++++++----------------- release/sysinstall/attr.c | 6 +++--- release/sysinstall/config.c | 6 +++--- release/sysinstall/devices.c | 4 ++-- release/sysinstall/dmenu.c | 4 ++-- release/sysinstall/ftp_strat.c | 4 ++-- release/sysinstall/index.c | 6 +++--- release/sysinstall/label.c | 6 +++--- release/sysinstall/media.c | 6 +++--- release/sysinstall/misc.c | 10 +++++++++- release/sysinstall/msg.c | 4 ++-- release/sysinstall/network.c | 14 ++++++++------ release/sysinstall/sysinstall.h | 5 ++++- release/sysinstall/tcpip.c | 40 +++++++++++++++++++--------------------- release/sysinstall/uc_main.c | 10 ++++------ release/sysinstall/variable.c | 10 +++++----- 17 files changed, 98 insertions(+), 89 deletions(-) (limited to 'release/sysinstall') diff --git a/release/sysinstall/anonFTP.c b/release/sysinstall/anonFTP.c index 20e26b3..cdd40fc 100644 --- a/release/sysinstall/anonFTP.c +++ b/release/sysinstall/anonFTP.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: anonFTP.c,v 1.16 1996/09/01 08:17:12 jkh Exp $ + * $Id: anonFTP.c,v 1.17 1996/09/06 05:58:27 jkh Exp $ * * Copyright (c) 1995 * Coranth Gryphon. All rights reserved. @@ -179,7 +179,7 @@ createFtpUser(void) tptr = msgGetInput("14", "What group name to use for gid %d ?", gid); if (tptr && *tptr) { - strcpy(tconf.group, tptr); + SAFE_STRCPY(tconf.group, tptr); if ((tgrp = getgrnam(tconf.group))) { gid = tgrp->gr_gid; } @@ -250,10 +250,10 @@ anonftpOpenDialog(void) bzero(&tconf, sizeof(tconf)); - strcpy(tconf.group, FTP_GROUP); - strcpy(tconf.upload, FTP_UPLOAD); - strcpy(tconf.comment, FTP_COMMENT); - strcpy(tconf.homedir, FTP_HOMEDIR); + SAFE_STRCPY(tconf.group, FTP_GROUP); + SAFE_STRCPY(tconf.upload, FTP_UPLOAD); + SAFE_STRCPY(tconf.comment, FTP_COMMENT); + SAFE_STRCPY(tconf.homedir, FTP_HOMEDIR); sprintf(tconf.uid, "%d", FTP_UID); /* Loop over the layout list, create the objects, and add them @@ -389,10 +389,10 @@ configAnonFTP(dialogMenuItem *self) sprintf(tconf.uid, "%d", FTP_UID); if (!tconf.group[0]) - strcpy(tconf.group, FTP_GROUP); + SAFE_STRCPY(tconf.group, FTP_GROUP); if (!tconf.upload[0]) - strcpy(tconf.upload, FTP_UPLOAD); + SAFE_STRCPY(tconf.upload, FTP_UPLOAD); /*** If the user did not specify a directory, use default ***/ @@ -400,7 +400,7 @@ configAnonFTP(dialogMenuItem *self) tconf.homedir[strlen(tconf.homedir) - 1] = '\0'; if (!tconf.homedir[0]) - strcpy(tconf.homedir, FTP_HOMEDIR); + SAFE_STRCPY(tconf.homedir, FTP_HOMEDIR); /*** If HomeDir does not exist, create it ***/ diff --git a/release/sysinstall/apache.c b/release/sysinstall/apache.c index d33b4cf..bc52542 100644 --- a/release/sysinstall/apache.c +++ b/release/sysinstall/apache.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: apache.c,v 1.27 1996/09/01 08:17:13 jkh Exp $ + * $Id: apache.c,v 1.28 1996/11/04 12:56:15 jkh Exp $ * * Copyright (c) 1995 * Coranth Gryphon. All rights reserved. @@ -232,15 +232,15 @@ apacheOpenDialog(void) sprintf(tconf.hostname, "www.%s", tmp); } - strcpy(tconf.defuser, DEFAULT_USER); - strcpy(tconf.defgroup, DEFAULT_GROUP); + SAFE_STRCPY(tconf.defuser, DEFAULT_USER); + SAFE_STRCPY(tconf.defgroup, DEFAULT_GROUP); - strcpy(tconf.userdir, USER_HOMEDIR); - strcpy(tconf.welcome, WELCOME_FILE); + SAFE_STRCPY(tconf.userdir, USER_HOMEDIR); + SAFE_STRCPY(tconf.welcome, WELCOME_FILE); - strcpy(tconf.logdir, LOGS_SUBDIR); - strcpy(tconf.accesslog, ACCESS_LOGNAME); - strcpy(tconf.errorlog, ERROR_LOGNAME); + SAFE_STRCPY(tconf.logdir, LOGS_SUBDIR); + SAFE_STRCPY(tconf.accesslog, ACCESS_LOGNAME); + SAFE_STRCPY(tconf.errorlog, ERROR_LOGNAME); sprintf(tconf.docroot, "%s/%s", APACHE_BASE,DATA_SUBDIR); @@ -399,21 +399,21 @@ configApache(dialogMenuItem *self) } /*** Fix defaults for invalid value ***/ if (!tconf.logdir[0]) - strcpy(tconf.logdir, LOGS_SUBDIR); + SAFE_STRCPY(tconf.logdir, LOGS_SUBDIR); if (!tconf.accesslog[0]) - strcpy(tconf.accesslog, ACCESS_LOGNAME); + SAFE_STRCPY(tconf.accesslog, ACCESS_LOGNAME); if (!tconf.errorlog[0]) - strcpy(tconf.errorlog, ERROR_LOGNAME); + SAFE_STRCPY(tconf.errorlog, ERROR_LOGNAME); if (!tconf.welcome[0]) - strcpy(tconf.welcome, WELCOME_FILE); + SAFE_STRCPY(tconf.welcome, WELCOME_FILE); if (!tconf.userdir[0]) - strcpy(tconf.userdir, USER_HOMEDIR); + SAFE_STRCPY(tconf.userdir, USER_HOMEDIR); if (!tconf.defuser[0]) - strcpy(tconf.defuser, DEFAULT_USER); + SAFE_STRCPY(tconf.defuser, DEFAULT_USER); if (!tconf.defgroup[0]) - strcpy(tconf.defgroup, DEFAULT_GROUP); + SAFE_STRCPY(tconf.defgroup, DEFAULT_GROUP); /*** If the user did not specify a directory, use default ***/ @@ -433,9 +433,9 @@ configApache(dialogMenuItem *self) if (!file_readable(file)) { tptr = msgGetInput(NULL, "What is your company name?"); if (tptr && tptr[0]) - strcpy(company, tptr); + SAFE_STRCPY(company, tptr); else - strcpy(company, "our Web Page"); + SAFE_STRCPY(company, "our Web Page"); msgNotify("Creating sample web page..."); fptr = fopen(file,"w"); diff --git a/release/sysinstall/attr.c b/release/sysinstall/attr.c index 43a45a4..0bd06cf 100644 --- a/release/sysinstall/attr.c +++ b/release/sysinstall/attr.c @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated to essentially a complete rewrite. * - * $Id: attr.c,v 1.7 1996/06/11 05:06:31 jkh Exp $ + * $Id: attr.c,v 1.8 1996/09/08 01:39:23 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -137,8 +137,8 @@ attr_parse(Attribs *attr, int fd) break; case COMMIT: - strcpy(attr[num_attribs].name, hold_n); - strcpy(attr[num_attribs].value, hold_v); + SAFE_STRCPY(attr[num_attribs].name, hold_n); + SAFE_STRCPY(attr[num_attribs].value, hold_v); state = LOOK; v = n = 0; ++num_attribs; diff --git a/release/sysinstall/config.c b/release/sysinstall/config.c index 7bdc5b9..ab4f062 100644 --- a/release/sysinstall/config.c +++ b/release/sysinstall/config.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: config.c,v 1.60 1996/11/27 22:52:31 phk Exp $ + * $Id: config.c,v 1.61 1996/12/02 05:01:00 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -275,7 +275,7 @@ configSysconfig(char *config) /* Skip the comments */ if (lines[i][0] == '#') continue; - strcpy(tmp, lines[i]); + SAFE_STRCPY(tmp, lines[i]); cp = index(tmp, '='); if (!cp) continue; @@ -411,7 +411,7 @@ skip: if (!index(hp, '.')) cp2[0] = '\0'; else { - strcpy(cp2, hp); + SAFE_STRCPY(cp2, hp); *(index(cp2, '.')) = '\0'; } fprintf(fp, "%s\t\t%s %s\n", cp, hp, cp2); diff --git a/release/sysinstall/devices.c b/release/sysinstall/devices.c index 56d9ec3..8965f6c 100644 --- a/release/sysinstall/devices.c +++ b/release/sysinstall/devices.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: devices.c,v 1.51 1996/11/27 01:01:52 joerg Exp $ + * $Id: devices.c,v 1.52 1996/12/08 12:27:53 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -102,7 +102,7 @@ new_device(char *name) dev = safe_malloc(sizeof(Device)); bzero(dev, sizeof(Device)); if (name) - strcpy(dev->name, name); + SAFE_STRCPY(dev->name, name); return dev; } diff --git a/release/sysinstall/dmenu.c b/release/sysinstall/dmenu.c index 410bd0b..9470f04 100644 --- a/release/sysinstall/dmenu.c +++ b/release/sysinstall/dmenu.c @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated for what's essentially a complete rewrite. * - * $Id: dmenu.c,v 1.26 1996/11/07 08:03:21 jkh Exp $ + * $Id: dmenu.c,v 1.27 1996/11/09 16:46:56 joerg Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -182,7 +182,7 @@ dmenuVarCheck(dialogMenuItem *item) w = (char *)item->data; if (!w) return FALSE; - strncpy(tmp, w, 256); + SAFE_STRCPY(tmp, w); if ((cp = index(tmp, '=')) != NULL) { *(cp++) = '\0'; if ((cp3 = index(cp, ',')) != NULL) diff --git a/release/sysinstall/ftp_strat.c b/release/sysinstall/ftp_strat.c index 9f24ebc..d5887bc 100644 --- a/release/sysinstall/ftp_strat.c +++ b/release/sysinstall/ftp_strat.c @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated to essentially a complete rewrite. * - * $Id: ftp_strat.c,v 1.28 1996/10/02 10:44:28 jkh Exp $ + * $Id: ftp_strat.c,v 1.29 1996/10/12 23:48:31 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -87,7 +87,7 @@ try: else login_name = user; if (variable_get(VAR_FTP_PASS)) - strcpy(password, variable_get(VAR_FTP_PASS)); + SAFE_STRCPY(password, variable_get(VAR_FTP_PASS)); else sprintf(password, "installer@%s", variable_get(VAR_HOSTNAME)); msgNotify("Logging in as %s..", login_name); diff --git a/release/sysinstall/index.c b/release/sysinstall/index.c index 4c5d144..62bcc0e 100644 --- a/release/sysinstall/index.c +++ b/release/sysinstall/index.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: index.c,v 1.37 1996/08/01 12:02:24 jkh Exp $ + * $Id: index.c,v 1.38 1996/08/03 10:10:54 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -491,7 +491,7 @@ index_menu(PkgNodePtr top, PkgNodePtr plist, int *pos, int *scroll) char buf[256]; /* Brutally adjust description to fit in menu */ - strcpy(buf, kp->desc); + SAFE_STRCPY(buf, kp->desc); if (strlen(buf) > (_MAX_DESC - maxname)) buf[_MAX_DESC - maxname] = '\0'; nitems = item_add(nitems, kp->name, buf, pkg_checked, pkg_fire, pkg_selected, kp, (int)plist, &curr, &max); @@ -555,7 +555,7 @@ index_extract_one(Device *dev, PkgNodePtr top, PkgNodePtr who, Boolean depended) if (id && id->deps && strlen(id->deps)) { char t[1024], *cp, *cp2; - strcpy(t, id->deps); + SAFE_STRCPY(t, id->deps); cp = t; while (cp && DITEM_STATUS(status) == DITEM_SUCCESS) { if ((cp2 = index(cp, ' ')) != NULL) diff --git a/release/sysinstall/label.c b/release/sysinstall/label.c index 87a2313..28c670e 100644 --- a/release/sysinstall/label.c +++ b/release/sysinstall/label.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: label.c,v 1.62 1996/10/04 14:53:52 jkh Exp $ + * $Id: label.c,v 1.63 1996/10/06 11:40:31 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -248,7 +248,7 @@ new_part(char *mpoint, Boolean newfs, u_long size) mpoint = "/change_me"; ret = (PartInfo *)safe_malloc(sizeof(PartInfo)); - strncpy(ret->mountpoint, mpoint, FILENAME_MAX); + sstrncpy(ret->mountpoint, mpoint, FILENAME_MAX); strcpy(ret->newfs_cmd, "newfs -b 8192 -f 1024"); ret->newfs = newfs; if (!size) @@ -355,7 +355,7 @@ getNewfsCmd(PartInfo *p) "Please enter the newfs command and options you'd like to use in\n" "creating this file system."); if (val) - strncpy(p->newfs_cmd, val, NEWFS_CMD_MAX); + sstrncpy(p->newfs_cmd, val, NEWFS_CMD_MAX); } #define MAX_MOUNT_NAME 12 diff --git a/release/sysinstall/media.c b/release/sysinstall/media.c index efa9bc6..673baba 100644 --- a/release/sysinstall/media.c +++ b/release/sysinstall/media.c @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated to essentially a complete rewrite. * - * $Id: media.c,v 1.64 1996/11/04 02:12:49 jkh Exp $ + * $Id: media.c,v 1.65 1996/11/07 14:17:09 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -297,7 +297,7 @@ mediaSetFTP(dialogMenuItem *self) variable_unset(VAR_FTP_PATH); return DITEM_FAILURE | what; } - strcpy(ftpDevice.name, cp); + SAFE_STRCPY(ftpDevice.name, cp); dialog_clear_norefresh(); if (RunningAsInit && @@ -409,7 +409,7 @@ mediaSetNFS(dialogMenuItem *self) "host:/full/pathname/to/FreeBSD/distdir"); return DITEM_FAILURE; } - strncpy(nfsDevice.name, cp, DEV_NAME_MAX); + SAFE_STRCPY(nfsDevice.name, cp); /* str == NULL means we were just called to change NFS paths, not network interfaces */ if (!tcpDeviceSelect()) return DITEM_FAILURE; diff --git a/release/sysinstall/misc.c b/release/sysinstall/misc.c index 1dfc30d..17ce8eb 100644 --- a/release/sysinstall/misc.c +++ b/release/sysinstall/misc.c @@ -1,7 +1,7 @@ /* * Miscellaneous support routines.. * - * $Id: misc.c,v 1.21 1996/07/08 08:54:30 jkh Exp $ + * $Id: misc.c,v 1.22 1996/07/09 14:28:17 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -76,6 +76,14 @@ string_concat(char *one, char *two) return tmp; } +/* sane strncpy() function */ +char * +sstrncpy(char *dst, const char *src, int size) +{ + *(dst + size) = '\0'; + return strncpy(dst, src, size - 1); +} + /* Concatenate three strings into static storage */ char * string_concat3(char *one, char *two, char *three) diff --git a/release/sysinstall/msg.c b/release/sysinstall/msg.c index ee79777..7770c70 100644 --- a/release/sysinstall/msg.c +++ b/release/sysinstall/msg.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: msg.c,v 1.40 1996/08/03 10:11:21 jkh Exp $ + * $Id: msg.c,v 1.41 1996/10/01 04:56:34 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -257,7 +257,7 @@ msgGetInput(char *buf, char *fmt, ...) use_helpline(NULL); use_helpfile(NULL); if (buf) - strcpy(input_buffer, buf); + SAFE_STRCPY(input_buffer, buf); else input_buffer[0] = '\0'; if (OnVTY) { diff --git a/release/sysinstall/network.c b/release/sysinstall/network.c index 0b20b12..a7ed90f 100644 --- a/release/sysinstall/network.c +++ b/release/sysinstall/network.c @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated to essentially a complete rewrite. * - * $Id: network.c,v 1.19 1996/12/09 06:37:44 jkh Exp $ + * $Id: network.c,v 1.20 1996/12/09 06:45:03 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -94,7 +94,7 @@ mediaInitNetwork(Device *dev) if (!val) return FALSE; else - strncpy(attach, val, 256); + SAFE_STRCPY(attach, val); /* * Doing this with vsystem() is actually bogus since we should be storing the pid of slattach * for later killing. It's just too convenient to call vsystem(), however, rather than @@ -198,15 +198,17 @@ startPPP(Device *devp) "maximum data rate since most modems can talk at one speed to the\n" "computer and at another speed to the remote end.\n\n" "If you're not sure what to put here, just select the default."); - strncpy(speed, (val && *val) ? val : "115200", 16); + SAFE_STRCPY(speed, (val && *val) ? val : "115200"); + + val = variable_get(VAR_GATEWAY); + SAFE_STRCPY(provider, (val && *val) ? val : "0"); - strncpy(provider, variable_get(VAR_GATEWAY) ? variable_get(VAR_GATEWAY) : "0", 16); val = msgGetInput(provider, "Enter the IP address of your service provider or 0 if you\n" "don't know it and would prefer to negotiate it dynamically."); - strncpy(provider, val ? val : "0", 16); + SAFE_STRCPY(provider, (val && *val) ? val : "0"); if (devp->private && ((DevInfo *)devp->private)->ipaddr[0]) - strncpy(myaddr, ((DevInfo *)devp->private)->ipaddr, 16); + SAFE_STRCPY(myaddr, ((DevInfo *)devp->private)->ipaddr); else strcpy(myaddr, "0"); diff --git a/release/sysinstall/sysinstall.h b/release/sysinstall/sysinstall.h index ddc94e2..dab2d63 100644 --- a/release/sysinstall/sysinstall.h +++ b/release/sysinstall/sysinstall.h @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated to essentially a complete rewrite. * - * $Id: sysinstall.h,v 1.88 1996/12/09 06:02:31 jkh Exp $ + * $Id: sysinstall.h,v 1.89 1996/12/09 06:37:45 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -147,6 +147,8 @@ #define ATTR_SELECTED (ColorDisplay ? item_selected_attr : item_attr) #define ATTR_TITLE button_active_attr +/* Handy strncpy() macro */ +#define SAFE_STRCPY(to, from) sstrncpy((to), (from), sizeof (to)) /*** Types ***/ typedef unsigned int Boolean; @@ -564,6 +566,7 @@ extern int Mkdir(char *); extern int Mount(char *, void *data); extern WINDOW *savescr(void); extern void restorescr(WINDOW *w); +extern char *sstrncpy(char *dst, const char *src, int size); /* msg.c */ extern Boolean isDebug(void); diff --git a/release/sysinstall/tcpip.c b/release/sysinstall/tcpip.c index a774c6d..a8c10fc 100644 --- a/release/sysinstall/tcpip.c +++ b/release/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); diff --git a/release/sysinstall/uc_main.c b/release/sysinstall/uc_main.c index 60487ec..987f597 100644 --- a/release/sysinstall/uc_main.c +++ b/release/sysinstall/uc_main.c @@ -24,7 +24,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * library functions for userconfig library * - * $Id: uc_main.c,v 1.12 1996/10/06 16:04:49 jkh Exp $ + * $Id: uc_main.c,v 1.13 1996/10/12 20:23:17 erich Exp $ */ #include @@ -39,9 +39,7 @@ #include #include "uc_main.h" - -extern int isDebug(void); -extern void msgDebug(char *fmt, ...); +#include "sysinstall.h" static struct nlist _nl[] = { {"_isa_devtab_bio"}, @@ -76,9 +74,9 @@ uc_open(char *name){ incore = 0; if (incore || (strcmp(name,"-bootfile") == 0)) - strncpy(kname, getbootfile(), 79); + SAFE_STRCPY(kname, getbootfile()); else - strncpy(kname, name, 79); + SAFE_STRCPY(kname, name); if (isDebug()) msgDebug("uc_open: kernel name is %s, incore = %d\n", kname, incore); diff --git a/release/sysinstall/variable.c b/release/sysinstall/variable.c index 7d77d15..013358e 100644 --- a/release/sysinstall/variable.c +++ b/release/sysinstall/variable.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: variable.c,v 1.10 1996/04/29 06:47:10 jkh Exp $ + * $Id: variable.c,v 1.11 1996/06/12 14:02:13 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -51,15 +51,15 @@ make_variable(char *var, char *value) if (!strcmp(newvar->name, var)) { if (isDebug()) msgDebug("variable %s was %s, now %s\n", newvar->name, newvar->value, value); - strncpy(newvar->value, value, VAR_VALUE_MAX); + SAFE_STRCPY(newvar->value, value); return; } } /* No? Create a new one */ newvar = (Variable *)safe_malloc(sizeof(Variable)); - strncpy(newvar->name, var, VAR_NAME_MAX); - strncpy(newvar->value, value, VAR_VALUE_MAX); + SAFE_STRCPY(newvar->name, var); + SAFE_STRCPY(newvar->value, value); newvar->next = VarHead; VarHead = newvar; if (isDebug()) @@ -75,7 +75,7 @@ variable_set(char *var) msgFatal("NULL variable name & value passed."); else if (!*var) msgDebug("Warning: Zero length name & value passed to variable_set()\n"); - strncpy(tmp, var, VAR_NAME_MAX + VAR_VALUE_MAX); + SAFE_STRCPY(tmp, var); if ((cp = index(tmp, '=')) == NULL) msgFatal("Invalid variable format: %s", var); *(cp++) = '\0'; -- cgit v1.1