Cosmetic (style):
sizeof(var) -> sizeof var sizeof type -> sizeof(type) Suggested by: J Wunsch <j@uriah.heep.sax.de>
This commit is contained in:
parent
eb98bd2e03
commit
14c2d8291d
@ -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.18 1997/11/22 03:37:22 brian Exp $
|
||||
* $Id: arp.c,v 1.19 1997/12/23 22:38:51 brian Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -90,7 +90,7 @@ sifproxyarp(int unit, u_long hisaddr)
|
||||
* Get the hardware address of an interface on the same subnet as our local
|
||||
* address.
|
||||
*/
|
||||
memset(&arpmsg, 0, sizeof(arpmsg));
|
||||
memset(&arpmsg, 0, sizeof arpmsg);
|
||||
if (!get_ether_addr(unit, hisaddr, &arpmsg.hwa)) {
|
||||
LogPrintf(LogERROR, "Cannot determine ethernet address for proxy ARP\n");
|
||||
return 0;
|
||||
@ -168,7 +168,7 @@ sifproxyarp(int unit, u_long hisaddr)
|
||||
char space[128];
|
||||
} dls;
|
||||
|
||||
memset(&arpreq, '\0', sizeof(arpreq));
|
||||
memset(&arpreq, '\0', sizeof arpreq);
|
||||
|
||||
/*
|
||||
* Get the hardware address of an interface on the same subnet as our local
|
||||
@ -199,7 +199,7 @@ cifproxyarp(int unit, u_long hisaddr)
|
||||
{
|
||||
struct arpreq arpreq;
|
||||
|
||||
memset(&arpreq, '\0', sizeof(arpreq));
|
||||
memset(&arpreq, '\0', sizeof arpreq);
|
||||
SET_SA_FAMILY(arpreq.arp_pa, AF_INET);
|
||||
((struct sockaddr_in *) & arpreq.arp_pa)->sin_addr.s_addr = hisaddr;
|
||||
if (ID0ioctl(unit, SIOCDARP, (caddr_t) & arpreq) < 0) {
|
||||
@ -228,7 +228,7 @@ get_ether_addr(int s, u_long ipaddr, struct sockaddr_dl *hwaddr)
|
||||
struct ifconf ifc;
|
||||
struct ifreq ifs[MAX_IFS];
|
||||
|
||||
ifc.ifc_len = sizeof(ifs);
|
||||
ifc.ifc_len = sizeof ifs;
|
||||
ifc.ifc_req = ifs;
|
||||
if (ioctl(s, SIOCGIFCONF, &ifc) < 0) {
|
||||
LogPrintf(LogERROR, "get_ether_addr: ioctl(SIOCGIFCONF): %s\n",
|
||||
@ -244,8 +244,8 @@ 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) - 1);
|
||||
ifreq.ifr_name[sizeof(ifreq.ifr_name) - 1] = '\0';
|
||||
strncpy(ifreq.ifr_name, ifr->ifr_name, sizeof ifreq.ifr_name - 1);
|
||||
ifreq.ifr_name[sizeof ifreq.ifr_name - 1] = '\0';
|
||||
|
||||
/*
|
||||
* Check that the interface is up, and not point-to-point or loopback.
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: auth.c,v 1.23 1997/11/17 00:42:37 brian Exp $
|
||||
* $Id: auth.c,v 1.24 1997/11/22 03:37:24 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o Implement check against with registered IP addresses.
|
||||
@ -79,11 +79,11 @@ LocalAuthValidate(const char *fname, const char *system, const char *key)
|
||||
fp = OpenSecret(fname);
|
||||
if (fp == NULL)
|
||||
return (rc);
|
||||
while (fgets(buff, sizeof(buff), fp)) {
|
||||
while (fgets(buff, sizeof buff, fp)) {
|
||||
if (buff[0] == '#')
|
||||
continue;
|
||||
buff[strlen(buff) - 1] = 0;
|
||||
memset(vector, '\0', sizeof(vector));
|
||||
memset(vector, '\0', sizeof vector);
|
||||
n = MakeArgs(buff, vector, VECSIZE(vector));
|
||||
if (n < 1)
|
||||
continue;
|
||||
@ -113,19 +113,19 @@ AuthValidate(const char *fname, const char *system, const char *key)
|
||||
fp = OpenSecret(fname);
|
||||
if (fp == NULL)
|
||||
return (0);
|
||||
while (fgets(buff, sizeof(buff), fp)) {
|
||||
while (fgets(buff, sizeof buff, fp)) {
|
||||
if (buff[0] == '#')
|
||||
continue;
|
||||
buff[strlen(buff) - 1] = 0;
|
||||
memset(vector, '\0', sizeof(vector));
|
||||
memset(vector, '\0', sizeof vector);
|
||||
n = MakeArgs(buff, vector, VECSIZE(vector));
|
||||
if (n < 2)
|
||||
continue;
|
||||
if (strcmp(vector[0], system) == 0) {
|
||||
ExpandString(vector[1], passwd, sizeof(passwd), 0);
|
||||
ExpandString(vector[1], passwd, sizeof passwd, 0);
|
||||
if (strcmp(passwd, key) == 0) {
|
||||
CloseSecret(fp);
|
||||
memset(&DefHisAddress, '\0', sizeof(DefHisAddress));
|
||||
memset(&DefHisAddress, '\0', sizeof DefHisAddress);
|
||||
n -= 2;
|
||||
if (n > 0) {
|
||||
if (ParseAddr(n--, (char const *const *)(vector+2),
|
||||
@ -156,18 +156,18 @@ AuthGetSecret(const char *fname, const char *system, int len, int setaddr)
|
||||
fp = OpenSecret(fname);
|
||||
if (fp == NULL)
|
||||
return (NULL);
|
||||
while (fgets(buff, sizeof(buff), fp)) {
|
||||
while (fgets(buff, sizeof buff, fp)) {
|
||||
if (buff[0] == '#')
|
||||
continue;
|
||||
buff[strlen(buff) - 1] = 0;
|
||||
memset(vector, '\0', sizeof(vector));
|
||||
memset(vector, '\0', sizeof vector);
|
||||
n = MakeArgs(buff, vector, VECSIZE(vector));
|
||||
if (n < 2)
|
||||
continue;
|
||||
if (strlen(vector[0]) == len && strncmp(vector[0], system, len) == 0) {
|
||||
ExpandString(vector[1], passwd, sizeof(passwd), 0);
|
||||
ExpandString(vector[1], passwd, sizeof passwd, 0);
|
||||
if (setaddr) {
|
||||
memset(&DefHisAddress, '\0', sizeof(DefHisAddress));
|
||||
memset(&DefHisAddress, '\0', sizeof DefHisAddress);
|
||||
}
|
||||
n -= 2;
|
||||
if (n > 0 && setaddr) {
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: ccp.c,v 1.24 1997/12/13 02:37:21 brian Exp $
|
||||
* $Id: ccp.c,v 1.25 1997/12/17 21:21:53 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o Support other compression protocols
|
||||
@ -100,7 +100,7 @@ static char const *cftypes[] = {
|
||||
"DEFLATE", /* 26: Deflate (rfc1979) */
|
||||
};
|
||||
|
||||
#define NCFTYPES (sizeof(cftypes)/sizeof(char *))
|
||||
#define NCFTYPES (sizeof cftypes/sizeof cftypes[0])
|
||||
|
||||
static const char *
|
||||
protoname(int proto)
|
||||
@ -119,7 +119,7 @@ static const struct ccp_algorithm *algorithm[] = {
|
||||
|
||||
static int in_algorithm = -1;
|
||||
static int out_algorithm = -1;
|
||||
#define NALGORITHMS (sizeof(algorithm)/sizeof(algorithm[0]))
|
||||
#define NALGORITHMS (sizeof algorithm/sizeof algorithm[0])
|
||||
|
||||
int
|
||||
ReportCcpStatus(struct cmdargs const *arg)
|
||||
@ -138,7 +138,7 @@ ReportCcpStatus(struct cmdargs const *arg)
|
||||
static void
|
||||
ccpstateInit(void)
|
||||
{
|
||||
memset(&CcpInfo, '\0', sizeof(struct ccpstate));
|
||||
memset(&CcpInfo, '\0', sizeof CcpInfo);
|
||||
CcpInfo.his_proto = CcpInfo.my_proto = -1;
|
||||
if (in_algorithm >= 0 && in_algorithm < NALGORITHMS) {
|
||||
(*algorithm[in_algorithm]->i.Term)();
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: chap.c,v 1.26 1997/11/22 03:37:25 brian Exp $
|
||||
* $Id: chap.c,v 1.27 1997/12/07 23:55:25 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -230,10 +230,10 @@ RecvChapTalk(struct fsmheader *chp, struct mbuf *bp)
|
||||
VarBaseDevice);
|
||||
else {
|
||||
struct utmp ut;
|
||||
memset(&ut, 0, sizeof(ut));
|
||||
memset(&ut, 0, sizeof ut);
|
||||
time(&ut.ut_time);
|
||||
strncpy(ut.ut_name, name, sizeof(ut.ut_name)-1);
|
||||
strncpy(ut.ut_line, VarBaseDevice, sizeof(ut.ut_line)-1);
|
||||
strncpy(ut.ut_name, name, sizeof ut.ut_name - 1);
|
||||
strncpy(ut.ut_line, VarBaseDevice, sizeof ut.ut_line - 1);
|
||||
if (logout(ut.ut_line))
|
||||
logwtmp(ut.ut_line, "", "");
|
||||
login(&ut);
|
||||
|
@ -19,7 +19,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: chap_ms.c,v 1.2 1997/10/26 01:02:20 brian Exp $
|
||||
* $Id: chap_ms.c,v 1.3 1997/11/22 03:37:26 brian Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -53,7 +53,7 @@ ChallengeResponse(u_char *challenge, u_char *pwHash, u_char *response)
|
||||
{
|
||||
char ZPasswordHash[21];
|
||||
|
||||
memset(ZPasswordHash, '\0', sizeof(ZPasswordHash));
|
||||
memset(ZPasswordHash, '\0', sizeof ZPasswordHash);
|
||||
memcpy(ZPasswordHash, pwHash, 16);
|
||||
|
||||
DesEncrypt(challenge, ZPasswordHash + 0, response + 0);
|
||||
|
@ -18,7 +18,7 @@
|
||||
* Columbus, OH 43221
|
||||
* (614)451-1883
|
||||
*
|
||||
* $Id: chat.c,v 1.40 1997/12/18 01:10:12 brian Exp $
|
||||
* $Id: chat.c,v 1.41 1997/12/23 22:38:51 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o Support more UUCP compatible control sequences.
|
||||
@ -186,8 +186,8 @@ ExpandString(const char *str, char *result, int reslen, int sendmode)
|
||||
case 'T':
|
||||
if (VarAltPhone == NULL) {
|
||||
if (VarNextPhone == NULL) {
|
||||
strncpy(VarPhoneCopy, VarPhoneList, sizeof(VarPhoneCopy) - 1);
|
||||
VarPhoneCopy[sizeof(VarPhoneCopy) - 1] = '\0';
|
||||
strncpy(VarPhoneCopy, VarPhoneList, sizeof VarPhoneCopy - 1);
|
||||
VarPhoneCopy[sizeof VarPhoneCopy - 1] = '\0';
|
||||
VarNextPhone = VarPhoneCopy;
|
||||
}
|
||||
VarAltPhone = strsep(&VarNextPhone, ":");
|
||||
@ -292,7 +292,7 @@ WaitforString(const char *estr)
|
||||
omask = sigblock(sigmask(SIGALRM));
|
||||
#endif
|
||||
clear_log();
|
||||
ExpandString(estr, buff, sizeof(buff), 0);
|
||||
ExpandString(estr, buff, sizeof buff, 0);
|
||||
LogPrintf(LogCHAT, "Wait for (%d): %s --> %s\n", TimeoutSec, estr, buff);
|
||||
str = buff;
|
||||
inp = inbuff;
|
||||
@ -489,7 +489,7 @@ SendString(const char *str)
|
||||
|
||||
if (abort_next) {
|
||||
abort_next = 0;
|
||||
ExpandString(str, buff, sizeof(buff), 0);
|
||||
ExpandString(str, buff, sizeof buff, 0);
|
||||
AbortStrings[numaborts++] = strdup(buff);
|
||||
} else if (timeout_next) {
|
||||
timeout_next = 0;
|
||||
@ -498,10 +498,10 @@ SendString(const char *str)
|
||||
TimeoutSec = 30;
|
||||
} else {
|
||||
if (*str == '!') {
|
||||
ExpandString(str + 1, buff + 2, sizeof(buff) - 2, 0);
|
||||
ExpandString(str + 1, buff + 2, sizeof buff - 2, 0);
|
||||
ExecStr(buff + 2, buff + 2);
|
||||
} else {
|
||||
ExpandString(str, buff + 2, sizeof(buff) - 2, 1);
|
||||
ExpandString(str, buff + 2, sizeof buff - 2, 1);
|
||||
}
|
||||
if (strstr(str, "\\P")) /* Do not log the password itself. */
|
||||
LogPrintf(LogCHAT, "sending: %s\n", str);
|
||||
@ -615,7 +615,7 @@ DoChat(char *script)
|
||||
}
|
||||
numaborts = 0;
|
||||
|
||||
memset(vector, '\0', sizeof(vector));
|
||||
memset(vector, '\0', sizeof vector);
|
||||
argc = MakeArgs(script, vector, VECSIZE(vector));
|
||||
argv = vector;
|
||||
TimeoutSec = 30;
|
||||
|
@ -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.116 1997/12/21 03:16:09 brian Exp $
|
||||
* $Id: command.c,v 1.117 1997/12/23 22:38:52 brian Exp $
|
||||
*
|
||||
*/
|
||||
#include <sys/param.h>
|
||||
@ -766,18 +766,18 @@ RunCommand(int argc, char const *const *argv, const char *label)
|
||||
|
||||
*buf = '\0';
|
||||
if (label) {
|
||||
strncpy(buf, label, sizeof(buf) - 3);
|
||||
buf[sizeof(buf)-3] = '\0';
|
||||
strncpy(buf, label, sizeof buf - 3);
|
||||
buf[sizeof buf - 3] = '\0';
|
||||
strcat(buf, ": ");
|
||||
}
|
||||
n = strlen(buf);
|
||||
for (f = 0; f < argc; f++) {
|
||||
if (n < sizeof(buf)-1 && f)
|
||||
if (n < sizeof buf - 1 && f)
|
||||
buf[n++] = ' ';
|
||||
if (arghidden(argc, argv, f))
|
||||
strncpy(buf+n, HIDDEN, sizeof(buf)-n-1);
|
||||
strncpy(buf+n, HIDDEN, sizeof buf - n - 1);
|
||||
else
|
||||
strncpy(buf+n, argv[f], sizeof(buf)-n-1);
|
||||
strncpy(buf+n, argv[f], sizeof buf - n - 1);
|
||||
n += strlen(buf+n);
|
||||
}
|
||||
LogPrintf(LogCOMMAND, "%s\n", buf);
|
||||
@ -999,7 +999,7 @@ SetServer(struct cmdargs const *arg)
|
||||
if (passwd == NULL)
|
||||
VarHaveLocalAuthKey = 0;
|
||||
else {
|
||||
strncpy(VarLocalAuthKey, passwd, sizeof(VarLocalAuthKey) - 1);
|
||||
strncpy(VarLocalAuthKey, passwd, sizeof VarLocalAuthKey - 1);
|
||||
VarLocalAuthKey[sizeof VarLocalAuthKey - 1] = '\0';
|
||||
VarHaveLocalAuthKey = 1;
|
||||
}
|
||||
@ -1329,28 +1329,28 @@ SetVariable(struct cmdargs const *arg)
|
||||
|
||||
switch (param) {
|
||||
case VAR_AUTHKEY:
|
||||
strncpy(VarAuthKey, argp, sizeof(VarAuthKey) - 1);
|
||||
VarAuthKey[sizeof(VarAuthKey) - 1] = '\0';
|
||||
strncpy(VarAuthKey, argp, sizeof VarAuthKey - 1);
|
||||
VarAuthKey[sizeof VarAuthKey - 1] = '\0';
|
||||
break;
|
||||
case VAR_AUTHNAME:
|
||||
strncpy(VarAuthName, argp, sizeof(VarAuthName) - 1);
|
||||
VarAuthName[sizeof(VarAuthName) - 1] = '\0';
|
||||
strncpy(VarAuthName, argp, sizeof VarAuthName - 1);
|
||||
VarAuthName[sizeof VarAuthName - 1] = '\0';
|
||||
break;
|
||||
case VAR_DIAL:
|
||||
strncpy(VarDialScript, argp, sizeof(VarDialScript) - 1);
|
||||
VarDialScript[sizeof(VarDialScript) - 1] = '\0';
|
||||
strncpy(VarDialScript, argp, sizeof VarDialScript - 1);
|
||||
VarDialScript[sizeof VarDialScript - 1] = '\0';
|
||||
break;
|
||||
case VAR_LOGIN:
|
||||
strncpy(VarLoginScript, argp, sizeof(VarLoginScript) - 1);
|
||||
VarLoginScript[sizeof(VarLoginScript) - 1] = '\0';
|
||||
strncpy(VarLoginScript, argp, sizeof VarLoginScript - 1);
|
||||
VarLoginScript[sizeof VarLoginScript - 1] = '\0';
|
||||
break;
|
||||
case VAR_DEVICE:
|
||||
if (modem != -1)
|
||||
LogPrintf(LogWARN, "Cannot change device to \"%s\" when \"%s\" is open\n",
|
||||
argp, VarDevice);
|
||||
else {
|
||||
strncpy(VarDeviceList, argp, sizeof(VarDeviceList) - 1);
|
||||
VarDeviceList[sizeof(VarDeviceList) - 1] = '\0';
|
||||
strncpy(VarDeviceList, argp, sizeof VarDeviceList - 1);
|
||||
VarDeviceList[sizeof VarDeviceList - 1] = '\0';
|
||||
}
|
||||
break;
|
||||
case VAR_ACCMAP:
|
||||
@ -1358,16 +1358,16 @@ SetVariable(struct cmdargs const *arg)
|
||||
VarAccmap = map;
|
||||
break;
|
||||
case VAR_PHONE:
|
||||
strncpy(VarPhoneList, argp, sizeof(VarPhoneList) - 1);
|
||||
VarPhoneList[sizeof(VarPhoneList) - 1] = '\0';
|
||||
strncpy(VarPhoneCopy, VarPhoneList, sizeof(VarPhoneCopy) - 1);
|
||||
VarPhoneCopy[sizeof(VarPhoneCopy) - 1] = '\0';
|
||||
strncpy(VarPhoneList, argp, sizeof VarPhoneList - 1);
|
||||
VarPhoneList[sizeof VarPhoneList - 1] = '\0';
|
||||
strncpy(VarPhoneCopy, VarPhoneList, sizeof VarPhoneCopy - 1);
|
||||
VarPhoneCopy[sizeof VarPhoneCopy - 1] = '\0';
|
||||
VarNextPhone = VarPhoneCopy;
|
||||
VarAltPhone = NULL;
|
||||
break;
|
||||
case VAR_HANGUP:
|
||||
strncpy(VarHangupScript, argp, sizeof(VarHangupScript) - 1);
|
||||
VarHangupScript[sizeof(VarHangupScript) - 1] = '\0';
|
||||
strncpy(VarHangupScript, argp, sizeof VarHangupScript - 1);
|
||||
VarHangupScript[sizeof VarHangupScript - 1] = '\0';
|
||||
break;
|
||||
#ifdef HAVE_DES
|
||||
case VAR_ENC:
|
||||
|
@ -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.6 1997/12/21 12:11:05 brian Exp $
|
||||
* $Id: defs.c,v 1.7 1997/12/23 22:38:53 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -56,7 +56,7 @@ void
|
||||
SetLabel(const char *label)
|
||||
{
|
||||
if (label)
|
||||
strncpy(dstsystem, label, sizeof(dstsystem) - 1);
|
||||
strncpy(dstsystem, label, sizeof dstsystem - 1);
|
||||
else
|
||||
*dstsystem = '\0';
|
||||
}
|
||||
@ -88,7 +88,7 @@ GetShortHost()
|
||||
{
|
||||
char *p;
|
||||
|
||||
if (gethostname(VarShortHost, sizeof(VarShortHost))) {
|
||||
if (gethostname(VarShortHost, sizeof VarShortHost)) {
|
||||
LogPrintf(LogERROR, "GetShortHost: gethostbyname: %s\n", strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: filter.c,v 1.19 1997/11/22 03:37:30 brian Exp $
|
||||
* $Id: filter.c,v 1.20 1997/12/13 02:37:22 brian Exp $
|
||||
*
|
||||
* TODO: Shoud send ICMP error message when we discard packets.
|
||||
*/
|
||||
@ -301,7 +301,7 @@ Parse(int argc, char const *const *argv, struct filterent * ofp)
|
||||
argv++;
|
||||
|
||||
proto = P_NONE;
|
||||
memset(&filterdata, '\0', sizeof(filterdata));
|
||||
memset(&filterdata, '\0', sizeof filterdata);
|
||||
|
||||
if (!strcmp(*argv, "permit")) {
|
||||
action = A_PERMIT;
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: fsm.c,v 1.23 1997/12/03 10:23:46 brian Exp $
|
||||
* $Id: fsm.c,v 1.24 1997/12/13 02:37:23 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o Refer loglevel for log output
|
||||
@ -345,7 +345,7 @@ FsmRecvConfigReq(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
|
||||
int ackaction = 0;
|
||||
|
||||
plen = plength(bp);
|
||||
flen = ntohs(lhp->length) - sizeof(*lhp);
|
||||
flen = ntohs(lhp->length) - sizeof *lhp;
|
||||
if (plen < flen) {
|
||||
LogPrintf(LogERROR, "FsmRecvConfigReq: plen (%d) < flen (%d)\n",
|
||||
plen, flen);
|
||||
@ -464,7 +464,7 @@ FsmRecvConfigNak(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
|
||||
int plen, flen;
|
||||
|
||||
plen = plength(bp);
|
||||
flen = ntohs(lhp->length) - sizeof(*lhp);
|
||||
flen = ntohs(lhp->length) - sizeof *lhp;
|
||||
if (plen < flen) {
|
||||
pfree(bp);
|
||||
return;
|
||||
@ -574,7 +574,7 @@ FsmRecvConfigRej(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
|
||||
int plen, flen;
|
||||
|
||||
plen = plength(bp);
|
||||
flen = ntohs(lhp->length) - sizeof(*lhp);
|
||||
flen = ntohs(lhp->length) - sizeof *lhp;
|
||||
if (plen < flen) {
|
||||
pfree(bp);
|
||||
return;
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: hdlc.c,v 1.23 1997/12/03 10:23:47 brian Exp $
|
||||
* $Id: hdlc.c,v 1.24 1997/12/04 18:49:26 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -355,7 +355,7 @@ static struct {
|
||||
{ 0xc481, 0xc481, "Proprietary Node ID Authentication Protocol" }
|
||||
};
|
||||
|
||||
#define NPROTOCOLS (sizeof(protocols)/sizeof(protocols[0]))
|
||||
#define NPROTOCOLS (sizeof protocols/sizeof protocols[0])
|
||||
|
||||
static const char *
|
||||
Protocol2Nam(u_short proto)
|
||||
@ -477,7 +477,7 @@ HdlcErrorCheck()
|
||||
struct hdlcstat *hp = &HdlcStat;
|
||||
struct hdlcstat *op = &laststat;
|
||||
|
||||
if (memcmp(hp, op, sizeof(laststat))) {
|
||||
if (memcmp(hp, op, sizeof laststat)) {
|
||||
LogPrintf(LogPHASE, "HDLC errors -> FCS: %u ADDR: %u COMD: %u PROTO: %u\n",
|
||||
hp->badfcs - op->badfcs, hp->badaddr - op->badaddr,
|
||||
hp->badcommand - op->badcommand, hp->unknownproto - op->unknownproto);
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: ip.c,v 1.31 1997/11/18 14:52:04 brian Exp $
|
||||
* $Id: ip.c,v 1.32 1997/11/22 03:37:33 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o Return ICMP message for filterd packet
|
||||
@ -411,7 +411,7 @@ IpInput(struct mbuf * bp)
|
||||
IpcpAddInOctets(nb);
|
||||
|
||||
nb = ntohs(((struct ip *) tun.data)->ip_len);
|
||||
nb += sizeof(tun)-sizeof(tun.data);
|
||||
nb += sizeof tun - sizeof tun.data;
|
||||
nw = write(tun_out, &tun, nb);
|
||||
if (nw != nb)
|
||||
if (nw == -1)
|
||||
@ -424,8 +424,9 @@ IpInput(struct mbuf * bp)
|
||||
while ((fptr = VarPacketAliasGetFragment(tun.data)) != NULL) {
|
||||
VarPacketAliasFragmentIn(tun.data, fptr);
|
||||
nb = ntohs(((struct ip *) fptr)->ip_len);
|
||||
frag = (struct tun_data *)((char *)fptr-sizeof(tun)+sizeof(tun.data));
|
||||
nb += sizeof(tun)-sizeof(tun.data);
|
||||
frag = (struct tun_data *)
|
||||
((char *)fptr - sizeof tun + sizeof tun.data);
|
||||
nb += sizeof tun - sizeof tun.data;
|
||||
nw = write(tun_out, frag, nb);
|
||||
if (nw != nb)
|
||||
if (nw == -1)
|
||||
@ -438,13 +439,13 @@ IpInput(struct mbuf * bp)
|
||||
}
|
||||
} else if (iresult == PKT_ALIAS_UNRESOLVED_FRAGMENT) {
|
||||
nb = ntohs(((struct ip *) tun.data)->ip_len);
|
||||
nb += sizeof(tun)-sizeof(tun.data);
|
||||
nb += sizeof tun - sizeof tun.data;
|
||||
frag = (struct tun_data *)malloc(nb);
|
||||
if (frag == NULL)
|
||||
LogPrintf(LogALERT, "IpInput: Cannot allocate memory for fragment\n");
|
||||
else {
|
||||
tun_fill_header(*frag, AF_INET);
|
||||
memcpy(frag->data, tun.data, nb-sizeof(tun)+sizeof(tun.data));
|
||||
memcpy(frag->data, tun.data, nb - sizeof tun + sizeof tun.data);
|
||||
VarPacketAliasSaveFragment(frag->data);
|
||||
}
|
||||
}
|
||||
@ -456,7 +457,7 @@ IpInput(struct mbuf * bp)
|
||||
return;
|
||||
}
|
||||
IpcpAddInOctets(nb);
|
||||
nb += sizeof(tun)-sizeof(tun.data);
|
||||
nb += sizeof tun - sizeof tun.data;
|
||||
nw = write(tun_out, &tun, nb);
|
||||
if (nw != nb)
|
||||
if (nw == -1)
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: ipcp.c,v 1.43 1997/12/19 04:49:53 brian Exp $
|
||||
* $Id: ipcp.c,v 1.44 1997/12/24 09:28:11 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o More RFC1772 backwoard compatibility
|
||||
@ -110,7 +110,7 @@ static const char *cftypes[] = {
|
||||
"IPADDR", /* 3: IP-Address */
|
||||
};
|
||||
|
||||
#define NCFTYPES (sizeof(cftypes)/sizeof(char *))
|
||||
#define NCFTYPES (sizeof cftypes/sizeof cftypes[0])
|
||||
|
||||
static const char *cftypes128[] = {
|
||||
/* Check out the latest ``Assigned numbers'' rfc (rfc1700.txt) */
|
||||
@ -121,7 +121,7 @@ static const char *cftypes128[] = {
|
||||
"SECNBNS", /* 132: Secondary NBNS Server Address */
|
||||
};
|
||||
|
||||
#define NCFTYPES128 (sizeof(cftypes128)/sizeof(char *))
|
||||
#define NCFTYPES128 (sizeof cftypes128/sizeof cftypes128[0])
|
||||
|
||||
struct pppThroughput throughput;
|
||||
|
||||
@ -172,11 +172,11 @@ IpcpDefAddress()
|
||||
struct hostent *hp;
|
||||
char name[200];
|
||||
|
||||
memset(&DefMyAddress, '\0', sizeof(DefMyAddress));
|
||||
memset(&DefHisAddress, '\0', sizeof(DefHisAddress));
|
||||
memset(&DefMyAddress, '\0', sizeof DefMyAddress);
|
||||
memset(&DefHisAddress, '\0', sizeof DefHisAddress);
|
||||
TriggerAddress.s_addr = 0;
|
||||
HaveTriggerAddress = 0;
|
||||
if (gethostname(name, sizeof(name)) == 0) {
|
||||
if (gethostname(name, sizeof name) == 0) {
|
||||
hp = gethostbyname(name);
|
||||
if (hp && hp->h_addrtype == AF_INET) {
|
||||
memcpy(&DefMyAddress.ipaddr.s_addr, hp->h_addr, hp->h_length);
|
||||
@ -190,7 +190,7 @@ IpcpInit()
|
||||
if (iplist_isvalid(&DefHisChoice))
|
||||
iplist_setrandpos(&DefHisChoice);
|
||||
FsmInit(&IpcpFsm);
|
||||
memset(&IpcpInfo, '\0', sizeof(struct ipcpstate));
|
||||
memset(&IpcpInfo, '\0', sizeof IpcpInfo);
|
||||
if ((mode & MODE_DEDICATED) && !GetLabel()) {
|
||||
IpcpInfo.want_ipaddr.s_addr = IpcpInfo.his_ipaddr.s_addr = 0;
|
||||
} else {
|
||||
@ -302,7 +302,7 @@ IpcpLayerUp(struct fsm * fp)
|
||||
|
||||
Prompt();
|
||||
LogPrintf(LogIPCP, "IpcpLayerUp(%d).\n", fp->state);
|
||||
snprintf(tbuff, sizeof(tbuff), "myaddr = %s ",
|
||||
snprintf(tbuff, sizeof tbuff, "myaddr = %s ",
|
||||
inet_ntoa(IpcpInfo.want_ipaddr));
|
||||
|
||||
if (IpcpInfo.his_compproto >> 16 == PROTO_VJCOMP)
|
||||
@ -367,11 +367,11 @@ IpcpDecodeConfig(u_char * cp, int plen, int mode_type)
|
||||
type = *cp;
|
||||
length = cp[1];
|
||||
if (type < NCFTYPES)
|
||||
snprintf(tbuff, sizeof(tbuff), " %s[%d] ", cftypes[type], length);
|
||||
snprintf(tbuff, sizeof tbuff, " %s[%d] ", cftypes[type], length);
|
||||
else if (type > 128 && type < 128 + NCFTYPES128)
|
||||
snprintf(tbuff, sizeof(tbuff), " %s[%d] ", cftypes128[type-128], length);
|
||||
snprintf(tbuff, sizeof tbuff, " %s[%d] ", cftypes128[type-128], length);
|
||||
else
|
||||
snprintf(tbuff, sizeof(tbuff), " <%d>[%d] ", type, length);
|
||||
snprintf(tbuff, sizeof tbuff, " <%d>[%d] ", type, length);
|
||||
|
||||
switch (type) {
|
||||
case TY_IPADDR: /* RFC1332 */
|
||||
@ -415,7 +415,7 @@ IpcpDecodeConfig(u_char * cp, int plen, int mode_type)
|
||||
case MODE_NAK:
|
||||
if (AcceptableAddr(&DefMyAddress, ipaddr)) {
|
||||
/* Use address suggested by peer */
|
||||
snprintf(tbuff2, sizeof(tbuff2), "%s changing address: %s ", tbuff,
|
||||
snprintf(tbuff2, sizeof tbuff2, "%s changing address: %s ", tbuff,
|
||||
inet_ntoa(IpcpInfo.want_ipaddr));
|
||||
LogPrintf(LogIPCP, "%s --> %s\n", tbuff2, inet_ntoa(ipaddr));
|
||||
IpcpInfo.want_ipaddr = ipaddr;
|
||||
@ -468,7 +468,7 @@ IpcpDecodeConfig(u_char * cp, int plen, int mode_type)
|
||||
pcomp->proto = htons(PROTO_VJCOMP);
|
||||
pcomp->slots = MAX_STATES - 1;
|
||||
pcomp->compcid = 0;
|
||||
memcpy(nakp+2, &pcomp, sizeof(pcomp));
|
||||
memcpy(nakp+2, &pcomp, sizeof pcomp);
|
||||
nakp += length;
|
||||
}
|
||||
break;
|
||||
@ -494,7 +494,7 @@ IpcpDecodeConfig(u_char * cp, int plen, int mode_type)
|
||||
ipaddr.s_addr = *lp;
|
||||
lp = (u_long *) (cp + 6);
|
||||
dstipaddr.s_addr = *lp;
|
||||
snprintf(tbuff2, sizeof(tbuff2), "%s %s,", tbuff, inet_ntoa(ipaddr));
|
||||
snprintf(tbuff2, sizeof tbuff2, "%s %s,", tbuff, inet_ntoa(ipaddr));
|
||||
LogPrintf(LogIPCP, "%s %s\n", tbuff2, inet_ntoa(dstipaddr));
|
||||
|
||||
switch (mode_type) {
|
||||
@ -505,7 +505,7 @@ IpcpDecodeConfig(u_char * cp, int plen, int mode_type)
|
||||
ackp += length;
|
||||
break;
|
||||
case MODE_NAK:
|
||||
snprintf(tbuff2, sizeof(tbuff2), "%s changing address: %s", tbuff,
|
||||
snprintf(tbuff2, sizeof tbuff2, "%s changing address: %s", tbuff,
|
||||
inet_ntoa(IpcpInfo.want_ipaddr));
|
||||
LogPrintf(LogIPCP, "%s --> %s\n", tbuff2, inet_ntoa(ipaddr));
|
||||
IpcpInfo.want_ipaddr = ipaddr;
|
||||
|
@ -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 12:11:06 brian Exp $
|
||||
* $Id: iplist.c,v 1.3 1997/12/23 22:38:54 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -149,8 +149,8 @@ iplist_next(struct iplist *list)
|
||||
int
|
||||
iplist_setsrc(struct iplist *list, const char *src)
|
||||
{
|
||||
strncpy(list->src, src, sizeof(list->src)-1);
|
||||
list->src[sizeof(list->src)-1] = '\0';
|
||||
strncpy(list->src, src, sizeof list->src - 1);
|
||||
list->src[sizeof list->src - 1] = '\0';
|
||||
list->cur.srcptr = list->src;
|
||||
do {
|
||||
if (iplist_nextrange(list))
|
||||
@ -211,7 +211,7 @@ iplist_ip2pos(struct iplist *list, struct in_addr ip)
|
||||
int f, result;
|
||||
|
||||
result = -1;
|
||||
memcpy(&cur, &list->cur, sizeof(cur));
|
||||
memcpy(&cur, &list->cur, sizeof cur);
|
||||
|
||||
for (iplist_first(list), f = 0; f < list->nItems; f++)
|
||||
if (iplist_next(list).s_addr == ip.s_addr) {
|
||||
@ -219,6 +219,6 @@ iplist_ip2pos(struct iplist *list, struct in_addr ip)
|
||||
break;
|
||||
}
|
||||
|
||||
memcpy(&list->cur, &cur, sizeof(list->cur));
|
||||
memcpy(&list->cur, &cur, sizeof list->cur);
|
||||
return result;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: lcp.c,v 1.49 1997/12/03 10:23:49 brian Exp $
|
||||
* $Id: lcp.c,v 1.50 1997/12/07 23:55:27 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o Validate magic number received from peer.
|
||||
@ -117,7 +117,7 @@ static const char *cftypes[] = {
|
||||
"LDBACP", /* 23: Link Discriminator for BACP */
|
||||
};
|
||||
|
||||
#define NCFTYPES (sizeof(cftypes)/sizeof(char *))
|
||||
#define NCFTYPES (sizeof cftypes/sizeof cftypes[0])
|
||||
|
||||
struct fsm LcpFsm = {
|
||||
"LCP", /* Name of protocol */
|
||||
@ -791,7 +791,7 @@ LcpDecodeConfig(u_char *cp, int plen, int mode_type)
|
||||
break;
|
||||
|
||||
default:
|
||||
sz = (sizeof(desc)-2)/2;
|
||||
sz = (sizeof desc - 2) / 2;
|
||||
if (sz > length - 2)
|
||||
sz = length - 2;
|
||||
pos = 0;
|
||||
@ -803,8 +803,8 @@ LcpDecodeConfig(u_char *cp, int plen, int mode_type)
|
||||
|
||||
if (mode_type == MODE_REQ) {
|
||||
reqreject:
|
||||
if (length > sizeof(RejBuff) - (rejp - RejBuff)) {
|
||||
length = sizeof(RejBuff) - (rejp - RejBuff);
|
||||
if (length > sizeof RejBuff - (rejp - RejBuff)) {
|
||||
length = sizeof RejBuff - (rejp - RejBuff);
|
||||
LogPrintf(LogLCP, "Can't REJ length %d - trunating to %d\n",
|
||||
cp[1], length);
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: log.c,v 1.23 1997/12/21 12:11:07 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -237,7 +237,7 @@ LogDumpBuff(int lev, const char *hdr, const u_char * ptr, int n)
|
||||
LogPrintf(lev, "%s\n", hdr);
|
||||
while (n > 0) {
|
||||
b = buf;
|
||||
for (b = buf; b != buf + sizeof(buf) - 2 && n--; b += 3)
|
||||
for (b = buf; b != buf + sizeof buf - 2 && n--; b += 3)
|
||||
sprintf(b, " %02x", (int) *ptr++);
|
||||
strcpy(b, "\n");
|
||||
LogPrintf(lev, buf);
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: main.c,v 1.109 1997/12/17 21:21:56 brian Exp $
|
||||
* $Id: main.c,v 1.110 1997/12/22 02:28:18 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o Add commands for traffic summary, version display, etc.
|
||||
@ -278,7 +278,7 @@ ex_desc(int ex)
|
||||
"reboot", "errdead", "hangup", "term", "nodial", "nologin"
|
||||
};
|
||||
|
||||
if (ex >= 0 && ex < sizeof(desc) / sizeof(*desc))
|
||||
if (ex >= 0 && ex < sizeof desc / sizeof *desc)
|
||||
return desc[ex];
|
||||
snprintf(num, sizeof num, "%d", ex);
|
||||
return num;
|
||||
@ -545,7 +545,7 @@ main(int argc, char **argv)
|
||||
TtyCommandMode(1);
|
||||
}
|
||||
|
||||
snprintf(pid_filename, sizeof(pid_filename), "%stun%d.pid",
|
||||
snprintf(pid_filename, sizeof pid_filename, "%stun%d.pid",
|
||||
_PATH_VARRUN, tunno);
|
||||
lockfile = ID0fopen(pid_filename, "w");
|
||||
if (lockfile != NULL) {
|
||||
@ -616,11 +616,13 @@ ReadTty(void)
|
||||
LogPrintf(LogDEBUG, "termode = %d, netfd = %d, mode = %d\n",
|
||||
TermMode, netfd, mode);
|
||||
if (!TermMode) {
|
||||
n = read(netfd, linebuff, sizeof(linebuff) - 1);
|
||||
n = read(netfd, linebuff, sizeof linebuff - 1);
|
||||
if (n > 0) {
|
||||
aft_cmd = 1;
|
||||
if (linebuff[n-1] == '\n')
|
||||
linebuff[--n] = '\0';
|
||||
else
|
||||
linebuff[n] = '\0';
|
||||
if (n)
|
||||
DecodeCommand(linebuff, n, IsInteractive(0) ? NULL : "Client");
|
||||
Prompt();
|
||||
@ -1021,7 +1023,7 @@ DoLoop(void)
|
||||
/* something to read from modem */
|
||||
if (LcpFsm.state <= ST_CLOSED)
|
||||
nointr_usleep(10000);
|
||||
n = read(modem, rbuff, sizeof(rbuff));
|
||||
n = read(modem, rbuff, sizeof rbuff);
|
||||
if ((mode & MODE_DIRECT) && n <= 0) {
|
||||
DownConnection();
|
||||
} else
|
||||
@ -1052,12 +1054,12 @@ DoLoop(void)
|
||||
}
|
||||
if (tun_in >= 0 && FD_ISSET(tun_in, &rfds)) { /* something to read
|
||||
* from tun */
|
||||
n = read(tun_in, &tun, sizeof(tun));
|
||||
n = read(tun_in, &tun, sizeof tun);
|
||||
if (n < 0) {
|
||||
LogPrintf(LogERROR, "read from tun: %s\n", strerror(errno));
|
||||
continue;
|
||||
}
|
||||
n -= sizeof(tun)-sizeof(tun.data);
|
||||
n -= sizeof tun - sizeof tun.data;
|
||||
if (n <= 0) {
|
||||
LogPrintf(LogERROR, "read from tun: Only %d bytes read\n", n);
|
||||
continue;
|
||||
|
@ -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.69 1997/12/21 03:16:12 brian Exp $
|
||||
* $Id: modem.c,v 1.70 1997/12/23 22:38:55 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -364,7 +364,7 @@ OpenConnection(char *host, char *port)
|
||||
if (sock < 0) {
|
||||
return (sock);
|
||||
}
|
||||
if (connect(sock, (struct sockaddr *) & dest, sizeof(dest)) < 0) {
|
||||
if (connect(sock, (struct sockaddr *)&dest, sizeof dest) < 0) {
|
||||
LogPrintf(LogWARN, "OpenConnection: connection failed.\n");
|
||||
return (-1);
|
||||
}
|
||||
@ -434,7 +434,7 @@ OpenModem()
|
||||
int oldflag;
|
||||
char *host, *port;
|
||||
char *cp;
|
||||
char tmpDeviceList[sizeof(VarDeviceList)];
|
||||
char tmpDeviceList[sizeof VarDeviceList];
|
||||
char *tmpDevice;
|
||||
|
||||
if (modem >= 0)
|
||||
@ -466,13 +466,13 @@ OpenModem()
|
||||
return modem = 0;
|
||||
}
|
||||
} else {
|
||||
strncpy(tmpDeviceList, VarDeviceList, sizeof(tmpDeviceList)-1);
|
||||
tmpDeviceList[sizeof(tmpDeviceList)-1] = '\0';
|
||||
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)-1);
|
||||
VarDevice[sizeof(VarDevice)-1]= '\0';
|
||||
strncpy(VarDevice, tmpDevice, sizeof VarDevice - 1);
|
||||
VarDevice[sizeof VarDevice - 1]= '\0';
|
||||
VarBaseDevice = strrchr(VarDevice, '/');
|
||||
VarBaseDevice = VarBaseDevice ? VarBaseDevice + 1 : "";
|
||||
|
||||
@ -700,8 +700,8 @@ HangupModem(int flag)
|
||||
if (modem >= 0) {
|
||||
char ScriptBuffer[SCRIPT_LEN];
|
||||
|
||||
strncpy(ScriptBuffer, VarHangupScript, sizeof(ScriptBuffer)-1);
|
||||
ScriptBuffer[sizeof(ScriptBuffer) - 1] = '\0';
|
||||
strncpy(ScriptBuffer, VarHangupScript, sizeof ScriptBuffer - 1);
|
||||
ScriptBuffer[sizeof ScriptBuffer - 1] = '\0';
|
||||
LogPrintf(LogDEBUG, "HangupModem: Script: %s\n", ScriptBuffer);
|
||||
if (flag || !(mode & MODE_DEDICATED)) {
|
||||
DoChat(ScriptBuffer);
|
||||
@ -728,8 +728,8 @@ CloseLogicalModem(void)
|
||||
ClosePhysicalModem();
|
||||
if (Utmp) {
|
||||
struct utmp ut;
|
||||
strncpy(ut.ut_line, VarBaseDevice, sizeof(ut.ut_line)-1);
|
||||
ut.ut_line[sizeof(ut.ut_line)-1] = '\0';
|
||||
strncpy(ut.ut_line, VarBaseDevice, sizeof ut.ut_line - 1);
|
||||
ut.ut_line[sizeof ut.ut_line - 1] = '\0';
|
||||
if (logout(ut.ut_line))
|
||||
logwtmp(ut.ut_line, "", "");
|
||||
else
|
||||
@ -847,12 +847,12 @@ DialModem()
|
||||
char ScriptBuffer[SCRIPT_LEN];
|
||||
int excode;
|
||||
|
||||
strncpy(ScriptBuffer, VarDialScript, sizeof(ScriptBuffer) - 1);
|
||||
ScriptBuffer[sizeof(ScriptBuffer) - 1] = '\0';
|
||||
strncpy(ScriptBuffer, VarDialScript, sizeof ScriptBuffer - 1);
|
||||
ScriptBuffer[sizeof ScriptBuffer - 1] = '\0';
|
||||
if ((excode = DoChat(ScriptBuffer)) > 0) {
|
||||
if (VarTerm)
|
||||
fprintf(VarTerm, "dial OK!\n");
|
||||
strncpy(ScriptBuffer, VarLoginScript, sizeof(ScriptBuffer) - 1);
|
||||
strncpy(ScriptBuffer, VarLoginScript, sizeof ScriptBuffer - 1);
|
||||
if ((excode = DoChat(ScriptBuffer)) > 0) {
|
||||
VarAltPhone = NULL;
|
||||
if (VarTerm)
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: os.c,v 1.36 1997/12/03 10:23:51 brian Exp $
|
||||
* $Id: os.c,v 1.37 1997/12/13 02:37:27 brian Exp $
|
||||
*
|
||||
*/
|
||||
#include <sys/param.h>
|
||||
@ -90,9 +90,9 @@ SetIpDevice(struct in_addr myaddr,
|
||||
close(s);
|
||||
return (0);
|
||||
}
|
||||
memset(&ifra.ifra_addr, '\0', sizeof(ifra.ifra_addr));
|
||||
memset(&ifra.ifra_broadaddr, '\0', sizeof(ifra.ifra_addr));
|
||||
memset(&ifra.ifra_mask, '\0', sizeof(ifra.ifra_addr));
|
||||
memset(&ifra.ifra_addr, '\0', sizeof ifra.ifra_addr);
|
||||
memset(&ifra.ifra_broadaddr, '\0', sizeof ifra.ifra_broadaddr);
|
||||
memset(&ifra.ifra_mask, '\0', sizeof ifra.ifra_mask);
|
||||
if (ID0ioctl(s, SIOCDIFADDR, &ifra) < 0) {
|
||||
LogPrintf(LogERROR, "SetIpDevice: ioctl(SIOCDIFADDR): %s\n",
|
||||
strerror(errno));
|
||||
@ -111,9 +111,9 @@ SetIpDevice(struct in_addr myaddr,
|
||||
* If different address has been set, then delete it first.
|
||||
*/
|
||||
if (oldmine.s_addr || oldhis.s_addr) {
|
||||
memset(&ifra.ifra_addr, '\0', sizeof(ifra.ifra_addr));
|
||||
memset(&ifra.ifra_broadaddr, '\0', sizeof(ifra.ifra_addr));
|
||||
memset(&ifra.ifra_mask, '\0', sizeof(ifra.ifra_addr));
|
||||
memset(&ifra.ifra_addr, '\0', sizeof ifra.ifra_addr);
|
||||
memset(&ifra.ifra_broadaddr, '\0', sizeof ifra.ifra_broadaddr);
|
||||
memset(&ifra.ifra_mask, '\0', sizeof ifra.ifra_mask);
|
||||
if (ID0ioctl(s, SIOCDIFADDR, &ifra) < 0) {
|
||||
LogPrintf(LogERROR, "SetIpDevice: ioctl(SIOCDIFADDR): %s\n",
|
||||
strerror(errno));
|
||||
@ -126,13 +126,13 @@ SetIpDevice(struct in_addr myaddr,
|
||||
sock_in = (struct sockaddr_in *) & (ifra.ifra_addr);
|
||||
sock_in->sin_family = AF_INET;
|
||||
sock_in->sin_addr = myaddr;
|
||||
sock_in->sin_len = sizeof(*sock_in);
|
||||
sock_in->sin_len = sizeof *sock_in;
|
||||
|
||||
/* Set destination address */
|
||||
sock_in = (struct sockaddr_in *) & (ifra.ifra_broadaddr);
|
||||
sock_in->sin_family = AF_INET;
|
||||
sock_in->sin_addr = hisaddr;
|
||||
sock_in->sin_len = sizeof(*sock_in);
|
||||
sock_in->sin_len = sizeof *sock_in;
|
||||
|
||||
addr = ntohl(myaddr.s_addr);
|
||||
if (IN_CLASSA(addr))
|
||||
@ -151,7 +151,7 @@ SetIpDevice(struct in_addr myaddr,
|
||||
sock_in = (struct sockaddr_in *) & (ifra.ifra_mask);
|
||||
sock_in->sin_family = AF_INET;
|
||||
sock_in->sin_addr.s_addr = htonl(mask);
|
||||
sock_in->sin_len = sizeof(*sock_in);
|
||||
sock_in->sin_len = sizeof *sock_in;
|
||||
|
||||
if (ID0ioctl(s, SIOCAIFADDR, &ifra) < 0) {
|
||||
if (how != SET_TRY)
|
||||
@ -299,7 +299,7 @@ OpenTunnel(int *ptun)
|
||||
|
||||
err = ENOENT;
|
||||
for (unit = 0; unit <= MAX_TUN; unit++) {
|
||||
snprintf(devname, sizeof(devname), "/dev/tun%d", unit);
|
||||
snprintf(devname, sizeof devname, "/dev/tun%d", unit);
|
||||
tun_out = ID0open(devname, O_RDWR);
|
||||
if (tun_out >= 0)
|
||||
break;
|
||||
@ -327,8 +327,8 @@ OpenTunnel(int *ptun)
|
||||
*/
|
||||
strncpy(ifname, devname + 5, IFNAMSIZ - 1);
|
||||
|
||||
memset(&ifra, '\0', sizeof(ifra));
|
||||
memset(&ifrq, '\0', sizeof(ifrq));
|
||||
memset(&ifra, '\0', sizeof ifra);
|
||||
memset(&ifrq, '\0', sizeof ifrq);
|
||||
|
||||
strncpy(ifrq.ifr_name, ifname, IFNAMSIZ - 1);
|
||||
strncpy(ifra.ifra_name, ifname, IFNAMSIZ - 1);
|
||||
|
@ -18,7 +18,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: pap.c,v 1.18 1997/10/26 01:03:28 brian Exp $
|
||||
* $Id: pap.c,v 1.19 1997/11/22 03:37:43 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -171,10 +171,10 @@ PapInput(struct mbuf * bp)
|
||||
VarBaseDevice);
|
||||
else {
|
||||
struct utmp ut;
|
||||
memset(&ut, 0, sizeof(ut));
|
||||
memset(&ut, 0, sizeof ut);
|
||||
time(&ut.ut_time);
|
||||
strncpy(ut.ut_name, cp+1, sizeof(ut.ut_name)-1);
|
||||
strncpy(ut.ut_line, VarBaseDevice, sizeof(ut.ut_line)-1);
|
||||
strncpy(ut.ut_name, cp+1, sizeof ut.ut_name - 1);
|
||||
strncpy(ut.ut_line, VarBaseDevice, sizeof ut.ut_line - 1);
|
||||
if (logout(ut.ut_line))
|
||||
logwtmp(ut.ut_line, "", "");
|
||||
login(&ut);
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: route.c,v 1.33 1997/12/17 00:19:25 brian Exp $
|
||||
* $Id: route.c,v 1.34 1997/12/17 21:22:05 brian Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -81,7 +81,7 @@ OsSetRoute(int cmd,
|
||||
LogPrintf(LogERROR, "OsSetRoute: socket(): %s\n", strerror(errno));
|
||||
return;
|
||||
}
|
||||
memset(&rtmes, '\0', sizeof(rtmes));
|
||||
memset(&rtmes, '\0', sizeof rtmes);
|
||||
rtmes.m_rtm.rtm_version = RTM_VERSION;
|
||||
rtmes.m_rtm.rtm_type = cmd;
|
||||
rtmes.m_rtm.rtm_addrs = RTA_DST;
|
||||
@ -89,7 +89,7 @@ OsSetRoute(int cmd,
|
||||
rtmes.m_rtm.rtm_pid = getpid();
|
||||
rtmes.m_rtm.rtm_flags = RTF_UP | RTF_GATEWAY | RTF_STATIC;
|
||||
|
||||
memset(&rtdata, '\0', sizeof(rtdata));
|
||||
memset(&rtdata, '\0', sizeof rtdata);
|
||||
rtdata.sin_len = 16;
|
||||
rtdata.sin_family = AF_INET;
|
||||
rtdata.sin_port = 0;
|
||||
@ -107,14 +107,14 @@ OsSetRoute(int cmd,
|
||||
|
||||
iname = Index2Nam(IfIndex);
|
||||
ilen = strlen(iname);
|
||||
dl.sdl_len = sizeof(dl)-sizeof(dl.sdl_data)+ilen;
|
||||
dl.sdl_len = sizeof dl - sizeof dl.sdl_data + ilen;
|
||||
dl.sdl_family = AF_LINK;
|
||||
dl.sdl_index = IfIndex;
|
||||
dl.sdl_type = 0;
|
||||
dl.sdl_nlen = ilen;
|
||||
dl.sdl_alen = 0;
|
||||
dl.sdl_slen = 0;
|
||||
strcpy(dl.sdl_data, iname);
|
||||
strncpy(dl.sdl_data, iname, sizeof dl.sdl_data);
|
||||
|
||||
memcpy(cp, &dl, dl.sdl_len);
|
||||
cp += dl.sdl_len;
|
||||
@ -219,7 +219,7 @@ p_sockaddr(struct sockaddr *phost, struct sockaddr *pmask, int width)
|
||||
snprintf(buf, sizeof buf, "%.*s", dl->sdl_nlen, dl->sdl_data);
|
||||
else if (dl->sdl_alen)
|
||||
if (dl->sdl_type == IFT_ETHER)
|
||||
if (dl->sdl_alen < sizeof(buf)/3) {
|
||||
if (dl->sdl_alen < sizeof buf / 3) {
|
||||
int f;
|
||||
u_char *MAC;
|
||||
|
||||
@ -289,8 +289,8 @@ p_flags(u_long f, int max)
|
||||
char name[33], *flags;
|
||||
register struct bits *p = bits;
|
||||
|
||||
if (max > sizeof(name)-1)
|
||||
max = sizeof(name)-1;
|
||||
if (max > sizeof name - 1)
|
||||
max = sizeof name - 1;
|
||||
|
||||
for (flags = name; p->b_mask && flags - name < max; p++)
|
||||
if (p->b_mask & f)
|
||||
@ -334,10 +334,10 @@ Index2Nam(int idx)
|
||||
for (ptr = buf; ptr < end; ptr += ifm->ifm_msglen) {
|
||||
ifm = (struct if_msghdr *)ptr;
|
||||
dl = (struct sockaddr_dl *)(ifm + 1);
|
||||
if (ifm->ifm_index > 0 && ifm->ifm_index <= sizeof(ifs)/sizeof(ifs[0])
|
||||
if (ifm->ifm_index > 0 && ifm->ifm_index <= sizeof ifs/sizeof ifs[0]
|
||||
&& ifs[ifm->ifm_index-1][0] == '\0') {
|
||||
if ((len = dl->sdl_nlen) > sizeof(ifs[0])-1)
|
||||
len = sizeof(ifs[0])-1;
|
||||
if ((len = dl->sdl_nlen) > sizeof ifs[0] - 1)
|
||||
len = sizeof ifs[0] - 1;
|
||||
strncpy(ifs[ifm->ifm_index-1], dl->sdl_data, len);
|
||||
ifs[ifm->ifm_index-1][len] = '\0';
|
||||
if (len && nifs < ifm->ifm_index)
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: server.c,v 1.14 1997/12/21 12:11:08 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -87,7 +87,7 @@ ServerLocalOpen(const char *name, mode_t mask)
|
||||
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &s, sizeof s);
|
||||
if (mask != (mode_t)-1)
|
||||
mask = umask(mask);
|
||||
if (bind(s, (struct sockaddr *) & ifsun, sizeof(ifsun)) < 0) {
|
||||
if (bind(s, (struct sockaddr *)&ifsun, sizeof ifsun) < 0) {
|
||||
if (mask != (mode_t)-1)
|
||||
umask(mask);
|
||||
LogPrintf(LogERROR, "Local: bind: %s\n", strerror(errno));
|
||||
@ -138,7 +138,7 @@ ServerTcpOpen(int port)
|
||||
ifsin.sin_addr.s_addr = INADDR_ANY;
|
||||
ifsin.sin_port = htons(port);
|
||||
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &s, sizeof s);
|
||||
if (bind(s, (struct sockaddr *) & ifsin, sizeof(ifsin)) < 0) {
|
||||
if (bind(s, (struct sockaddr *)&ifsin, sizeof ifsin) < 0) {
|
||||
LogPrintf(LogERROR, "Tcp: bind: %s\n", strerror(errno));
|
||||
if (errno == EADDRINUSE && VarTerm)
|
||||
fprintf(VarTerm, "Wait for a while, then try again.\n");
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: slcompress.c,v 1.13 1997/10/26 01:03:44 brian Exp $
|
||||
* $Id: slcompress.c,v 1.14 1997/11/22 03:37:50 brian Exp $
|
||||
*
|
||||
* Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
|
||||
* - Initial distribution.
|
||||
@ -59,7 +59,7 @@ sl_compress_init(struct slcompress * comp, int max_state)
|
||||
register u_int i;
|
||||
register struct cstate *tstate = comp->tstate;
|
||||
|
||||
memset(comp, '\0', sizeof(*comp));
|
||||
memset(comp, '\0', sizeof *comp);
|
||||
for (i = max_state; i > 0; --i) {
|
||||
tstate[i].cs_id = i;
|
||||
tstate[i].cs_next = &tstate[i - 1];
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: systems.c,v 1.32 1997/12/21 02:11:48 brian Exp $
|
||||
* $Id: systems.c,v 1.33 1997/12/21 03:41:23 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -250,7 +250,7 @@ ReadSystem(const char *name, const char *file, int doexec)
|
||||
LogPrintf(LogDEBUG, "ReadSystem: Checking %s (%s).\n", name, filename);
|
||||
|
||||
linenum = 0;
|
||||
while (fgets(line, sizeof(line), fp)) {
|
||||
while (fgets(line, sizeof line, fp)) {
|
||||
linenum++;
|
||||
cp = line;
|
||||
switch (*cp) {
|
||||
@ -283,7 +283,7 @@ ReadSystem(const char *name, const char *file, int doexec)
|
||||
break;
|
||||
}
|
||||
} else if (strcmp(cp, name) == 0) {
|
||||
while (fgets(line, sizeof(line), fp)) {
|
||||
while (fgets(line, sizeof line, fp)) {
|
||||
cp = line;
|
||||
if (issep(*cp)) {
|
||||
n = strspn(cp, " \t");
|
||||
|
Loading…
Reference in New Issue
Block a user