diff options
author | brian <brian@FreeBSD.org> | 1997-12-17 21:22:05 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 1997-12-17 21:22:05 +0000 |
commit | 7903f9af9432f5105f3f04bda2ee313b2efdc84f (patch) | |
tree | 279930bdbcfd264d3ae3ca576c374965c1c4f6bb | |
parent | 7d06bfe1d51f8b96c5b80c6e6749cee5f75c423c (diff) | |
download | FreeBSD-src-7903f9af9432f5105f3f04bda2ee313b2efdc84f.zip FreeBSD-src-7903f9af9432f5105f3f04bda2ee313b2efdc84f.tar.gz |
Don't depend on a u_long being 32 bits.
Pointed out by: Theo de Raadt <deraadt@cvs.openbsd.org>
-rw-r--r-- | usr.sbin/ppp/route.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/usr.sbin/ppp/route.c b/usr.sbin/ppp/route.c index df8f1f7..21636ce 100644 --- a/usr.sbin/ppp/route.c +++ b/usr.sbin/ppp/route.c @@ -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.32 1997/12/15 20:21:15 brian Exp $ + * $Id: route.c,v 1.33 1997/12/17 00:19:25 brian Exp $ * */ @@ -283,17 +283,20 @@ struct bits { #endif static void -p_flags(u_long f, const char *format) +p_flags(u_long f, int max) { if (VarTerm) { char name[33], *flags; register struct bits *p = bits; - for (flags = name; p->b_mask; p++) + if (max > sizeof(name)-1) + max = sizeof(name)-1; + + for (flags = name; p->b_mask && flags - name < max; p++) if (p->b_mask & f) *flags++ = p->b_val; *flags = '\0'; - fprintf(VarTerm, format, name); + fprintf(VarTerm, "%-*.*s", max, max, name); } } @@ -422,8 +425,8 @@ ShowRoute(struct cmdargs const *arg) p_sockaddr(sa_dst, sa_mask, 20); p_sockaddr(sa_gw, NULL, 20); - p_flags(rtm->rtm_flags, "%-6.6s "); - fprintf(VarTerm, "%s\n", Index2Nam(rtm->rtm_index)); + p_flags(rtm->rtm_flags, 6); + fprintf(VarTerm, " %s\n", Index2Nam(rtm->rtm_index)); } free(sp); return 0; |