Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src - enlarge buffer to avoid snprintf() truncation
details: https://anonhg.NetBSD.org/src/rev/657cfc0d9fad
branches: trunk
changeset: 448441:657cfc0d9fad
user: mrg <mrg%NetBSD.org@localhost>
date: Sun Feb 03 10:48:46 2019 +0000
description:
- enlarge buffer to avoid snprintf() truncation
diffstat:
dist/pf/sbin/pfctl/pfctl_osfp.c | 4 ++--
dist/pf/sbin/pflogd/privsep.c | 5 ++++-
external/bsd/ntp/dist/ntpd/ntp_control.c | 6 +++++-
external/bsd/ntp/dist/ntpd/refclock_jjy.c | 14 +++++++-------
external/bsd/ntp/dist/ntpd/refclock_neoclock4x.c | 10 +++++-----
external/bsd/ntp/dist/ntpd/refclock_oncore.c | 6 +++---
external/bsd/ntp/dist/sntp/libopts/usage.c | 4 ++--
games/cribbage/score.c | 6 +++---
games/hack/hack.unix.c | 6 +++---
games/sail/dr_2.c | 6 +++---
tests/kernel/gen_t_subr_prf | 2 +-
tests/lib/libc/net/getaddrinfo/h_gai.c | 4 ++--
tests/lib/libc/stdlib/t_atoi.c | 6 +++---
usr.bin/rusers/rusers.c | 6 +++---
usr.bin/systat/ps.c | 6 +++---
usr.sbin/cpuctl/arch/arm.c | 6 +++---
usr.sbin/sysinst/disks.c | 4 ++--
17 files changed, 54 insertions(+), 47 deletions(-)
diffs (truncated from 452 to 300 lines):
diff -r 664b1e699822 -r 657cfc0d9fad dist/pf/sbin/pfctl/pfctl_osfp.c
--- a/dist/pf/sbin/pfctl/pfctl_osfp.c Sun Feb 03 10:45:58 2019 +0000
+++ b/dist/pf/sbin/pfctl/pfctl_osfp.c Sun Feb 03 10:48:46 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pfctl_osfp.c,v 1.7 2008/06/18 09:06:26 yamt Exp $ */
+/* $NetBSD: pfctl_osfp.c,v 1.8 2019/02/03 10:48:47 mrg Exp $ */
/* $OpenBSD: pfctl_osfp.c,v 1.15 2006/12/13 05:10:15 itojun Exp $ */
/*
@@ -724,7 +724,7 @@
void
print_name_list(int opts, struct name_list *nml, const char *prefix)
{
- char newprefix[32];
+ char newprefix[33];
struct name_entry *nm;
LIST_FOREACH(nm, nml, nm_entry) {
diff -r 664b1e699822 -r 657cfc0d9fad dist/pf/sbin/pflogd/privsep.c
--- a/dist/pf/sbin/pflogd/privsep.c Sun Feb 03 10:45:58 2019 +0000
+++ b/dist/pf/sbin/pflogd/privsep.c Sun Feb 03 10:48:46 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: privsep.c,v 1.7 2010/12/13 01:45:39 christos Exp $ */
+/* $NetBSD: privsep.c,v 1.8 2019/02/03 10:48:47 mrg Exp $ */
/* $OpenBSD: privsep.c,v 1.16 2006/10/25 20:55:04 moritz Exp $ */
/*
@@ -332,6 +332,7 @@
case -1:
if (errno == EINTR || errno == EAGAIN)
continue;
+ /* FALLTHROUGH */
case 0:
return (1);
default:
@@ -355,6 +356,7 @@
case -1:
if (errno == EINTR || errno == EAGAIN)
continue;
+ /* FALLTHROUGH */
case 0:
_exit(0);
default:
@@ -377,6 +379,7 @@
case -1:
if (errno == EINTR || errno == EAGAIN)
continue;
+ /* FALLTHROUGH */
case 0:
_exit(0);
default:
diff -r 664b1e699822 -r 657cfc0d9fad external/bsd/ntp/dist/ntpd/ntp_control.c
--- a/external/bsd/ntp/dist/ntpd/ntp_control.c Sun Feb 03 10:45:58 2019 +0000
+++ b/external/bsd/ntp/dist/ntpd/ntp_control.c Sun Feb 03 10:48:46 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ntp_control.c,v 1.21 2018/09/29 21:52:33 christos Exp $ */
+/* $NetBSD: ntp_control.c,v 1.22 2019/02/03 10:48:47 mrg Exp $ */
/*
* ntp_control.c - respond to mode 6 control messages and send async
@@ -1900,7 +1900,11 @@
)
{
l_fp tmp;
+#ifndef HAVE_UNAME
char str[256];
+#else
+ char str[sizeof utsnamebuf.sysname + sizeof utsnamebuf.release];
+#endif
u_int u;
double kb;
double dtemp;
diff -r 664b1e699822 -r 657cfc0d9fad external/bsd/ntp/dist/ntpd/refclock_jjy.c
--- a/external/bsd/ntp/dist/ntpd/refclock_jjy.c Sun Feb 03 10:45:58 2019 +0000
+++ b/external/bsd/ntp/dist/ntpd/refclock_jjy.c Sun Feb 03 10:48:46 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: refclock_jjy.c,v 1.13 2018/04/07 00:19:53 christos Exp $ */
+/* $NetBSD: refclock_jjy.c,v 1.14 2019/02/03 10:48:47 mrg Exp $ */
/*
* refclock_jjy - clock driver for JJY receivers
@@ -1012,7 +1012,7 @@
jjy_synctime ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
{
- char sLog [ 80 ], cStatus ;
+ char sLog [ 192 ], cStatus ;
const char *pStatus ;
pp->year = up->year ;
@@ -1167,7 +1167,7 @@
struct peer *peer;
char * pBuf ;
- char sLog [ 100 ] ;
+ char sLog [ 192 ] ;
int iLen ;
int rc ;
@@ -1463,7 +1463,7 @@
struct refclockproc *pp ;
struct peer *peer ;
- char *pBuf, sLog [ 100 ] ;
+ char *pBuf, sLog [ 192 ] ;
int iLen ;
int rc ;
@@ -2346,7 +2346,7 @@
struct refclockproc *pp ;
struct jjyunit *up ;
- char *pBuf, sLog [ 100 ] ;
+ char *pBuf, sLog [ 192 ] ;
int iLen, i ;
int rc, iWeekday ;
time_t now ;
@@ -2695,7 +2695,7 @@
jjy_start_telephone ( int unit, struct peer *peer, struct jjyunit *up )
{
- char sLog [ 80 ], sFirstThreeDigits [ 4 ] ;
+ char sLog [ 192 ], sFirstThreeDigits [ 4 ] ;
int iNumberOfDigitsOfPhoneNumber, iCommaCount, iCommaPosition ;
size_t i ;
size_t iFirstThreeDigitsCount ;
@@ -3404,7 +3404,7 @@
char *pBuf ;
int iLen, rc ;
- char sLog [ 80 ] ;
+ char sLog [ 192 ] ;
char bAdjustment ;
diff -r 664b1e699822 -r 657cfc0d9fad external/bsd/ntp/dist/ntpd/refclock_neoclock4x.c
--- a/external/bsd/ntp/dist/ntpd/refclock_neoclock4x.c Sun Feb 03 10:45:58 2019 +0000
+++ b/external/bsd/ntp/dist/ntpd/refclock_neoclock4x.c Sun Feb 03 10:48:46 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: refclock_neoclock4x.c,v 1.9 2016/01/08 21:35:39 christos Exp $ */
+/* $NetBSD: refclock_neoclock4x.c,v 1.10 2019/02/03 10:48:47 mrg Exp $ */
/*
*
@@ -727,7 +727,7 @@
if(NULL != out)
{
char *tt;
- char tmpbuf[80];
+ char tmpbuf[199];
out->kv_list = (struct ctl_var *)0;
out->type = REFCLK_NEOCLOCK4X;
@@ -768,13 +768,13 @@
else
snprintf(tt, 39, "dststatus=\"unknown\"");
tt = add_var(&out->kv_list, 80, RO|DEF);
- snprintf(tt, 79, "firmware=\"%s\"", up->firmware);
+ snprintf(tt, 99, "firmware=\"%s\"", up->firmware);
tt = add_var(&out->kv_list, 40, RO|DEF);
snprintf(tt, 39, "firmwaretag=\"%c\"", up->firmwaretag);
tt = add_var(&out->kv_list, 80, RO|DEF);
- snprintf(tt, 79, "driver version=\"%s\"", NEOCLOCK4X_DRIVER_VERSION);
+ snprintf(tt, 99, "driver version=\"%s\"", NEOCLOCK4X_DRIVER_VERSION);
tt = add_var(&out->kv_list, 80, RO|DEF);
- snprintf(tt, 79, "serialnumber=\"%s\"", up->serial);
+ snprintf(tt, 99, "serialnumber=\"%s\"", up->serial);
}
}
diff -r 664b1e699822 -r 657cfc0d9fad external/bsd/ntp/dist/ntpd/refclock_oncore.c
--- a/external/bsd/ntp/dist/ntpd/refclock_oncore.c Sun Feb 03 10:45:58 2019 +0000
+++ b/external/bsd/ntp/dist/ntpd/refclock_oncore.c Sun Feb 03 10:48:46 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: refclock_oncore.c,v 1.15 2018/02/04 09:15:45 mrg Exp $ */
+/* $NetBSD: refclock_oncore.c,v 1.16 2019/02/03 10:48:47 mrg Exp $ */
/*
* ----------------------------------------------------------------------------
@@ -1804,7 +1804,7 @@
Rsm = ((instance->BEHa[129]<<8) | instance->BEHa[130]);
if (instance->chan == 6 || instance->chan == 8) {
- char f1[5], f2[5], f3[5], f4[5];
+ char f1[6], f2[6], f3[6], f4[6];
if (instance->traim) {
snprintf(f1, sizeof(f1), "%d",
instance->BEHn[21]);
@@ -1837,7 +1837,7 @@
instance->BEHa[57], instance->BEHa[61], instance->BEHa[65], instance->BEHa[69]
); /* will be 0 for 6 chan */
} else if (instance->chan == 12) {
- char f1[5], f2[5], f3[5], f4[5];
+ char f1[6], f2[6], f3[6], f4[6];
if (instance->traim) {
snprintf(f1, sizeof(f1), "%d",
instance->BEHn[6]);
diff -r 664b1e699822 -r 657cfc0d9fad external/bsd/ntp/dist/sntp/libopts/usage.c
--- a/external/bsd/ntp/dist/sntp/libopts/usage.c Sun Feb 03 10:45:58 2019 +0000
+++ b/external/bsd/ntp/dist/sntp/libopts/usage.c Sun Feb 03 10:48:46 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: usage.c,v 1.6 2016/01/08 21:35:41 christos Exp $ */
+/* $NetBSD: usage.c,v 1.7 2019/02/03 10:48:47 mrg Exp $ */
/*
@@ -764,7 +764,7 @@
OPTST_NO_USAGE_MASK | OPTST_DOCUMENT;
static char const vfmtfmt[] = "%%-%us %%s\n";
- char vfmt[sizeof(vfmtfmt)];
+ char vfmt[sizeof(vfmtfmt)+10]; /* strlen(UINT_MAX) */
/*
* Only handle client specified options. The "vendor option" follows
diff -r 664b1e699822 -r 657cfc0d9fad games/cribbage/score.c
--- a/games/cribbage/score.c Sun Feb 03 10:45:58 2019 +0000
+++ b/games/cribbage/score.c Sun Feb 03 10:48:46 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: score.c,v 1.16 2012/10/13 20:36:06 dholland Exp $ */
+/* $NetBSD: score.c,v 1.17 2019/02/03 10:48:46 mrg Exp $ */
/*-
* Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)score.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: score.c,v 1.16 2012/10/13 20:36:06 dholland Exp $");
+__RCSID("$NetBSD: score.c,v 1.17 2019/02/03 10:48:46 mrg Exp $");
#endif
#endif /* not lint */
@@ -115,7 +115,7 @@
int hscore;
BOOLEAN flag;
CARD h[(CINHAND + 1)];
- char buf[32];
+ char buf[52];
explan[0] = '\0'; /* initialize explanation */
hscore = 0;
diff -r 664b1e699822 -r 657cfc0d9fad games/hack/hack.unix.c
--- a/games/hack/hack.unix.c Sun Feb 03 10:45:58 2019 +0000
+++ b/games/hack/hack.unix.c Sun Feb 03 10:48:46 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hack.unix.c,v 1.17 2011/09/01 07:18:50 plunky Exp $ */
+/* $NetBSD: hack.unix.c,v 1.18 2019/02/03 10:48:46 mrg Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -63,7 +63,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hack.unix.c,v 1.17 2011/09/01 07:18:50 plunky Exp $");
+__RCSID("$NetBSD: hack.unix.c,v 1.18 2019/02/03 10:48:46 mrg Exp $");
#endif /* not lint */
/* This file collects some Unix dependencies; hack.pager.c contains some more */
@@ -123,7 +123,7 @@
char *
getdatestr(void)
{
- static char datestr[7];
+ static char datestr[32];
struct tm *lt = getlt();
(void) snprintf(datestr, sizeof(datestr), "%02d%02d%02d",
diff -r 664b1e699822 -r 657cfc0d9fad games/sail/dr_2.c
--- a/games/sail/dr_2.c Sun Feb 03 10:45:58 2019 +0000
+++ b/games/sail/dr_2.c Sun Feb 03 10:48:46 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dr_2.c,v 1.26 2014/03/28 17:53:47 apb Exp $ */
+/* $NetBSD: dr_2.c,v 1.27 2019/02/03 10:48:46 mrg Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)dr_2.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: dr_2.c,v 1.26 2014/03/28 17:53:47 apb Exp $");
+__RCSID("$NetBSD: dr_2.c,v 1.27 2019/02/03 10:48:46 mrg Exp $");
#endif
#endif /* not lint */
@@ -252,7 +252,7 @@
int ma, int ta, bool af, int vma, int dir, int *high, int rakeme)
{
int new, n;
- char st[4];
+ char st[11];
#define rakeyou (gunsbear(f, t) && !gunsbear(t, f))
if ((n = str_end(temp)) < '1' || n > '9')
diff -r 664b1e699822 -r 657cfc0d9fad tests/kernel/gen_t_subr_prf
--- a/tests/kernel/gen_t_subr_prf Sun Feb 03 10:45:58 2019 +0000
+++ b/tests/kernel/gen_t_subr_prf Sun Feb 03 10:48:46 2019 +0000
@@ -58,7 +58,7 @@
Home |
Main Index |
Thread Index |
Old Index