routed(8): Misc. cleanups to squelch Coverity.
table.c: Copy into fixed size buffer. trace.c: Argument got dup2() cannot be negative. Copy into fixed size buffer. CID: 1006785, 1006786, 271301 Obtained from: NetBSD MFC after: 2 weeks.
This commit is contained in:
parent
415f6c24dd
commit
e09d48f656
@ -1228,7 +1228,7 @@ read_rt(void)
|
||||
continue; /* ignore compat message */
|
||||
#endif
|
||||
|
||||
strcpy(str, rtm_type_name(m.r.rtm.rtm_type));
|
||||
strlcpy(str, rtm_type_name(m.r.rtm.rtm_type), sizeof(str));
|
||||
strp = &str[strlen(str)];
|
||||
if (m.r.rtm.rtm_type <= RTM_CHANGE)
|
||||
strp += sprintf(strp," from pid %d",m.r.rtm.rtm_pid);
|
||||
|
@ -205,6 +205,8 @@ trace_close(int zap_stdio)
|
||||
fclose(ftrace);
|
||||
ftrace = NULL;
|
||||
fd = open(_PATH_DEVNULL, O_RDWR);
|
||||
if (fd < 0)
|
||||
return;
|
||||
if (isatty(STDIN_FILENO))
|
||||
(void)dup2(fd, STDIN_FILENO);
|
||||
if (isatty(STDOUT_FILENO))
|
||||
@ -439,9 +441,12 @@ addrname(naddr addr, /* in network byte order */
|
||||
} bufs[NUM_BUFS];
|
||||
char *s, *sp;
|
||||
naddr dmask;
|
||||
size_t l;
|
||||
int i;
|
||||
|
||||
s = strcpy(bufs[bufno].str, naddr_ntoa(addr));
|
||||
strlcpy(bufs[bufno].str, naddr_ntoa(addr), sizeof(bufs[bufno].str));
|
||||
s = bufs[bufno].str;
|
||||
l = sizeof(bufs[bufno].str);
|
||||
bufno = (bufno+1) % NUM_BUFS;
|
||||
|
||||
if (force == 1 || (force == 0 && mask != std_mask(addr))) {
|
||||
@ -451,10 +456,11 @@ addrname(naddr addr, /* in network byte order */
|
||||
if (mask + dmask == 0) {
|
||||
for (i = 0; i != 32 && ((1<<i) & mask) == 0; i++)
|
||||
continue;
|
||||
(void)sprintf(sp, "/%d", 32-i);
|
||||
(void)snprintf(sp, s + l - sp, "/%d", 32-i);
|
||||
|
||||
} else {
|
||||
(void)sprintf(sp, " (mask %#x)", (u_int)mask);
|
||||
(void)snprintf(sp, s + l - sp, " (mask %#x)",
|
||||
(u_int)mask);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user