summaryrefslogtreecommitdiff
path: root/usr.sbin/ppp/route.c
diff options
context:
space:
mode:
authorbrian <brian@cvs.openbsd.org>1997-12-17 21:18:10 +0000
committerbrian <brian@cvs.openbsd.org>1997-12-17 21:18:10 +0000
commit0017be07b227a275abf41142fe4d976530637595 (patch)
tree05ddb0f01ac7a812d634bc5a84cc4625034ea253 /usr.sbin/ppp/route.c
parent756c4405109e9303251819cff36a3385c83de12a (diff)
Don't depend on a u_long being 32 bits.
Pointed out by: Theo de Raadt <deraadt@cvs.openbsd.org>
Diffstat (limited to 'usr.sbin/ppp/route.c')
-rw-r--r--usr.sbin/ppp/route.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/usr.sbin/ppp/route.c b/usr.sbin/ppp/route.c
index f23ef7c2ec1..b329db92dba 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.6 1997/12/17 00:20:37 brian Exp $
+ * $Id: route.c,v 1.7 1997/12/17 21:18:09 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;