Back out strcpy() -> strncpy() changes. According to bruce, they are unneeded.

This commit is contained in:
Philippe Charnier 1997-10-29 07:32:30 +00:00
parent dd63f75f44
commit 0b778a4e7f
8 changed files with 46 additions and 112 deletions

View File

@ -36,7 +36,7 @@
static char sccsid[] = "@(#)acksend.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
"$Id$";
"$Id: acksend.c,v 1.2 1997/10/22 06:19:48 charnier Exp $";
#endif /* not lint */
#include "globals.h"
@ -56,8 +56,7 @@ xmit(type, seq, addr)
msg.tsp_type = type;
msg.tsp_seq = seq;
msg.tsp_vers = TSPVERSION;
(void)strncpy(msg.tsp_name, hostname, sizeof msg.tsp_name-1);
msg.tsp_name[sizeof msg.tsp_name-1] = '\0';
(void)strcpy(msg.tsp_name, hostname);
bytenetorder(&msg);
if (sendto(sock, (char *)&msg, sizeof(struct tsp), 0,
(struct sockaddr*)addr, sizeof(struct sockaddr)) < 0) {

View File

@ -36,7 +36,7 @@
static char sccsid[] = "@(#)candidate.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
"$Id$";
"$Id: candidate.c,v 1.3 1997/10/22 06:19:48 charnier Exp $";
#endif /* not lint */
#include "globals.h"
@ -80,8 +80,7 @@ again:
fprintf(fd, "This machine is a candidate time master\n");
msg.tsp_type = TSP_ELECTION;
msg.tsp_vers = TSPVERSION;
(void)strncpy(msg.tsp_name, hostname, sizeof msg.tsp_name-1);
msg.tsp_name[sizeof msg.tsp_name-1] = '\0';
(void)strcpy(msg.tsp_name, hostname);
bytenetorder(&msg);
if (sendto(sock, (char *)&msg, sizeof(struct tsp), 0,
(struct sockaddr*)&net->dest_addr,
@ -140,9 +139,7 @@ again:
/* no master for another round */
htp = addmach(resp->tsp_name,&from,fromnet);
msg.tsp_type = TSP_REFUSE;
(void)strncpy(msg.tsp_name, hostname,
sizeof msg.tsp_name-1);
msg.tsp_name[sizeof msg.tsp_name-1] = '\0';
(void)strcpy(msg.tsp_name, hostname);
answer = acksend(&msg, &htp->addr, htp->name,
TSP_ACK, 0, htp->noanswer);
if (!answer) {

View File

@ -36,7 +36,7 @@
static char sccsid[] = "@(#)correct.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
"$Id$";
"$Id: correct.c,v 1.2 1997/10/22 06:19:48 charnier Exp $";
#endif /* not lint */
#include "globals.h"
@ -84,9 +84,7 @@ correct(avdelta)
mstotvround(&to.tsp_time, corr);
to.tsp_type = TSP_ADJTIME;
}
(void)strncpy(to.tsp_name, hostname,
sizeof to.tsp_name-1);
to.tsp_name[sizeof to.tsp_name-1] = '\0';
(void)strcpy(to.tsp_name, hostname);
answer = acksend(&to, &htp->addr, htp->name,
TSP_ACK, 0, 0);
if (!answer) {

View File

@ -33,10 +33,6 @@
* @(#)globals.h 8.1 (Berkeley) 6/6/93
*/
#ifdef sgi
#ident "$Revision: 1.1.1.1 $"
#endif
#include <sys/param.h>
#include <sys/time.h>
#include <sys/socket.h>

View File

@ -36,7 +36,7 @@
static char sccsid[] = "@(#)master.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
"$Id$";
"$Id: master.c,v 1.3 1997/10/22 06:19:48 charnier Exp $";
#endif /* not lint */
#include "globals.h"
@ -150,9 +150,7 @@ loop:
to.tsp_vers = TSPVERSION;
to.tsp_seq = sequence++;
to.tsp_hopcnt = MAX_HOPCNT;
(void)strncpy(to.tsp_name, hostname,
sizeof to.tsp_name-1);
to.tsp_name[sizeof to.tsp_name-1] = '\0';
(void)strcpy(to.tsp_name, hostname);
bytenetorder(&to);
if (sendto(sock, (char *)&to,
sizeof(struct tsp), 0,
@ -181,9 +179,7 @@ loop:
#ifdef sgi
(void)cftime(newdate, "%D %T", &msg->tsp_time.tv_sec);
#else
(void)strncpy(newdate, ctime(&msg->tsp_time.tv_sec),
sizeof newdate-1);
newdate[sizeof newdate-1] = '\0';
(void)strcpy(newdate, ctime(&msg->tsp_time.tv_sec));
#endif /* sgi */
if (!good_host_name(msg->tsp_name)) {
syslog(LOG_NOTICE,
@ -204,9 +200,7 @@ loop:
#ifdef sgi
(void)cftime(newdate, "%D %T", &msg->tsp_time.tv_sec);
#else
(void)strncpy(newdate, ctime(&msg->tsp_time.tv_sec),
sizeof newdate-1);
newdate[sizeof newdate-1] = '\0';
(void)strcpy(newdate, ctime(&msg->tsp_time.tv_sec));
#endif /* sgi */
htp = findhost(msg->tsp_name);
if (htp == 0) {
@ -254,12 +248,9 @@ loop:
(void)addmach(msg->tsp_name, &from,fromnet);
}
taddr = from;
(void)strncpy(tname, msg->tsp_name, sizeof tname-1);
tname[sizeof tname-1] = '\0';
(void)strcpy(tname, msg->tsp_name);
to.tsp_type = TSP_QUIT;
(void)strncpy(to.tsp_name, hostname,
sizeof to.tsp_name-1);
to.tsp_name[sizeof to.tsp_name-1] = '\0';
(void)strcpy(to.tsp_name, hostname);
answer = acksend(&to, &taddr, tname,
TSP_ACK, 0, 1);
if (answer == NULL) {
@ -276,9 +267,7 @@ loop:
*/
if (!fromnet || fromnet->status != MASTER)
break;
(void)strncpy(to.tsp_name, hostname,
sizeof to.tsp_name-1);
to.tsp_name[sizeof to.tsp_name-1] = '\0';
(void)strcpy(to.tsp_name, hostname);
/* The other master often gets into the same state,
* with boring results if we stay at it forever.
@ -286,9 +275,7 @@ loop:
ntp = fromnet; /* (acksend() can leave fromnet=0 */
for (i = 0; i < 3; i++) {
to.tsp_type = TSP_RESOLVE;
(void)strncpy(to.tsp_name, hostname,
sizeof to.tsp_name-1);
to.tsp_name[sizeof to.tsp_name-1] = '\0';
(void)strcpy(to.tsp_name, hostname);
answer = acksend(&to, &ntp->dest_addr,
ANYADDR, TSP_MASTERACK,
ntp, 0);
@ -333,9 +320,7 @@ loop:
*/
htp = addmach(msg->tsp_name, &from,fromnet);
to.tsp_type = TSP_QUIT;
(void)strncpy(to.tsp_name, hostname,
sizeof to.tsp_name-1);
to.tsp_name[sizeof to.tsp_name-1] = '\0';
(void)strcpy(to.tsp_name, hostname);
answer = acksend(&to, &htp->addr, htp->name,
TSP_ACK, 0, 1);
if (!answer) {
@ -379,13 +364,11 @@ mchgdate(msg)
char olddate[32];
struct timeval otime, ntime;
(void)strncpy(tname, msg->tsp_name, sizeof tname-1);
tname[sizeof tname-1] = '\0';
(void)strcpy(tname, msg->tsp_name);
xmit(TSP_DATEACK, msg->tsp_seq, &from);
(void)strncpy(olddate, date(), sizeof olddate-1);
olddate[sizeof olddate-1] = '\0';
(void)strcpy(olddate, date());
/* adjust time for residence on the queue */
(void)gettimeofday(&otime, 0);
@ -520,8 +503,7 @@ spreadtime()
dictate = 2;
for (htp = self.l_fwd; htp != &self; htp = htp->l_fwd) {
to.tsp_type = TSP_SETTIME;
(void)strncpy(to.tsp_name, hostname, sizeof to.tsp_name-1);
to.tsp_name[sizeof to.tsp_name-1] = '\0';
(void)strcpy(to.tsp_name, hostname);
(void)gettimeofday(&to.tsp_time, 0);
answer = acksend(&to, &htp->addr, htp->name,
TSP_ACK, 0, htp->noanswer);
@ -805,8 +787,7 @@ newslave(msg)
if (now.tv_sec >= fromnet->slvwait.tv_sec+3
|| now.tv_sec < fromnet->slvwait.tv_sec) {
to.tsp_type = TSP_SETTIME;
(void)strncpy(to.tsp_name, hostname, sizeof to.tsp_name-1);
to.tsp_name[sizeof to.tsp_name-1] = '\0';
(void)strcpy(to.tsp_name, hostname);
(void)gettimeofday(&to.tsp_time, 0);
answer = acksend(&to, &htp->addr,
htp->name, TSP_ACK,

View File

@ -36,7 +36,7 @@
static char sccsid[] = "@(#)readmsg.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
"$Id$";
"$Id: readmsg.c,v 1.2 1997/10/22 06:19:48 charnier Exp $";
#endif /* not lint */
#include "globals.h"
@ -393,8 +393,7 @@ masterack()
resp = msgin;
resp.tsp_vers = TSPVERSION;
(void)strncpy(resp.tsp_name, hostname, sizeof resp.tsp_name-1);
resp.tsp_name[sizeof resp.tsp_name-1] = '\0';
(void)strcpy(resp.tsp_name, hostname);
switch(msgin.tsp_type) {

View File

@ -36,7 +36,7 @@
static char sccsid[] = "@(#)slave.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
"$Id$";
"$Id: slave.c,v 1.3 1997/10/22 06:19:48 charnier Exp $";
#endif /* not lint */
#include "globals.h"
@ -151,9 +151,7 @@ loop:
to.tsp_vers = TSPVERSION;
to.tsp_seq = sequence++;
to.tsp_hopcnt = MAX_HOPCNT;
(void)strncpy(to.tsp_name, hostname,
sizeof to.tsp_name-1);
to.tsp_name[sizeof to.tsp_name-1] = '\0';
(void)strcpy(to.tsp_name, hostname);
bytenetorder(&to);
if (sendto(sock, (char *)&to, sizeof(struct tsp), 0,
(struct sockaddr*)&ntp->dest_addr,
@ -267,11 +265,8 @@ loop:
* the following line is necessary due to syslog
* calling ctime() which clobbers the static buffer
*/
(void)strncpy(olddate, date(), sizeof olddate-1);
olddate[sizeof olddate-1] = '\0';
(void)strncpy(newdate, ctime(&msg->tsp_time.tv_sec),
sizeof newdate-1);
newdate[sizeof newdate-1] = '\0';
(void)strcpy(olddate, date());
(void)strcpy(newdate, ctime(&msg->tsp_time.tv_sec));
#endif /* sgi */
if (!good_host_name(msg->tsp_name)) {
@ -362,9 +357,7 @@ loop:
#ifdef sgi
(void)cftime(newdate, "%D %T", &msg->tsp_time.tv_sec);
#else
(void)strncpy(newdate, ctime(&msg->tsp_time.tv_sec),
sizeof newdate-1);
newdate[sizeof newdate-1] = '\0';
(void)strcpy(newdate, ctime(&msg->tsp_time.tv_sec));
#endif /* sgi */
schgdate(msg, newdate);
break;
@ -375,9 +368,7 @@ loop:
#ifdef sgi
(void)cftime(newdate, "%D %T", &msg->tsp_time.tv_sec);
#else
(void)strncpy(newdate, ctime(&msg->tsp_time.tv_sec),
sizeof newdate-1);
newdate[sizeof newdate-1] = '\0';
(void)strcpy(newdate, ctime(&msg->tsp_time.tv_sec));
#endif /* sgi */
htp = findhost(msg->tsp_name);
if (0 == htp) {
@ -431,12 +422,8 @@ loop:
refusetime = ntime.tv_sec + 30;
}
taddr = from;
(void)strncpy(tname, msg->tsp_name,
sizeof tname-1);
tname[sizeof tname-1] = '\0';
(void)strncpy(to.tsp_name, hostname,
sizeof to.tsp_name-1);
to.tsp_name[sizeof to.tsp_name-1] = '\0';
(void)strcpy(tname, msg->tsp_name);
(void)strcpy(to.tsp_name, hostname);
answerdelay();
if (!acksend(&to, &taddr, tname,
TSP_ACK, 0, 0))
@ -447,9 +434,7 @@ loop:
} else { /* fromnet->status == MASTER */
htp = addmach(msg->tsp_name, &from,fromnet);
to.tsp_type = TSP_QUIT;
(void)strncpy(to.tsp_name, hostname,
sizeof to.tsp_name-1);
to.tsp_name[sizeof to.tsp_name-1] = '\0';
(void)strcpy(to.tsp_name, hostname);
if (!acksend(&to, &htp->addr, htp->name,
TSP_ACK, 0, htp->noanswer)) {
syslog(LOG_ERR,
@ -468,9 +453,7 @@ loop:
* more than one master: the first slave to
* come up will notify here the situation.
*/
(void)strncpy(to.tsp_name, hostname,
sizeof to.tsp_name-1);
to.tsp_name[sizeof to.tsp_name-1] = '\0';
(void)strcpy(to.tsp_name, hostname);
/* The other master often gets into the same state,
* with boring results.
@ -504,9 +487,7 @@ loop:
to.tsp_type = TSP_MSITEREQ;
to.tsp_vers = TSPVERSION;
to.tsp_seq = 0;
(void)strncpy(to.tsp_name, hostname,
sizeof to.tsp_name-1);
to.tsp_name[sizeof to.tsp_name-1] = '\0';
(void)strcpy(to.tsp_name, hostname);
answer = acksend(&to, &slavenet->dest_addr,
ANYADDR, TSP_ACK,
slavenet, 0);
@ -514,14 +495,12 @@ loop:
&& good_host_name(answer->tsp_name)) {
setmaster(answer);
to.tsp_type = TSP_ACK;
(void)strncpy(to.tsp_name, answer->tsp_name,
sizeof to.tsp_name-1);
to.tsp_name[sizeof to.tsp_name-1] = '\0';
(void)strcpy(to.tsp_name, answer->tsp_name);
bytenetorder(&to);
if (sendto(sock, (char *)&to,
sizeof(struct tsp), 0,
(struct sockaddr*)&taddr,
sizeof(taddr)) < 0) {
sizeof(taddr)) < 0) {
trace_sendto_err(taddr.sin_addr);
}
}
@ -566,13 +545,9 @@ loop:
if (answer == NULL)
break;
taddr = from;
(void)strncpy(tname, answer->tsp_name,
sizeof tname-1);
tname[sizeof tname-1] = '\0';
(void)strcpy(tname, answer->tsp_name);
to.tsp_type = TSP_QUIT;
(void)strncpy(to.tsp_name, hostname,
sizeof to.tsp_name-1);
to.tsp_name[sizeof to.tsp_name-1] = '\0';
(void)strcpy(to.tsp_name, hostname);
if (!acksend(&to, &taddr, tname,
TSP_ACK, 0, 1)) {
syslog(LOG_ERR,
@ -625,9 +600,7 @@ loop:
htp = addmach(answer->tsp_name,
&from,ntp);
to.tsp_type = TSP_QUIT;
(void)strncpy(to.tsp_name, hostname,
sizeof to.tsp_name-1);
to.tsp_name[sizeof to.tsp_name-1] = '\0';
(void)strcpy(to.tsp_name, hostname);
if (!acksend(&to,&htp->addr,htp->name,
TSP_ACK, 0, htp->noanswer)) {
syslog(LOG_ERR,
@ -663,9 +636,7 @@ setmaster(msg)
&& (slavenet != old_slavenet
|| strcmp(msg->tsp_name, master_name)
|| old_status != status)) {
(void)strncpy(master_name, msg->tsp_name,
sizeof master_name-1);
master_name[sizeof master_name-1] = '\0';
(void)strcpy(master_name, msg->tsp_name);
old_slavenet = slavenet;
old_status = status;
@ -713,8 +684,7 @@ schgdate(msg, newdate)
to.tsp_type = TSP_SETDATEREQ;
to.tsp_time = msg->tsp_time;
(void)strncpy(to.tsp_name, hostname, sizeof to.tsp_name-1);
to.tsp_name[sizeof to.tsp_name-1] = '\0';
(void)strcpy(to.tsp_name, hostname);
if (!acksend(&to, &slavenet->dest_addr,
ANYADDR, TSP_DATEACK,
slavenet, 0))

View File

@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)timed.c 8.1 (Berkeley) 6/6/93";
#endif
static const char rcsid[] =
"$Id$";
"$Id: timed.c,v 1.5 1997/10/22 06:19:49 charnier Exp $";
#endif /* not lint */
#define TSPTYPES
@ -573,8 +573,7 @@ suppress(addr, name,net)
if (trace)
fprintf(fd, "suppress: %s\n", name);
tgt = *addr;
(void)strncpy(tname, name, sizeof tname-1);
tname[sizeof tname-1] = '\0';
(void)strcpy(tname, name);
while (0 != readmsg(TSP_ANY, ANYADDR, &wait, net)) {
if (trace)
@ -584,8 +583,7 @@ suppress(addr, name,net)
syslog(LOG_NOTICE, "suppressing false master %s", tname);
msg.tsp_type = TSP_QUIT;
(void)strncpy(msg.tsp_name, hostname, sizeof msg.tsp_name-1);
msg.tsp_name[sizeof msg.tsp_name-1] = '\0';
(void)strcpy(msg.tsp_name, hostname);
(void)acksend(&msg, &tgt, tname, TSP_ACK, 0, 1);
}
@ -603,8 +601,7 @@ lookformaster(ntp)
/* look for master */
resp.tsp_type = TSP_MASTERREQ;
(void)strncpy(resp.tsp_name, hostname, sizeof resp.tsp_name-1);
resp.tsp_name[sizeof resp.tsp_name-1] = '\0';
(void)strcpy(resp.tsp_name, hostname);
answer = acksend(&resp, &ntp->dest_addr, ANYADDR,
TSP_MASTERACK, ntp, 0);
if (answer != 0 && !good_host_name(answer->tsp_name)) {
@ -659,8 +656,7 @@ lookformaster(ntp)
}
ntp->status = SLAVE;
(void)strncpy(mastername, answer->tsp_name, sizeof mastername-1);
mastername[sizeof mastername-1] = '\0';
(void)strcpy(mastername, answer->tsp_name);
masteraddr = from;
/*
@ -678,9 +674,7 @@ lookformaster(ntp)
if (answer != NULL &&
strcmp(answer->tsp_name, mastername) != 0) {
conflict.tsp_type = TSP_CONFLICT;
(void)strncpy(conflict.tsp_name, hostname,
sizeof conflict.tsp_name-1);
conflict.tsp_name[sizeof conflict.tsp_name-1] = '\0';
(void)strcpy(conflict.tsp_name, hostname);
if (!acksend(&conflict, &masteraddr, mastername,
TSP_ACK, 0, 0)) {
syslog(LOG_ERR,