diff options
author | brian <brian@cvs.openbsd.org> | 1997-12-23 22:38:04 +0000 |
---|---|---|
committer | brian <brian@cvs.openbsd.org> | 1997-12-23 22:38:04 +0000 |
commit | 5b328ddb5aa49cb7e5e4d9072e21d9e4b1f90acd (patch) | |
tree | 4340619842ab0940f8d489b47a4806655b4d5afa | |
parent | 54118aee3c311f24af1c94a68759b0863cf8392f (diff) |
strncpy(x,y,sizeof(x)) --> strncpy(x,y,sizeof(x)-1)
Suggested by: Philippe Charnier <charnier@lirmm.fr>
Theo de Raadt <deraadt@cvs.openbsd.org>
-rw-r--r-- | usr.sbin/ppp/arp.c | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/chat.c | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/command.c | 8 | ||||
-rw-r--r-- | usr.sbin/ppp/defs.c | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/iplist.c | 4 | ||||
-rw-r--r-- | usr.sbin/ppp/modem.c | 8 |
6 files changed, 16 insertions, 16 deletions
diff --git a/usr.sbin/ppp/arp.c b/usr.sbin/ppp/arp.c index bed1cd879aa..4fd52304bbf 100644 --- a/usr.sbin/ppp/arp.c +++ b/usr.sbin/ppp/arp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: arp.c,v 1.1 1997/11/23 20:27:32 brian Exp $ + * $Id: arp.c,v 1.2 1997/12/23 22:38:00 brian Exp $ * */ @@ -244,7 +244,7 @@ get_ether_addr(int s, u_long ipaddr, struct sockaddr_dl *hwaddr) for (ifr = ifc.ifc_req; ifr < ifend;) { if (ifr->ifr_addr.sa_family == AF_INET) { ina = ((struct sockaddr_in *) & ifr->ifr_addr)->sin_addr.s_addr; - strncpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name)); + strncpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name) - 1); ifreq.ifr_name[sizeof(ifreq.ifr_name) - 1] = '\0'; /* diff --git a/usr.sbin/ppp/chat.c b/usr.sbin/ppp/chat.c index f12d98c92cb..dcc10b607c0 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.2 1997/12/18 01:10:24 brian Exp $ + * $Id: chat.c,v 1.3 1997/12/23 22:38:01 brian Exp $ * * TODO: * o Support more UUCP compatible control sequences. @@ -186,7 +186,7 @@ ExpandString(const char *str, char *result, int reslen, int sendmode) case 'T': if (VarAltPhone == NULL) { if (VarNextPhone == NULL) { - strncpy(VarPhoneCopy, VarPhoneList, sizeof(VarPhoneCopy)); + strncpy(VarPhoneCopy, VarPhoneList, sizeof(VarPhoneCopy) - 1); VarPhoneCopy[sizeof(VarPhoneCopy) - 1] = '\0'; VarNextPhone = VarPhoneCopy; } diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c index be7150d1670..5400c3a86c3 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.11 1997/12/21 03:15:53 brian Exp $ + * $Id: command.c,v 1.12 1997/12/23 22:38:01 brian Exp $ * */ #include <sys/param.h> @@ -766,7 +766,7 @@ RunCommand(int argc, char const *const *argv, const char *label) *buf = '\0'; if (label) { - strncpy(buf, label, sizeof buf); + strncpy(buf, label, sizeof(buf) - 3); buf[sizeof(buf)-3] = '\0'; strcat(buf, ": "); } @@ -999,7 +999,7 @@ SetServer(struct cmdargs const *arg) if (passwd == NULL) VarHaveLocalAuthKey = 0; else { - strncpy(VarLocalAuthKey, passwd, sizeof VarLocalAuthKey); + strncpy(VarLocalAuthKey, passwd, sizeof(VarLocalAuthKey) - 1); VarLocalAuthKey[sizeof VarLocalAuthKey - 1] = '\0'; VarHaveLocalAuthKey = 1; } @@ -1360,7 +1360,7 @@ SetVariable(struct cmdargs const *arg) case VAR_PHONE: strncpy(VarPhoneList, argp, sizeof(VarPhoneList) - 1); VarPhoneList[sizeof(VarPhoneList) - 1] = '\0'; - strncpy(VarPhoneCopy, VarPhoneList, sizeof(VarPhoneCopy)); + strncpy(VarPhoneCopy, VarPhoneList, sizeof(VarPhoneCopy) - 1); VarPhoneCopy[sizeof(VarPhoneCopy) - 1] = '\0'; VarNextPhone = VarPhoneCopy; VarAltPhone = NULL; diff --git a/usr.sbin/ppp/defs.c b/usr.sbin/ppp/defs.c index b295a5ee713..c0ce7c6303b 100644 --- a/usr.sbin/ppp/defs.c +++ b/usr.sbin/ppp/defs.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: defs.c,v 1.2 1997/12/21 14:27:03 brian Exp $ + * $Id: defs.c,v 1.3 1997/12/23 22:38:02 brian Exp $ */ #include <sys/param.h> @@ -56,7 +56,7 @@ void SetLabel(const char *label) { if (label) - strncpy(dstsystem, label, sizeof dstsystem); + strncpy(dstsystem, label, sizeof(dstsystem) - 1); else *dstsystem = '\0'; } diff --git a/usr.sbin/ppp/iplist.c b/usr.sbin/ppp/iplist.c index f24455ecf2a..aa555039368 100644 --- a/usr.sbin/ppp/iplist.c +++ b/usr.sbin/ppp/iplist.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: iplist.c,v 1.2 1997/12/21 14:27:05 brian Exp $ + * $Id: iplist.c,v 1.3 1997/12/23 22:38:02 brian Exp $ */ #include <sys/types.h> @@ -149,7 +149,7 @@ iplist_next(struct iplist *list) int iplist_setsrc(struct iplist *list, const char *src) { - strncpy(list->src, src, sizeof(list->src)); + strncpy(list->src, src, sizeof(list->src)-1); list->src[sizeof(list->src)-1] = '\0'; list->cur.srcptr = list->src; do { diff --git a/usr.sbin/ppp/modem.c b/usr.sbin/ppp/modem.c index fcdffe3bcbb..d6cf4b53b00 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.3 1997/12/21 03:15:54 brian Exp $ + * $Id: modem.c,v 1.4 1997/12/23 22:38:03 brian Exp $ * * TODO: */ @@ -466,12 +466,12 @@ OpenModem() return modem = 0; } } else { - strncpy(tmpDeviceList, VarDeviceList, sizeof(tmpDeviceList)); + strncpy(tmpDeviceList, VarDeviceList, sizeof(tmpDeviceList)-1); tmpDeviceList[sizeof(tmpDeviceList)-1] = '\0'; for(tmpDevice=strtok(tmpDeviceList, ","); tmpDevice && (modem < 0); tmpDevice=strtok(NULL,",")) { - strncpy(VarDevice, tmpDevice, sizeof(VarDevice)); + strncpy(VarDevice, tmpDevice, sizeof(VarDevice)-1); VarDevice[sizeof(VarDevice)-1]= '\0'; VarBaseDevice = strrchr(VarDevice, '/'); VarBaseDevice = VarBaseDevice ? VarBaseDevice + 1 : ""; @@ -700,7 +700,7 @@ HangupModem(int flag) if (modem >= 0) { char ScriptBuffer[SCRIPT_LEN]; - strncpy(ScriptBuffer, VarHangupScript, sizeof(ScriptBuffer)); + strncpy(ScriptBuffer, VarHangupScript, sizeof(ScriptBuffer)-1); ScriptBuffer[sizeof(ScriptBuffer) - 1] = '\0'; LogPrintf(LogDEBUG, "HangupModem: Script: %s\n", ScriptBuffer); if (flag || !(mode & MODE_DEDICATED)) { |