KNF. ensure buffers are not overrun.

This commit is contained in:
mrg 1998-07-12 09:14:19 +00:00
parent 1cd9ed7799
commit 97eafd5059
8 changed files with 33 additions and 25 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: biz31.c,v 1.6 1997/11/22 07:28:53 lukem Exp $ */
/* $NetBSD: biz31.c,v 1.7 1998/07/12 09:14:19 mrg Exp $ */
/*
* Copyright (c) 1983, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)biz31.c 8.1 (Berkeley) 6/6/93";
#endif
__RCSID("$NetBSD: biz31.c,v 1.6 1997/11/22 07:28:53 lukem Exp $");
__RCSID("$NetBSD: biz31.c,v 1.7 1998/07/12 09:14:19 mrg Exp $");
#endif /* not lint */
#include "tip.h"
@ -140,7 +140,6 @@ echo(s)
char c;
while (c = *s++) switch (c) {
case '$':
read(FD, &c, 1);
s++;

View File

@ -1,4 +1,4 @@
/* $NetBSD: courier.c,v 1.9 1998/03/30 02:31:44 mrg Exp $ */
/* $NetBSD: courier.c,v 1.10 1998/07/12 09:14:20 mrg Exp $ */
/*
* Copyright (c) 1986, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)courier.c 8.1 (Berkeley) 6/6/93";
#endif
__RCSID("$NetBSD: courier.c,v 1.9 1998/03/30 02:31:44 mrg Exp $");
__RCSID("$NetBSD: courier.c,v 1.10 1998/07/12 09:14:20 mrg Exp $");
#endif /* not lint */
/*
@ -125,7 +125,8 @@ badsynch:
void
cour_disconnect()
{
/* first hang up the modem*/
/* first hang up the modem*/
ioctl(FD, TIOCCDTR, 0);
sleep(1);
ioctl(FD, TIOCSDTR, 0);
@ -136,6 +137,7 @@ cour_disconnect()
void
cour_abort()
{
cour_write(FD, "\r", 1); /* send anything to abort the call */
cour_disconnect();
}
@ -144,6 +146,7 @@ static void
sigALRM(dummy)
int dummy;
{
printf("\07timeout waiting for reply\n");
timeout = 1;
longjmp(timeoutbuf, 1);
@ -218,10 +221,9 @@ cour_connect()
return (0);
f = signal(SIGALRM, sigALRM);
again:
nc = 0; nl = sizeof(dialer_buf)-1;
memset(dialer_buf, 0, sizeof(dialer_buf));
timeout = 0;
for (nc = 0, nl = sizeof(dialer_buf)-1 ; nl > 0 ; nc++, nl--) {
for (nc = 0, nl = sizeof(dialer_buf) - 1 ; nl > 0 ; nc++, nl--) {
if (setjmp(timeoutbuf))
break;
alarm(number(value(DIALTIMEOUT)));
@ -326,6 +328,7 @@ cour_write(fd, cp, n)
char *cp;
int n;
{
#ifdef notdef
if (boolean(value(VERBOSE)))
write(1, cp, n);
@ -399,5 +402,6 @@ static void
cour_napx(dummy)
int dummy;
{
ringring = 1;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: dn11.c,v 1.5 1997/11/22 07:28:55 lukem Exp $ */
/* $NetBSD: dn11.c,v 1.6 1998/07/12 09:14:20 mrg Exp $ */
/*
* Copyright (c) 1983, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)dn11.c 8.1 (Berkeley) 6/6/93";
#endif
__RCSID("$NetBSD: dn11.c,v 1.5 1997/11/22 07:28:55 lukem Exp $");
__RCSID("$NetBSD: dn11.c,v 1.6 1998/07/12 09:14:20 mrg Exp $");
#endif /* not lint */
/*
@ -120,6 +120,7 @@ static void
alarmtr(dummy)
int dummy;
{
alarm(0);
longjmp(jmpbuf, 1);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: hayes.c,v 1.7 1997/11/22 07:28:56 lukem Exp $ */
/* $NetBSD: hayes.c,v 1.8 1998/07/12 09:14:20 mrg Exp $ */
/*
* Copyright (c) 1983, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)hayes.c 8.1 (Berkeley) 6/6/93";
#endif
__RCSID("$NetBSD: hayes.c,v 1.7 1997/11/22 07:28:56 lukem Exp $");
__RCSID("$NetBSD: hayes.c,v 1.8 1998/07/12 09:14:20 mrg Exp $");
#endif /* not lint */
/*
@ -219,6 +219,7 @@ static void
error_rep(c)
char c;
{
printf("\n\r");
switch (c) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: t3000.c,v 1.7 1998/03/30 02:31:44 mrg Exp $ */
/* $NetBSD: t3000.c,v 1.8 1998/07/12 09:14:20 mrg Exp $ */
/*
* Copyright (c) 1992, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)t3000.c 8.1 (Berkeley) 6/6/93";
#endif
__RCSID("$NetBSD: t3000.c,v 1.7 1998/03/30 02:31:44 mrg Exp $");
__RCSID("$NetBSD: t3000.c,v 1.8 1998/07/12 09:14:20 mrg Exp $");
#endif /* not lint */
/*
@ -229,7 +229,6 @@ t3000_connect()
return (0);
f = signal(SIGALRM, sigALRM);
again:
nc = 0; nl = sizeof(dialer_buf)-1;
memset(dialer_buf, 0, sizeof(dialer_buf));
timeout = 0;
for (nc = 0, nl = sizeof(dialer_buf)-1 ; nl > 0 ; nc++, nl--) {
@ -340,6 +339,7 @@ t3000_write(fd, cp, n)
char *cp;
int n;
{
#ifdef notdef
if (boolean(value(VERBOSE)))
write(1, cp, n);
@ -412,5 +412,6 @@ static void
t3000_napx(dummy)
int dummy;
{
ringring = 1;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: v3451.c,v 1.7 1997/11/22 07:28:57 lukem Exp $ */
/* $NetBSD: v3451.c,v 1.8 1998/07/12 09:14:20 mrg Exp $ */
/*
* Copyright (c) 1983, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)v3451.c 8.1 (Berkeley) 6/6/93";
#endif
__RCSID("$NetBSD: v3451.c,v 1.7 1997/11/22 07:28:57 lukem Exp $");
__RCSID("$NetBSD: v3451.c,v 1.8 1998/07/12 09:14:20 mrg Exp $");
#endif /* not lint */
/*
@ -203,6 +203,7 @@ static void
alarmtr(dummy)
int dummy;
{
longjmp(Sjbuf, 1);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: v831.c,v 1.6 1997/11/22 07:28:58 lukem Exp $ */
/* $NetBSD: v831.c,v 1.7 1998/07/12 09:14:20 mrg Exp $ */
/*
* Copyright (c) 1983, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)v831.c 8.1 (Berkeley) 6/6/93";
#endif
__RCSID("$NetBSD: v831.c,v 1.6 1997/11/22 07:28:58 lukem Exp $");
__RCSID("$NetBSD: v831.c,v 1.7 1998/07/12 09:14:20 mrg Exp $");
#endif /* not lint */
/*
@ -121,6 +121,7 @@ static void
alarmtr(dummy)
int dummy;
{
alarm(0);
longjmp(jmpbuf, 1);
}
@ -255,7 +256,7 @@ sanitize(s)
static char buf[128];
char *cp;
for (cp = buf; *s; s++) {
for (cp = buf; *s && buf + sizeof buf - cp > 1; s++) {
if (!isdigit(*s) && *s == '<' && *s != '_')
continue;
if (*s == '_')

View File

@ -1,4 +1,4 @@
/* $NetBSD: ventel.c,v 1.7 1997/11/22 07:28:59 lukem Exp $ */
/* $NetBSD: ventel.c,v 1.8 1998/07/12 09:14:20 mrg Exp $ */
/*
* Copyright (c) 1983, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)ventel.c 8.1 (Berkeley) 6/6/93";
#endif
__RCSID("$NetBSD: ventel.c,v 1.7 1997/11/22 07:28:59 lukem Exp $");
__RCSID("$NetBSD: ventel.c,v 1.8 1998/07/12 09:14:20 mrg Exp $");
#endif /* not lint */
/*
@ -176,6 +176,7 @@ static void
sigALRM(dummy)
int dummy;
{
printf("\07timeout waiting for reply\n");
timeout = 1;
longjmp(timeoutbuf, 1);
@ -255,8 +256,8 @@ vensync(fd)
continue;
}
while (nread > 0) {
read(fd, buf, min(nread, 60));
if ((buf[nread - 1] & 0177) == '$')
read(fd, buf, min(nread, sizeof buf));
if ((buf[min(nread, sizeof buf) - 1] & 0177) == '$')
return (1);
nread -= min(nread, 60);
}
@ -265,4 +266,3 @@ vensync(fd)
}
return (0);
}