Skip to content

Commit

Permalink
fix printing of flags. now we can properly print 'not' flags, the logic
Browse files Browse the repository at this point in the history
did not properly account for the meaning of the negative value flags.
and while i'm there, i find that clang 4.0.0 now likes to optimize
away our wonderful memset( ,0, ); which also screwed up flag printing
BIGLY! explicit_bzero to the rescue. i'm starting to think,
this is going to be explicitly needed in several places.
  • Loading branch information
yellowman committed May 10, 2017
1 parent 5595a9f commit bf9ecd5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions conf.c
Expand Up @@ -1294,10 +1294,12 @@ isdefaultroute(struct sockaddr *sa, struct sockaddr *samask)

switch (sa->sa_family) {
case AF_INET:
/* XXX check for zero mask */
return
(((struct sockaddr_in *)sa)->sin_addr.s_addr) == INADDR_ANY;
break;
case AF_INET6:
/* XXX check for zero mask */
return (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr));
break;
default:
Expand Down Expand Up @@ -1328,11 +1330,11 @@ conf_rtflags(char *txt, int flags, struct rt_msghdr *rtm)

for (i = 0; i < nitems(rtflags); i++)
if (rtflags[i].flag < 0) {
if (!flags & rtflags[i].flag) {
if (!(flags & -rtflags[i].flag)) {
strlcat(txt, " ", TMPSIZ);
strlcat(txt, rtflags[i].name, TMPSIZ);
}
} else if (flags & rtflags[i].flag) {
} else if ((flags & rtflags[i].flag)) {
strlcat(txt, " ", TMPSIZ);
strlcat(txt, rtflags[i].name, TMPSIZ);
}
Expand Down Expand Up @@ -1401,5 +1403,5 @@ conf_print_rtm(FILE *output, struct rt_msghdr *rtm, char *delim, int af)
fprintf(output, "%s%s ", delim, routename(dst));
fprintf(output, "%s\n", routename(gate));
}
memset(flags, 0, TMPSIZ);
explicit_bzero(flags, TMPSIZ);
}

0 comments on commit bf9ecd5

Please sign in to comment.