strlcpy. rtm_seq is an int. use pidfile(3). sync w/kame via openbsd

This commit is contained in:
itojun 2002-05-29 23:11:13 +00:00
parent 1675bb6f17
commit ef188effbf
2 changed files with 16 additions and 19 deletions

View File

@ -1,8 +1,11 @@
# $NetBSD: Makefile,v 1.5 2001/11/19 03:19:10 itojun Exp $ # $NetBSD: Makefile,v 1.6 2002/05/29 23:11:13 itojun Exp $
PROG= route6d PROG= route6d
MAN= route6d.8 MAN= route6d.8
CPPFLAGS+=-DINET6 CPPFLAGS+=-DINET6
LDADD+= -lutil
DPADD+= ${LIBUTIL}
.include <bsd.prog.mk> .include <bsd.prog.mk>

View File

@ -1,5 +1,5 @@
/* $NetBSD: route6d.c,v 1.32 2002/02/25 02:22:59 itojun Exp $ */ /* $NetBSD: route6d.c,v 1.33 2002/05/29 23:11:13 itojun Exp $ */
/* $KAME: route6d.c,v 1.80 2002/02/24 07:10:10 suz Exp $ */ /* $KAME: route6d.c,v 1.83 2002/05/29 23:07:33 itojun Exp $ */
/* /*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -32,7 +32,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef lint #ifndef lint
__RCSID("$NetBSD: route6d.c,v 1.32 2002/02/25 02:22:59 itojun Exp $"); __RCSID("$NetBSD: route6d.c,v 1.33 2002/05/29 23:11:13 itojun Exp $");
#endif #endif
#include <stdio.h> #include <stdio.h>
@ -51,6 +51,7 @@ __RCSID("$NetBSD: route6d.c,v 1.32 2002/02/25 02:22:59 itojun Exp $");
#include <stddef.h> #include <stddef.h>
#include <errno.h> #include <errno.h>
#include <err.h> #include <err.h>
#include <util.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/param.h> #include <sys/param.h>
@ -199,9 +200,8 @@ FILE *rtlog = NULL;
int logopened = 0; int logopened = 0;
static u_long seq = 0; static int seq = 0;
volatile int signo;
volatile sig_atomic_t seenalrm; volatile sig_atomic_t seenalrm;
volatile sig_atomic_t seenquit; volatile sig_atomic_t seenquit;
volatile sig_atomic_t seenusr1; volatile sig_atomic_t seenusr1;
@ -284,7 +284,6 @@ main(argc, argv)
int error = 0; int error = 0;
struct ifc *ifcp; struct ifc *ifcp;
sigset_t mask, omask; sigset_t mask, omask;
FILE *pidfile;
char *progname; char *progname;
char *ep; char *ep;
@ -392,11 +391,7 @@ main(argc, argv)
if (dflag) if (dflag)
ifrtdump(0); ifrtdump(0);
pid = getpid(); pidfile(NULL);
if ((pidfile = fopen(ROUTE6D_PID, "w")) != NULL) {
fprintf(pidfile, "%d\n", pid);
fclose(pidfile);
}
if ((ripbuf = (struct rip6 *)malloc(RIP6_MAXMTU)) == NULL) { if ((ripbuf = (struct rip6 *)malloc(RIP6_MAXMTU)) == NULL) {
fatal("malloc"); fatal("malloc");
@ -454,7 +449,6 @@ main(argc, argv)
} }
FD_COPY(&sockvec, &recvec); FD_COPY(&sockvec, &recvec);
signo = 0;
switch (select(maxfd + 1, &recvec, 0, 0, 0)) { switch (select(maxfd + 1, &recvec, 0, 0, 0)) {
case -1: case -1:
if (errno != EINTR) { if (errno != EINTR) {
@ -480,11 +474,10 @@ main(argc, argv)
} }
void void
sighandler(sig) sighandler(signo)
int sig; int signo;
{ {
signo = sig;
switch (signo) { switch (signo) {
case SIGALRM: case SIGALRM:
seenalrm++; seenalrm++;
@ -2796,7 +2789,7 @@ getroute(np, gw)
struct in6_addr *gw; struct in6_addr *gw;
{ {
u_char buf[BUFSIZ]; u_char buf[BUFSIZ];
u_long myseq; int myseq;
int len; int len;
struct rt_msghdr *rtm; struct rt_msghdr *rtm;
struct sockaddr_in6 *sin6; struct sockaddr_in6 *sin6;
@ -3269,14 +3262,15 @@ char *
allocopy(p) allocopy(p)
char *p; char *p;
{ {
char *q = (char *)malloc(strlen(p) + 1); int len = strlen(p) + 1;
char *q = (char *)malloc(len);
if (!q) { if (!q) {
fatal("malloc"); fatal("malloc");
/*NOTREACHED*/ /*NOTREACHED*/
} }
strcpy(q, p); strlcpy(q, p, len);
return q; return q;
} }