summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorbrian <brian@cvs.openbsd.org>1997-12-18 01:10:27 +0000
committerbrian <brian@cvs.openbsd.org>1997-12-18 01:10:27 +0000
commit2fcde60e0f33befff25fc6c3e2a2010c923a704b (patch)
tree42d57f293073052cdff0914e7f8c6c3a38a33327 /usr.sbin
parent5926ec4d15989689aa36f550da3212dcbc424cb3 (diff)
Replace
strcpy(a, b); /* a and b are the same size */ with strncpy(a, b, sizeof(a)); a[sizeof(a)-1] = '\0'; Making the code `correct at a glance'. Suggested by: Theo de Raadt <deraadt@cvs.openbsd.org>
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ppp/chat.c5
-rw-r--r--usr.sbin/ppp/command.c5
-rw-r--r--usr.sbin/ppp/modem.c5
3 files changed, 9 insertions, 6 deletions
diff --git a/usr.sbin/ppp/chat.c b/usr.sbin/ppp/chat.c
index 2f42b56abb0..f12d98c92cb 100644
--- a/usr.sbin/ppp/chat.c
+++ b/usr.sbin/ppp/chat.c
@@ -18,7 +18,7 @@
* Columbus, OH 43221
* (614)451-1883
*
- * $Id: chat.c,v 1.1 1997/11/23 20:27:33 brian Exp $
+ * $Id: chat.c,v 1.2 1997/12/18 01:10:24 brian Exp $
*
* TODO:
* o Support more UUCP compatible control sequences.
@@ -186,7 +186,8 @@ ExpandString(const char *str, char *result, int reslen, int sendmode)
case 'T':
if (VarAltPhone == NULL) {
if (VarNextPhone == NULL) {
- strcpy(VarPhoneCopy, VarPhoneList);
+ strncpy(VarPhoneCopy, VarPhoneList, sizeof(VarPhoneCopy));
+ VarPhoneCopy[sizeof(VarPhoneCopy) - 1] = '\0';
VarNextPhone = VarPhoneCopy;
}
VarAltPhone = strsep(&VarNextPhone, ":");
diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c
index 0e6f7bde0ad..8866badb18d 100644
--- a/usr.sbin/ppp/command.c
+++ b/usr.sbin/ppp/command.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: command.c,v 1.8 1997/12/18 00:28:48 brian Exp $
+ * $Id: command.c,v 1.9 1997/12/18 01:10:25 brian Exp $
*
*/
#include <sys/param.h>
@@ -1360,7 +1360,8 @@ SetVariable(struct cmdargs const *arg)
case VAR_PHONE:
strncpy(VarPhoneList, argp, sizeof(VarPhoneList) - 1);
VarPhoneList[sizeof(VarPhoneList) - 1] = '\0';
- strcpy(VarPhoneCopy, VarPhoneList);
+ strncpy(VarPhoneCopy, VarPhoneList, sizeof(VarPhoneCopy));
+ VarPhoneCopy[sizeof(VarPhoneCopy) - 1] = '\0';
VarNextPhone = VarPhoneCopy;
VarAltPhone = NULL;
break;
diff --git a/usr.sbin/ppp/modem.c b/usr.sbin/ppp/modem.c
index 8a8bb140fc1..e92a3b719d0 100644
--- a/usr.sbin/ppp/modem.c
+++ b/usr.sbin/ppp/modem.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: modem.c,v 1.1 1997/11/23 20:27:35 brian Exp $
+ * $Id: modem.c,v 1.2 1997/12/18 01:10:26 brian Exp $
*
* TODO:
*/
@@ -680,7 +680,8 @@ HangupModem(int flag)
if (modem >= 0) {
char ScriptBuffer[SCRIPT_LEN];
- strcpy(ScriptBuffer, VarHangupScript); /* arrays are the same size */
+ strncpy(ScriptBuffer, VarHangupScript, sizeof(ScriptBuffer));
+ ScriptBuffer[sizeof(ScriptBuffer) - 1] = '\0';
LogPrintf(LogDEBUG, "HangupModem: Script: %s\n", ScriptBuffer);
if (flag || !(mode & MODE_DEDICATED)) {
DoChat(ScriptBuffer);