CVS commit: src/sbin/routed/rtquery
Module Name:src Committed By: dholland Date: Sun Mar 23 05:36:58 UTC 2014 Modified Files: src/sbin/routed/rtquery: rtquery.c Log Message: don't use sprintf To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sbin/routed/rtquery/rtquery.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/routed/rtquery/rtquery.c diff -u src/sbin/routed/rtquery/rtquery.c:1.24 src/sbin/routed/rtquery/rtquery.c:1.25 --- src/sbin/routed/rtquery/rtquery.c:1.24 Sat Oct 19 00:57:41 2013 +++ src/sbin/routed/rtquery/rtquery.c Sun Mar 23 05:36:58 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: rtquery.c,v 1.24 2013/10/19 00:57:41 christos Exp $ */ +/* $NetBSD: rtquery.c,v 1.25 2014/03/23 05:36:58 dholland Exp $ */ /*- * Copyright (c) 1982, 1986, 1993 @@ -63,7 +63,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1988, 1993\ The Regents of the University of California. All rights reserved."); #ifdef __NetBSD__ -__RCSID("$NetBSD: rtquery.c,v 1.24 2013/10/19 00:57:41 christos Exp $"); +__RCSID("$NetBSD: rtquery.c,v 1.25 2014/03/23 05:36:58 dholland Exp $"); #elif defined(__FreeBSD__) __RCSID("$FreeBSD$"); #else @@ -552,11 +552,11 @@ static char * qstring(u_char *s, int len) { static char buf[8*20+1]; - char *p; + size_t bufpos; u_char *s2, c; - for (p = buf; len != 0 && p < &buf[sizeof(buf)-1]; len--) { + for (bufpos = 0; len != 0 && bufpos < sizeof(buf) - 1; len--) { c = *s++; if (c == '\0') { for (s2 = s+1; s2 < &s[len]; s2++) { @@ -568,33 +568,38 @@ qstring(u_char *s, int len) } if (c >= ' ' && c < 0x7f && c != '\\') { - *p++ = c; + buf[bufpos++] = c; continue; } - *p++ = '\\'; + if (bufpos >= sizeof(buf) - 2) { + /* too long */ + break; + } + buf[bufpos++] = '\\'; switch (c) { case '\\': - *p++ = '\\'; + buf[bufpos++] = '\\'; break; case '\n': - *p++= 'n'; + buf[bufpos++] = 'n'; break; case '\r': - *p++= 'r'; + buf[bufpos++] = 'r'; break; case '\t': - *p++ = 't'; + buf[bufpos++] = 't'; break; case '\b': - *p++ = 'b'; + buf[bufpos++] = 'b'; break; default: - p += sprintf(p,"%o",c); + bufpos += snprintf(buf + bufpos, sizeof(buf) - bufpos, + "%o", c); break; } } exit: - *p = '\0'; + buf[bufpos] = '\0'; return buf; } @@ -614,7 +619,7 @@ rip_input(struct sockaddr_in *from, MD5_CTX md5_ctx; u_char md5_authed = 0; u_int mask, dmask; - char *sp; + size_t spos; int i; struct hostent *hp; struct netent *np; @@ -665,9 +670,11 @@ rip_input(struct sockaddr_in *from, mask = ntohl(n->n_mask); dmask = mask & -mask; if (mask != 0) { -sp = &net_buf[strlen(net_buf)]; +spos = strlen(net_buf); if (IMSG.rip_vers == RIPv1) { - (void)sprintf(sp," mask=%#x ? ",mask); + (void)snprintf(net_buf + spos, + sizeof(net_buf) - spos, + " mask=%#x ? ", mask); mask = 0; } else if (mask + dmask == 0) { for (i = 0; @@ -675,9 +682,13 @@ rip_input(struct sockaddr_in *from, && ((1n_dst >> 24), (u_char)(n->n_dst >> 16),
CVS commit: src/sbin/routed/rtquery
Module Name:src Committed By: christos Date: Sat Oct 19 00:57:41 UTC 2013 Modified Files: src/sbin/routed/rtquery: rtquery.c Log Message: gcc warns about array bounds limits, but unfortunately the API here requires flex arrays in a union which is not allowed. So do a trivial pointer assignment to baffle gcc again. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sbin/routed/rtquery/rtquery.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/routed/rtquery/rtquery.c diff -u src/sbin/routed/rtquery/rtquery.c:1.23 src/sbin/routed/rtquery/rtquery.c:1.24 --- src/sbin/routed/rtquery/rtquery.c:1.23 Mon Aug 29 10:35:04 2011 +++ src/sbin/routed/rtquery/rtquery.c Fri Oct 18 20:57:41 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: rtquery.c,v 1.23 2011/08/29 14:35:04 joerg Exp $ */ +/* $NetBSD: rtquery.c,v 1.24 2013/10/19 00:57:41 christos Exp $ */ /*- * Copyright (c) 1982, 1986, 1993 @@ -63,7 +63,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1988, 1993\ The Regents of the University of California. All rights reserved."); #ifdef __NetBSD__ -__RCSID("$NetBSD: rtquery.c,v 1.23 2011/08/29 14:35:04 joerg Exp $"); +__RCSID("$NetBSD: rtquery.c,v 1.24 2013/10/19 00:57:41 christos Exp $"); #elif defined(__FreeBSD__) __RCSID("$FreeBSD$"); #else @@ -372,8 +372,9 @@ trace_loop(char *argv[]) static void query_loop(char *argv[], int argc) { -# define NA0 (OMSG.rip_auths[0]) -# define NA2 (OMSG.rip_auths[2]) + struct netauth *na = OMSG.rip_auths; +# define NA0 (na[0]) +# define NA2 (na[2]) struct seen { struct seen *next; struct in_addr addr; @@ -391,14 +392,14 @@ query_loop(char *argv[], int argc) if (ripv2) { OMSG.rip_vers = RIPv2; if (auth_type == RIP_AUTH_PW) { - OMSG.rip_nets[1] = OMSG.rip_nets[0]; + na[1] = na[0]; NA0.a_family = RIP_AF_AUTH; NA0.a_type = RIP_AUTH_PW; memcpy(NA0.au.au_pw, passwd, RIP_AUTH_PW_LEN); omsg_len += sizeof(OMSG.rip_nets[0]); } else if (auth_type == RIP_AUTH_MD5) { - OMSG.rip_nets[1] = OMSG.rip_nets[0]; + na[1] = na[0]; NA0.a_family = RIP_AF_AUTH; NA0.a_type = RIP_AUTH_MD5; NA0.au.a_md5.md5_keyid = (int8_t)keyid;
CVS commit: src/sbin/routed/rtquery
Module Name:src Committed By: wiz Date: Fri Sep 11 11:44:38 UTC 2009 Modified Files: src/sbin/routed/rtquery: rtquery.8 Log Message: Add xref to pkgsrc/net/gated, so people know where to find gated(8). Improve markup of RFCs in SEE ALSO. Sort options. Bump date. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sbin/routed/rtquery/rtquery.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/routed/rtquery/rtquery.8 diff -u src/sbin/routed/rtquery/rtquery.8:1.19 src/sbin/routed/rtquery/rtquery.8:1.20 --- src/sbin/routed/rtquery/rtquery.8:1.19 Tue Sep 23 12:14:49 2003 +++ src/sbin/routed/rtquery/rtquery.8 Fri Sep 11 11:44:38 2009 @@ -1,6 +1,6 @@ -.\" $NetBSD: rtquery.8,v 1.19 2003/09/23 12:14:49 wiz Exp $ +.\" $NetBSD: rtquery.8,v 1.20 2009/09/11 11:44:38 wiz Exp $ .\" -.Dd June 1, 1996 +.Dd September 11, 2009 .Dt RTQUERY 8 .Os .Sh NAME @@ -8,10 +8,10 @@ .Nd query routing daemons for their routing tables .Sh SYNOPSIS .Nm -.Op Fl np1 -.Op Fl w Ar timeout -.Op Fl r Ar addr +.Op Fl 1np .Op Fl a Ar secret +.Op Fl r Ar addr +.Op Fl w Ar timeout .Ar host ... .Nm .Op Fl t Ar op @@ -114,8 +114,15 @@ .El .Sh SEE ALSO .Xr gated 8 , -.Xr routed 8 -.br -RFC\ 1058 - Routing Information Protocol, RIPv1 -.br -RFC\ 1723 - Routing Information Protocol, RIPv2 +.Xr routed 8 , +.Pa pkgsrc/net/gated +.Rs +.%R RFC 1058 +.%T Routing Information Protocol, RIPv1 +.%D 1988 +.Re +.Rs +.%R RFC 1723 +.%T Routing Information Protocol, RIPv2 +.%D 1994 +.Re