From c1ae06abab7c9ad64e5410a36f6b76959aef7b55 Mon Sep 17 00:00:00 2001 From: christos Date: Thu, 20 Mar 2014 20:42:08 +0000 Subject: [PATCH] kill sprintf --- sys/external/bsd/ipf/netinet/fil.c | 25 +++---- sys/external/bsd/ipf/netinet/ip_compat.h | 5 +- sys/external/bsd/ipf/netinet/ip_fil_compat.c | 14 ++-- sys/external/bsd/ipf/netinet/ip_ftp_pxy.c | 69 ++++---------------- sys/external/bsd/ipf/netinet/ip_htable.c | 10 +-- sys/external/bsd/ipf/netinet/ip_irc_pxy.c | 11 +--- sys/external/bsd/ipf/netinet/ip_lookup.c | 10 +-- sys/external/bsd/ipf/netinet/ip_pool.c | 16 ++--- sys/external/bsd/ipf/netinet/ip_rpcb_pxy.c | 29 ++------ sys/external/bsd/ipf/netinet/radix_ipf.c | 10 +-- sys/lib/libsa/bootp.c | 4 +- sys/rump/dev/lib/libugenhc/ugenhc.c | 14 ++-- sys/rump/librump/rumpkern/rump.c | 7 +- sys/rump/librump/rumpvfs/devnodes.c | 22 +++---- sys/rump/net/lib/libshmif/if_shmem.c | 6 +- sys/rump/net/lib/libvirtif/if_virt.c | 6 +- 16 files changed, 80 insertions(+), 178 deletions(-) diff --git a/sys/external/bsd/ipf/netinet/fil.c b/sys/external/bsd/ipf/netinet/fil.c index baed15a58585..3dec2b38f3c2 100644 --- a/sys/external/bsd/ipf/netinet/fil.c +++ b/sys/external/bsd/ipf/netinet/fil.c @@ -1,4 +1,4 @@ -/* $NetBSD: fil.c,v 1.13 2013/11/27 22:18:06 christos Exp $ */ +/* $NetBSD: fil.c,v 1.14 2014/03/20 20:43:12 christos Exp $ */ /* * Copyright (C) 2012 by Darren Reed. @@ -138,7 +138,7 @@ extern struct timeout ipf_slowtimer_ch; #if !defined(lint) #if defined(__NetBSD__) #include -__KERNEL_RCSID(0, "$NetBSD: fil.c,v 1.13 2013/11/27 22:18:06 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fil.c,v 1.14 2014/03/20 20:43:12 christos Exp $"); #else static const char sccsid[] = "@(#)fil.c 1.36 6/5/96 (C) 1993-2000 Darren Reed"; static const char rcsid[] = "@(#)Id: fil.c,v 1.1.1.2 2012/07/22 13:45:07 darrenr Exp $"; @@ -4196,14 +4196,14 @@ ipf_getstat(ipf_main_softc_t *softc, friostat_t *fiop, int rev) fiop->f_features = ipf_features; #ifdef IPFILTER_COMPAT - sprintf(fiop->f_version, "IP Filter: v%d.%d.%d", - (rev / 1000000) % 100, - (rev / 10000) % 100, - (rev / 100) % 100); + snprintf(fiop->f_version, sizeof(fiop->f_version), + "IP Filter: v%d.%d.%d", (rev / 1000000) % 100, + (rev / 10000) % 100, (rev / 100) % 100); #else rev = rev; (void) strncpy(fiop->f_version, ipfilter_version, sizeof(fiop->f_version)); + fiop->f_version[sizeof(fiop->f_version) - 1] = '\0'; #endif } @@ -5392,11 +5392,7 @@ ipf_grpmapinit(ipf_main_softc_t *softc, frentry_t *fr) char name[FR_GROUPLEN]; iphtable_t *iph; -#if defined(SNPRINTF) && defined(_KERNEL) - SNPRINTF(name, sizeof(name), "%d", fr->fr_arg); -#else - (void) sprintf(name, "%d", fr->fr_arg); -#endif + (void) snprintf(name, sizeof(name), "%d", fr->fr_arg); iph = ipf_lookup_find_htable(softc, IPL_LOGIPF, name); if (iph == NULL) { IPFERROR(38); @@ -5932,12 +5928,9 @@ ipf_getifname(ifp, buffer) unit = ifp->if_unit; space = LIFNAMSIZ - (s - buffer); if ((space > 0) && (unit >= 0)) { -# if defined(SNPRINTF) && defined(_KERNEL) - SNPRINTF(temp, sizeof(temp), "%d", unit); -# else - (void) sprintf(temp, "%d", unit); -# endif + snprintf(temp, sizeof(temp), "%d", unit); (void) strncpy(s, temp, space); + s[space - 1] = '\0'; } # endif return buffer; diff --git a/sys/external/bsd/ipf/netinet/ip_compat.h b/sys/external/bsd/ipf/netinet/ip_compat.h index 8620404d40d9..cd9344349375 100644 --- a/sys/external/bsd/ipf/netinet/ip_compat.h +++ b/sys/external/bsd/ipf/netinet/ip_compat.h @@ -1,4 +1,4 @@ -/* $NetBSD: ip_compat.h,v 1.6 2013/01/09 13:23:20 christos Exp $ */ +/* $NetBSD: ip_compat.h,v 1.7 2014/03/20 20:43:12 christos Exp $ */ /* * Copyright (C) 2012 by Darren Reed. @@ -235,7 +235,6 @@ struct file; # include # endif # if SOLARIS2 >= 8 -# define SNPRINTF snprintf # include # define ipif_local_addr ipif_lcl_addr @@ -431,7 +430,6 @@ typedef struct ip6_hdr ip6_t; # ifdef _KERNEL # define FASTROUTE_RECURSION 1 -# define SNPRINTF sprintf # if (HPUXREV >= 1111) # define IPL_SELECT # ifdef IPL_SELECT @@ -1173,7 +1171,6 @@ typedef u_int32_t u_32_t; # include "bpfilter.h" # endif # if (OpenBSD >= 200311) -# define SNPRINTF snprintf # if defined(USE_INET6) # include "netinet6/in6_var.h" # include "netinet6/nd6.h" diff --git a/sys/external/bsd/ipf/netinet/ip_fil_compat.c b/sys/external/bsd/ipf/netinet/ip_fil_compat.c index bca09b12c501..8cd1b20d00f6 100644 --- a/sys/external/bsd/ipf/netinet/ip_fil_compat.c +++ b/sys/external/bsd/ipf/netinet/ip_fil_compat.c @@ -1,4 +1,4 @@ -/* $NetBSD: ip_fil_compat.c,v 1.3 2012/07/22 14:27:51 darrenr Exp $ */ +/* $NetBSD: ip_fil_compat.c,v 1.4 2014/03/20 20:43:12 christos Exp $ */ /* * Copyright (C) 2002-2012 by Darren Reed. @@ -3526,10 +3526,8 @@ friostat_current_to_4_1_33(void *current, friostat_4_1_33_t *old, int rev) old->f_running = fiop->f_running; old->f_logging = fiop->f_logging; old->f_features = fiop->f_features; - sprintf(old->f_version, "IP Filter: v%d.%d.%d", - (rev / 1000000) % 100, - (rev / 10000) % 100, - (rev / 100) % 100); + snprintf(old->f_version, sizeof(old->f_version), "IP Filter: v%d.%d.%d", + (rev / 1000000) % 100, (rev / 10000) % 100, (rev / 100) % 100); } @@ -3589,10 +3587,8 @@ friostat_current_to_4_1_0(void *current, friostat_4_1_0_t *old, int rev) old->f_running = fiop->f_running; old->f_logging = fiop->f_logging; old->f_features = fiop->f_features; - sprintf(old->f_version, "IP Filter: v%d.%d.%d", - (rev / 1000000) % 100, - (rev / 10000) % 100, - (rev / 100) % 100); + snprintf(old->f_version, sizeof(old->f_version), "IP Filter: v%d.%d.%d", + (rev / 1000000) % 100, (rev / 10000) % 100, (rev / 100) % 100); } diff --git a/sys/external/bsd/ipf/netinet/ip_ftp_pxy.c b/sys/external/bsd/ipf/netinet/ip_ftp_pxy.c index 88c493fb4e34..1622720423d6 100644 --- a/sys/external/bsd/ipf/netinet/ip_ftp_pxy.c +++ b/sys/external/bsd/ipf/netinet/ip_ftp_pxy.c @@ -1,4 +1,4 @@ -/* $NetBSD: ip_ftp_pxy.c,v 1.4 2012/07/30 19:27:46 pgoyette Exp $ */ +/* $NetBSD: ip_ftp_pxy.c,v 1.5 2014/03/20 20:43:12 christos Exp $ */ /* * Copyright (C) 2012 by Darren Reed. @@ -12,7 +12,7 @@ */ #include -__KERNEL_RCSID(1, "$NetBSD: ip_ftp_pxy.c,v 1.4 2012/07/30 19:27:46 pgoyette Exp $"); +__KERNEL_RCSID(1, "$NetBSD: ip_ftp_pxy.c,v 1.5 2014/03/20 20:43:12 christos Exp $"); #define IPF_FTP_PROXY @@ -391,14 +391,8 @@ ipf_p_ftp_port(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat, a4 = a1 & 0xff; a1 >>= 24; olen = s - f->ftps_rptr; - /* DO NOT change this to snprintf! */ -#if defined(SNPRINTF) && defined(_KERNEL) - SNPRINTF(newbuf, sizeof(newbuf), "%s %u,%u,%u,%u,%u,%u\r\n", + snprintf(newbuf, sizeof(newbuf), "%s %u,%u,%u,%u,%u,%u\r\n", "PORT", a1, a2, a3, a4, a5, a6); -#else - (void) sprintf(newbuf, "%s %u,%u,%u,%u,%u,%u\r\n", - "PORT", a1, a2, a3, a4, a5, a6); -#endif nlen = strlen(newbuf); inc = nlen - olen; @@ -806,15 +800,9 @@ ipf_p_ftp_pasv(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat, a4 = a1 & 0xff; a1 >>= 24; -#if defined(SNPRINTF) && defined(_KERNEL) - SNPRINTF(newbuf, sizeof(newbuf), "%s %s%u,%u,%u,%u,%u,%u%s\r\n", + snprintf(newbuf, sizeof(newbuf), "%s %s%u,%u,%u,%u,%u,%u%s\r\n", "227 Entering Passive Mode", brackets[0], a1, a2, a3, a4, a5, a6, brackets[1]); -#else - (void) sprintf(newbuf, "%s %s%u,%u,%u,%u,%u,%u%s\r\n", - "227 Entering Passive Mode", brackets[0], a1, a2, a3, a4, - a5, a6, brackets[1]); -#endif return ipf_p_ftp_pasvreply(softf, fin, ip, nat, ftp, (a5 << 8 | a6), newbuf, s); } @@ -1781,20 +1769,13 @@ ipf_p_ftp_eprt4(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat, a4 = a1 & 0xff; a1 >>= 24; olen = s - f->ftps_rptr; - /* DO NOT change this to snprintf! */ /* * While we could force the use of | as a delimiter here, it makes * sense to preserve whatever character is being used by the systems * involved in the communication. */ -#if defined(SNPRINTF) && defined(_KERNEL) - SNPRINTF(newbuf, sizeof(newbuf), "%s %c1%c%u.%u.%u.%u%c%u%c\r\n", + snprintf(newbuf, sizeof(newbuf), "%s %c1%c%u.%u.%u.%u%c%u%c\r\n", "EPRT", delim, delim, a1, a2, a3, a4, delim, port, delim); -#else - (void) sprintf(newbuf, "%s %c1%c%u.%u.%u.%u%c%u%c\r\n", - "EPRT", delim, delim, a1, a2, a3, a4, delim, port, - delim); -#endif nlen = strlen(newbuf); inc = nlen - olen; @@ -1892,13 +1873,8 @@ ipf_p_ftp_epsv(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, nat_t *nat, } s += 2; -#if defined(SNPRINTF) && defined(_KERNEL) - SNPRINTF(newbuf, sizeof(newbuf), "%s (|||%u|)\r\n", + snprintf(newbuf, sizeof(newbuf), "%s (|||%u|)\r\n", "229 Entering Extended Passive Mode", ap); -#else - (void) sprintf(newbuf, "%s (|||%u|)\r\n", - "229 Entering Extended Passive Mode", ap); -#endif return ipf_p_ftp_pasvreply(softf, fin, ip, nat, ftp, (u_int)ap, newbuf, s); @@ -2038,47 +2014,26 @@ ipf_p_ftp_eprt6(ipf_ftp_softc_t *softf, fr_info_t *fin, ip_t *ip, */ s = newbuf; left = sizeof(newbuf); -#if defined(SNPRINTF) && defined(_KERNEL) - SNPRINTF(newbuf, left, "EPRT %c2%c", delim, delim); + snprintf(newbuf, left, "EPRT %c2%c", delim, delim); left -= strlen(s) + 1; s += strlen(s); a = ntohl(a6->i6[0]); - SNPRINTF(s, left, "%x:%x:", a >> 16, a & 0xffff); + snprintf(s, left, "%x:%x:", a >> 16, a & 0xffff); left -= strlen(s); s += strlen(s); a = ntohl(a6->i6[1]); - SNPRINTF(s, left, "%x:%x:", a >> 16, a & 0xffff); + snprintf(s, left, "%x:%x:", a >> 16, a & 0xffff); left -= strlen(s); s += strlen(s); a = ntohl(a6->i6[2]); - SNPRINTF(s, left, "%x:%x:", a >> 16, a & 0xffff); + snprintf(s, left, "%x:%x:", a >> 16, a & 0xffff); left -= strlen(s); s += strlen(s); a = ntohl(a6->i6[3]); - SNPRINTF(s, left, "%x:%x", a >> 16, a & 0xffff); + snprintf(s, left, "%x:%x", a >> 16, a & 0xffff); left -= strlen(s); s += strlen(s); - sprintf(s, "|%d|\r\n", port); -#else - (void) sprintf(s, "EPRT %c2%c", delim, delim); - s += strlen(s); - a = ntohl(a6->i6[0]); - sprintf(s, "%x:%x:", a >> 16, a & 0xffff); - s += strlen(s); - a = ntohl(a6->i6[1]); - sprintf(s, "%x:%x:", a >> 16, a & 0xffff); - left -= strlen(s); - s += strlen(s); - a = ntohl(a6->i6[2]); - sprintf(s, "%x:%x:", a >> 16, a & 0xffff); - left -= strlen(s); - s += strlen(s); - a = ntohl(a6->i6[3]); - sprintf(s, "%x:%x", a >> 16, a & 0xffff); - left -= strlen(s); - s += strlen(s); - sprintf(s, "|%d|\r\n", port); -#endif + snprintf(s, left, "|%d|\r\n", port); nlen = strlen(newbuf); inc = nlen - olen; if ((inc + fin->fin_plen) > 65535) { diff --git a/sys/external/bsd/ipf/netinet/ip_htable.c b/sys/external/bsd/ipf/netinet/ip_htable.c index 35b9de8eb9a7..997591a94168 100644 --- a/sys/external/bsd/ipf/netinet/ip_htable.c +++ b/sys/external/bsd/ipf/netinet/ip_htable.c @@ -1,4 +1,4 @@ -/* $NetBSD: ip_htable.c,v 1.5 2014/02/27 01:30:18 joerg Exp $ */ +/* $NetBSD: ip_htable.c,v 1.6 2014/03/20 20:43:12 christos Exp $ */ /* * Copyright (C) 2012 by Darren Reed. @@ -60,7 +60,7 @@ struct file; #if !defined(lint) #if defined(__NetBSD__) #include -__KERNEL_RCSID(0, "$NetBSD: ip_htable.c,v 1.5 2014/02/27 01:30:18 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip_htable.c,v 1.6 2014/03/20 20:43:12 christos Exp $"); #else static const char rcsid[] = "@(#)Id: ip_htable.c,v 1.1.1.2 2012/07/22 13:45:19 darrenr Exp"; #endif @@ -326,11 +326,7 @@ ipf_htable_create(ipf_main_softc_t *softc, void *arg, iplookupop_t *op) i = IPHASH_ANON; do { i++; -#if defined(SNPRINTF) && defined(_KERNEL) - SNPRINTF(name, sizeof(name), "%u", i); -#else - (void)sprintf(name, "%u", i); -#endif + snprintf(name, sizeof(name), "%u", i); for (oiph = softh->ipf_htables[unit + 1]; oiph != NULL; oiph = oiph->iph_next) if (strncmp(oiph->iph_name, name, diff --git a/sys/external/bsd/ipf/netinet/ip_irc_pxy.c b/sys/external/bsd/ipf/netinet/ip_irc_pxy.c index 437af95b2a82..03061c31243e 100644 --- a/sys/external/bsd/ipf/netinet/ip_irc_pxy.c +++ b/sys/external/bsd/ipf/netinet/ip_irc_pxy.c @@ -1,4 +1,4 @@ -/* $NetBSD: ip_irc_pxy.c,v 1.3 2012/07/22 14:27:51 darrenr Exp $ */ +/* $NetBSD: ip_irc_pxy.c,v 1.4 2014/03/20 20:43:12 christos Exp $ */ /* * Copyright (C) 2012 by Darren Reed. @@ -9,7 +9,7 @@ */ #include -__KERNEL_RCSID(1, "$NetBSD: ip_irc_pxy.c,v 1.3 2012/07/22 14:27:51 darrenr Exp $"); +__KERNEL_RCSID(1, "$NetBSD: ip_irc_pxy.c,v 1.4 2014/03/20 20:43:12 christos Exp $"); #define IPF_IRC_PROXY @@ -309,12 +309,7 @@ ipf_p_irc_send(fr_info_t *fin, nat_t *nat) i = irc->irc_addr - ctcpbuf; i++; (void) strncpy(newbuf, ctcpbuf, i); - /* DO NOT change these! */ -#if defined(SNPRINTF) && defined(KERNEL) - SNPRINTF(newbuf, sizeof(newbuf) - i, "%u %u\001\r\n", a1, a5); -#else - (void) sprintf(newbuf, "%u %u\001\r\n", a1, a5); -#endif + snprintf(newbuf, sizeof(newbuf) - i, "%u %u\001\r\n", a1, a5); nlen = strlen(newbuf); inc = nlen - olen; diff --git a/sys/external/bsd/ipf/netinet/ip_lookup.c b/sys/external/bsd/ipf/netinet/ip_lookup.c index dcef9a62c7dd..ee63f6336675 100644 --- a/sys/external/bsd/ipf/netinet/ip_lookup.c +++ b/sys/external/bsd/ipf/netinet/ip_lookup.c @@ -1,4 +1,4 @@ -/* $NetBSD: ip_lookup.c,v 1.3 2012/07/22 14:27:51 darrenr Exp $ */ +/* $NetBSD: ip_lookup.c,v 1.4 2014/03/20 20:43:12 christos Exp $ */ /* * Copyright (C) 2012 by Darren Reed. @@ -68,7 +68,7 @@ struct file; #if !defined(lint) #if defined(__NetBSD__) #include -__KERNEL_RCSID(0, "$NetBSD: ip_lookup.c,v 1.3 2012/07/22 14:27:51 darrenr Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip_lookup.c,v 1.4 2014/03/20 20:43:12 christos Exp $"); #else static const char rcsid[] = "@(#)Id: ip_lookup.c,v 1.1.1.2 2012/07/22 13:45:21 darrenr Exp"; #endif @@ -818,11 +818,7 @@ ipf_lookup_res_num(ipf_main_softc_t *softc, int unit, u_int type, u_int number, { char name[FR_GROUPLEN]; -#if defined(SNPRINTF) && defined(_KERNEL) - SNPRINTF(name, sizeof(name), "%u", number); -#else - (void) sprintf(name, "%u", number); -#endif + snprintf(name, sizeof(name), "%u", number); return ipf_lookup_res_name(softc, unit, type, name, funcptr); } diff --git a/sys/external/bsd/ipf/netinet/ip_pool.c b/sys/external/bsd/ipf/netinet/ip_pool.c index 776cda9cfb22..03d2ff5b3de5 100644 --- a/sys/external/bsd/ipf/netinet/ip_pool.c +++ b/sys/external/bsd/ipf/netinet/ip_pool.c @@ -1,4 +1,4 @@ -/* $NetBSD: ip_pool.c,v 1.3 2012/07/22 14:27:51 darrenr Exp $ */ +/* $NetBSD: ip_pool.c,v 1.4 2014/03/20 20:43:12 christos Exp $ */ /* * Copyright (C) 2012 by Darren Reed. @@ -72,7 +72,7 @@ struct file; #if !defined(lint) #if defined(__NetBSD__) #include -__KERNEL_RCSID(0, "$NetBSD: ip_pool.c,v 1.3 2012/07/22 14:27:51 darrenr Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip_pool.c,v 1.4 2014/03/20 20:43:12 christos Exp $"); #else static const char sccsid[] = "@(#)ip_fil.c 2.41 6/5/96 (C) 1993-2000 Darren Reed"; static const char rcsid[] = "@(#)Id: ip_pool.c,v 1.1.1.2 2012/07/22 13:45:31 darrenr Exp"; @@ -955,21 +955,13 @@ ipf_pool_create(ipf_main_softc_t *softc, ipf_pool_softc_t *softp, h->ipo_flags |= IPOOL_ANON; poolnum = LOOKUP_ANON; -#if defined(SNPRINTF) && defined(_KERNEL) - SNPRINTF(name, sizeof(name), "%x", poolnum); -#else - (void)sprintf(name, "%x", poolnum); -#endif + snprintf(name, sizeof(name), "%x", poolnum); for (p = softp->ipf_pool_list[unit + 1]; p != NULL; ) { if (strncmp(name, p->ipo_name, sizeof(p->ipo_name)) == 0) { poolnum++; -#if defined(SNPRINTF) && defined(_KERNEL) - SNPRINTF(name, sizeof(name), "%x", poolnum); -#else - (void)sprintf(name, "%x", poolnum); -#endif + snprintf(name, sizeof(name), "%x", poolnum); p = softp->ipf_pool_list[unit + 1]; } else p = p->ipo_next; diff --git a/sys/external/bsd/ipf/netinet/ip_rpcb_pxy.c b/sys/external/bsd/ipf/netinet/ip_rpcb_pxy.c index 9929193d9811..8dda767e7c27 100644 --- a/sys/external/bsd/ipf/netinet/ip_rpcb_pxy.c +++ b/sys/external/bsd/ipf/netinet/ip_rpcb_pxy.c @@ -1,4 +1,4 @@ -/* $NetBSD: ip_rpcb_pxy.c,v 1.3 2012/07/22 14:27:51 darrenr Exp $ */ +/* $NetBSD: ip_rpcb_pxy.c,v 1.4 2014/03/20 20:43:12 christos Exp $ */ /* * Copyright (C) 2002-2012 by Ryan Beasley @@ -43,7 +43,7 @@ */ #include -__KERNEL_RCSID(1, "$NetBSD: ip_rpcb_pxy.c,v 1.3 2012/07/22 14:27:51 darrenr Exp $"); +__KERNEL_RCSID(1, "$NetBSD: ip_rpcb_pxy.c,v 1.4 2014/03/20 20:43:12 christos Exp $"); #define IPF_RPCB_PROXY @@ -760,15 +760,9 @@ ipf_p_rpcb_modreq(fr_info_t *fin, nat_t *nat, rpc_msg_t *rm, mb_t *m, u_int off) /* Form new string. */ bzero(uaddr, sizeof(uaddr)); /* Just in case we need padding. */ -#if defined(SNPRINTF) && defined(_KERNEL) - SNPRINTF(uaddr, sizeof(uaddr), + snprintf(uaddr, sizeof(uaddr), "%u.%u.%u.%u.%u.%u", i[0] & 0xff, i[1] & 0xff, i[2] & 0xff, i[3] & 0xff, p[0] & 0xff, p[1] & 0xff); -#else - (void) sprintf(uaddr, - "%u.%u.%u.%u.%u.%u", i[0] & 0xff, i[1] & 0xff, - i[2] & 0xff, i[3] & 0xff, p[0] & 0xff, p[1] & 0xff); -#endif len = strlen(uaddr); xlen = XDRALIGN(len); @@ -1279,15 +1273,9 @@ ipf_p_rpcb_modv3(fr_info_t *fin, nat_t *nat, rpc_msg_t *rm, mb_t *m, u_int off) /* Form new string. */ bzero(uaddr, sizeof(uaddr)); /* Just in case we need padding. */ -#if defined(SNPRINTF) && defined(_KERNEL) - SNPRINTF(uaddr, sizeof(uaddr), + snprintf(uaddr, sizeof(uaddr), "%u.%u.%u.%u.%u.%u", i[0] & 0xff, i[1] & 0xff, i[2] & 0xff, i[3] & 0xff, p[0] & 0xff, p[1] & 0xff); -#else - (void) sprintf(uaddr, - "%u.%u.%u.%u.%u.%u", i[0] & 0xff, i[1] & 0xff, - i[2] & 0xff, i[3] & 0xff, p[0] & 0xff, p[1] & 0xff); -#endif len = strlen(uaddr); xlen = XDRALIGN(len); @@ -1356,17 +1344,10 @@ ipf_p_rpcb_modv4(fr_info_t *fin, nat_t *nat, rpc_msg_t *rm, mb_t *m, u_int off) /* Form new string. */ bzero(uaddr, sizeof(uaddr)); /* Just in case we need padding. */ -#if defined(SNPRINTF) && defined(_KERNEL) - SNPRINTF(uaddr, sizeof(uaddr), + snprintf(uaddr, sizeof(uaddr), "%u.%u.%u.%u.%u.%u", i[0] & 0xff, i[1] & 0xff, i[2] & 0xff, i[3] & 0xff, p[0] & 0xff, p[1] & 0xff); -#else - (void) sprintf(uaddr, - "%u.%u.%u.%u.%u.%u", i[0] & 0xff, - i[1] & 0xff, i[2] & 0xff, i[3] & 0xff, - p[0] & 0xff, p[1] & 0xff); -#endif len = strlen(uaddr); xlen = XDRALIGN(len); diff --git a/sys/external/bsd/ipf/netinet/radix_ipf.c b/sys/external/bsd/ipf/netinet/radix_ipf.c index 5f7608c50546..8c3f3f2d8d89 100644 --- a/sys/external/bsd/ipf/netinet/radix_ipf.c +++ b/sys/external/bsd/ipf/netinet/radix_ipf.c @@ -1,4 +1,4 @@ -/* $NetBSD: radix_ipf.c,v 1.4 2013/09/15 09:38:28 martin Exp $ */ +/* $NetBSD: radix_ipf.c,v 1.5 2014/03/20 20:43:12 christos Exp $ */ /* * Copyright (C) 2012 by Darren Reed. @@ -1393,11 +1393,11 @@ add_addr(rnh, n, item) setmask(&stp->mask, ttable[item].mask); stp->next = myst_top; myst_top = stp; - (void) sprintf(rn[0].name, "_BORN.0"); - (void) sprintf(rn[1].name, "_BORN.1"); + (void) snprintf(rn[0].name, sizeof(rn[0].name), "_BORN.0"); + (void) snprintf(rn[1].name, sizeof(rn[1].name), "_BORN.1"); rn = ipf_rx_addroute(rnh, &stp->dst, &stp->mask, stp->nodes); - (void) sprintf(rn[0].name, "%d_NODE.0", item); - (void) sprintf(rn[1].name, "%d_NODE.1", item); + (void) snprintf(rn[0].name, sizeof(rn[0].name), "%d_NODE.0", item); + (void) snprintf(rn[1].name, sizeof(rn[1].name), "%d_NODE.1", item); printf("ADD %d/%d %s/%s\n", n, item, rn[0].name, rn[1].name); nodecount++; checktree(rnh); diff --git a/sys/lib/libsa/bootp.c b/sys/lib/libsa/bootp.c index c7c9afebd98b..ce27102f9a71 100644 --- a/sys/lib/libsa/bootp.c +++ b/sys/lib/libsa/bootp.c @@ -1,4 +1,4 @@ -/* $NetBSD: bootp.c,v 1.38 2011/05/11 16:23:40 zoltan Exp $ */ +/* $NetBSD: bootp.c,v 1.39 2014/03/20 20:42:37 christos Exp $ */ /* * Copyright (c) 1992 Regents of the University of California. @@ -106,7 +106,7 @@ bootp_addvend(u_char *area) *area++ = TAG_SWAPSERVER; /* Insert a NetBSD Vendor Class Identifier option. */ - sprintf(vci, "NetBSD:%s:libsa", MACHINE); + snprintf(vci, sizeof(vci), "NetBSD:%s:libsa", MACHINE); vcilen = strlen(vci); *area++ = TAG_CLASSID; *area++ = vcilen; diff --git a/sys/rump/dev/lib/libugenhc/ugenhc.c b/sys/rump/dev/lib/libugenhc/ugenhc.c index 1c935230fdd0..3de6ce5ca497 100644 --- a/sys/rump/dev/lib/libugenhc/ugenhc.c +++ b/sys/rump/dev/lib/libugenhc/ugenhc.c @@ -1,4 +1,4 @@ -/* $NetBSD: ugenhc.c,v 1.17 2014/03/13 01:38:11 pooka Exp $ */ +/* $NetBSD: ugenhc.c,v 1.18 2014/03/20 20:42:08 christos Exp $ */ /* * Copyright (c) 2009, 2010 Antti Kantee. All Rights Reserved. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ugenhc.c,v 1.17 2014/03/13 01:38:11 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ugenhc.c,v 1.18 2014/03/20 20:42:08 christos Exp $"); #include #include @@ -120,11 +120,11 @@ struct rusb_xfer { #define UGENDEV_BASESTR "/dev/ugen" #define UGENDEV_BUFSIZE 32 static void -makeugendevstr(int devnum, int endpoint, char *buf) +makeugendevstr(int devnum, int endpoint, char *buf, size_t len) { CTASSERT(UGENDEV_BUFSIZE > sizeof(UGENDEV_BASESTR)+sizeof("0.00")+1); - sprintf(buf, "%s%d.%02d", UGENDEV_BASESTR, devnum, endpoint); + snprintf(buf, len, "%s%d.%02d", UGENDEV_BASESTR, devnum, endpoint); } /* @@ -596,7 +596,7 @@ rhscintr(void *arg) usbd_xfer_handle xfer; int fd, error; - makeugendevstr(sc->sc_devnum, 0, buf); + makeugendevstr(sc->sc_devnum, 0, buf, sizeof(buf)); for (;;) { /* @@ -969,7 +969,7 @@ ugenhc_open(struct usbd_pipe *pipe) oflags = O_RDWR; } - makeugendevstr(sc->sc_devnum, endpt, buf); + makeugendevstr(sc->sc_devnum, endpt, buf, sizeof(buf)); /* XXX: theoretically should convert oflags */ error = rumpuser_open(buf, oflags, &fd); if (error != 0) { @@ -1057,7 +1057,7 @@ ugenhc_probe(device_t parent, cfdata_t match, void *aux) { char buf[UGENDEV_BUFSIZE]; - makeugendevstr(match->cf_unit, 0, buf); + makeugendevstr(match->cf_unit, 0, buf, sizeof(buf)); if (rumpuser_getfileinfo(buf, NULL, NULL) != 0) return 0; diff --git a/sys/rump/librump/rumpkern/rump.c b/sys/rump/librump/rumpkern/rump.c index 6f7f8555dbab..285dd0f437f2 100644 --- a/sys/rump/librump/rumpkern/rump.c +++ b/sys/rump/librump/rumpkern/rump.c @@ -1,4 +1,4 @@ -/* $NetBSD: rump.c,v 1.290 2014/03/15 15:15:27 pooka Exp $ */ +/* $NetBSD: rump.c,v 1.291 2014/03/20 20:42:08 christos Exp $ */ /* * Copyright (c) 2007-2011 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.290 2014/03/15 15:15:27 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.291 2014/03/20 20:42:08 christos Exp $"); #include #define ELFSIZE ARCH_ELFSIZE @@ -512,7 +512,8 @@ rump_init(void) #undef CPFX #undef CPFXLEN } else { - sprintf(buf, "rumpns_sys_%s", syscallnames[i]); + snprintf(buf, sizeof(buf), "rumpns_sys_%s", + syscallnames[i]); } if ((sym = rumpuser_dl_globalsym(buf)) != NULL && sym != rump_sysent[i].sy_call) { diff --git a/sys/rump/librump/rumpvfs/devnodes.c b/sys/rump/librump/rumpvfs/devnodes.c index 23c503ce9e06..8c3771976940 100644 --- a/sys/rump/librump/rumpvfs/devnodes.c +++ b/sys/rump/librump/rumpvfs/devnodes.c @@ -1,4 +1,4 @@ -/* $NetBSD: devnodes.c,v 1.8 2013/03/07 22:12:34 pooka Exp $ */ +/* $NetBSD: devnodes.c,v 1.9 2014/03/20 20:42:08 christos Exp $ */ /* * Copyright (c) 2009 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: devnodes.c,v 1.8 2013/03/07 22:12:34 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: devnodes.c,v 1.9 2014/03/20 20:42:08 christos Exp $"); #include #include @@ -110,8 +110,8 @@ doesitexist(const char *path, bool isblk, devmajor_t dmaj, devminor_t dmin) } static void -makeonenode(char *buf, devmajor_t blk, devmajor_t chr, devminor_t dmin, - const char *base, int c1, int c2) +makeonenode(char *buf, size_t len, devmajor_t blk, devmajor_t chr, + devminor_t dmin, const char *base, int c1, int c2) { char cstr1[2] = {0,0}, cstr2[2] = {0,0}; register_t rv; @@ -129,7 +129,7 @@ makeonenode(char *buf, devmajor_t blk, devmajor_t chr, devminor_t dmin, } /* block device */ - snprintf(buf, MAXPATHLEN, "/dev/%s%s%s", base, cstr1, cstr2); + snprintf(buf, len, "/dev/%s%s%s", base, cstr1, cstr2); if (blk != NODEVMAJOR) { switch (doesitexist(buf, true, blk, dmin)) { case DIFFERENT: @@ -146,7 +146,7 @@ makeonenode(char *buf, devmajor_t blk, devmajor_t chr, devminor_t dmin, /* done */ break; } - sprintf(buf, "/dev/r%s%s%s", base, cstr1, cstr2); + snprintf(buf, len, "/dev/r%s%s%s", base, cstr1, cstr2); } switch (doesitexist(buf, true, chr, dmin)) { @@ -190,20 +190,20 @@ rump_vfs_builddevs(struct devsw_conv *dcvec, size_t dcvecsize) } else { themin = 0; } - makeonenode(pnbuf, + makeonenode(pnbuf, MAXPATHLEN, dc->d_bmajor, dc->d_cmajor, themin, dc->d_name, -1, -1); break; case DEVNODE_VECTOR: for (v1 = 0; v1 < dc->d_vectdim[0]; v1++) { if (dc->d_vectdim[1] == 0) { - makeonenode(pnbuf, + makeonenode(pnbuf, MAXPATHLEN, dc->d_bmajor, dc->d_cmajor, v1, dc->d_name, v1, -1); } else { for (v2 = 0; v2 < dc->d_vectdim[1]; v2++) { - makeonenode(pnbuf, + makeonenode(pnbuf, MAXPATHLEN, dc->d_bmajor, dc->d_cmajor, v1 * dc->d_vectdim[1] + v2, dc->d_name, v1, v2); @@ -217,8 +217,8 @@ rump_vfs_builddevs(struct devsw_conv *dcvec, size_t dcvecsize) * ok, so we cheat a bit since * symlink isn't supported on rumpfs ... */ - makeonenode(pnbuf, -1, dc->d_cmajor, 0, - dc->d_name, -1, -1); + makeonenode(pnbuf, MAXPATHLEN, + -1, dc->d_cmajor, 0, dc->d_name, -1, -1); } break; diff --git a/sys/rump/net/lib/libshmif/if_shmem.c b/sys/rump/net/lib/libshmif/if_shmem.c index a64722a7096e..4c58d1d37029 100644 --- a/sys/rump/net/lib/libshmif/if_shmem.c +++ b/sys/rump/net/lib/libshmif/if_shmem.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_shmem.c,v 1.59 2014/03/13 01:42:59 pooka Exp $ */ +/* $NetBSD: if_shmem.c,v 1.60 2014/03/20 20:42:08 christos Exp $ */ /* * Copyright (c) 2009, 2010 Antti Kantee. All Rights Reserved. @@ -28,7 +28,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_shmem.c,v 1.59 2014/03/13 01:42:59 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_shmem.c,v 1.60 2014/03/20 20:42:08 christos Exp $"); #include #include @@ -170,7 +170,7 @@ allocif(int unit, struct shmif_sc **scp) ifp = &sc->sc_ec.ec_if; - sprintf(ifp->if_xname, "shmif%d", unit); + snprintf(ifp->if_xname, sizeof(ifp->if_xname), "shmif%d", unit); ifp->if_softc = sc; ifp->if_flags = IFF_BROADCAST | IFF_MULTICAST; ifp->if_init = shmif_init; diff --git a/sys/rump/net/lib/libvirtif/if_virt.c b/sys/rump/net/lib/libvirtif/if_virt.c index 356d0cd7183e..14530b2bb8cc 100644 --- a/sys/rump/net/lib/libvirtif/if_virt.c +++ b/sys/rump/net/lib/libvirtif/if_virt.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_virt.c,v 1.45 2014/03/18 18:10:08 pooka Exp $ */ +/* $NetBSD: if_virt.c,v 1.46 2014/03/20 20:42:08 christos Exp $ */ /* * Copyright (c) 2008, 2013 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_virt.c,v 1.45 2014/03/18 18:10:08 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_virt.c,v 1.46 2014/03/20 20:42:08 christos Exp $"); #include #include @@ -109,7 +109,7 @@ virtif_clone(struct if_clone *ifc, int num) sc = kmem_zalloc(sizeof(*sc), KM_SLEEP); sc->sc_num = num; ifp = &sc->sc_ec.ec_if; - sprintf(ifp->if_xname, "%s%d", VIF_NAME, num); + snprintf(ifp->if_xname, sizeof(ifp->if_xname), "%s%d", VIF_NAME, num); ifp->if_softc = sc; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;