- enlarge buffer to avoid snprintf() truncation

This commit is contained in:
mrg 2019-02-03 10:48:46 +00:00
parent 770680b518
commit 37649e4074
17 changed files with 54 additions and 47 deletions

View File

@ -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 @@ fingerprint_name_entry(struct name_list *list, char *name)
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) {

View File

@ -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 @@ may_read(int fd, void *buf, size_t n)
case -1:
if (errno == EINTR || errno == EAGAIN)
continue;
/* FALLTHROUGH */
case 0:
return (1);
default:
@ -355,6 +356,7 @@ must_read(int fd, void *buf, size_t n)
case -1:
if (errno == EINTR || errno == EAGAIN)
continue;
/* FALLTHROUGH */
case 0:
_exit(0);
default:
@ -377,6 +379,7 @@ must_write(int fd, void *buf, size_t n)
case -1:
if (errno == EINTR || errno == EAGAIN)
continue;
/* FALLTHROUGH */
case 0:
_exit(0);
default:

View File

@ -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 @@ ctl_putsys(
)
{
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;

View File

@ -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 @@ static void
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 @@ jjy_receive_tristate_jjy01 ( struct recvbuf *rbufp )
struct peer *peer;
char * pBuf ;
char sLog [ 100 ] ;
char sLog [ 192 ] ;
int iLen ;
int rc ;
@ -1463,7 +1463,7 @@ jjy_receive_cdex_jst2000 ( struct recvbuf *rbufp )
struct refclockproc *pp ;
struct peer *peer ;
char *pBuf, sLog [ 100 ] ;
char *pBuf, sLog [ 192 ] ;
int iLen ;
int rc ;
@ -2346,7 +2346,7 @@ jjy_receive_seiko_tsys_tdc_300 ( struct recvbuf *rbufp )
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 @@ static int
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 @@ teljjy_conn_data ( struct peer *peer, struct refclockproc *pp, struct jjyunit *u
char *pBuf ;
int iLen, rc ;
char sLog [ 80 ] ;
char sLog [ 192 ] ;
char bAdjustment ;

View File

@ -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 @@ neoclock4x_control(int unit,
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 @@ neoclock4x_control(int unit,
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);
}
}

View File

@ -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 @@ oncore_get_timestamp(
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 @@ oncore_get_timestamp(
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]);

View File

@ -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 @@ prt_vendor_opts(tOptions * opts, char const * title)
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

View File

@ -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 @@ scorehand(const CARD hand[], CARD starter, int n, BOOLEAN crb,
int hscore;
BOOLEAN flag;
CARD h[(CINHAND + 1)];
char buf[32];
char buf[52];
explan[0] = '\0'; /* initialize explanation */
hscore = 0;

View File

@ -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 @@ getyear(void)
char *
getdatestr(void)
{
static char datestr[7];
static char datestr[32];
struct tm *lt = getlt();
(void) snprintf(datestr, sizeof(datestr), "%02d%02d%02d",

View File

@ -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 @@ try(struct ship *f, struct ship *t,
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')

View File

@ -58,7 +58,7 @@ ATF_TC_HEAD(snprintf_print, tc)
ATF_TC_BODY(snprintf_print, tc)
{
char buf[10];
char buf[13];
int i;
memset(buf, 'x', sizeof(buf));

View File

@ -1,4 +1,4 @@
/* $NetBSD: h_gai.c,v 1.1 2011/01/12 02:58:40 pgoyette Exp $ */
/* $NetBSD: h_gai.c,v 1.2 2019/02/03 10:48:47 mrg Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, and 2002 WIDE Project.
@ -111,7 +111,7 @@ main(int argc, char *argv[])
extern int optind;
extern char *optarg;
int c;
char nbuf[10];
char nbuf[14];
memset(&ai, 0, sizeof(ai));
ai.ai_family = PF_UNSPEC;

View File

@ -1,4 +1,4 @@
/* $NetBSD: t_atoi.c,v 1.2 2012/03/29 05:56:36 jruoho Exp $ */
/* $NetBSD: t_atoi.c,v 1.3 2019/02/03 10:48:46 mrg Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: t_atoi.c,v 1.2 2012/03/29 05:56:36 jruoho Exp $");
__RCSID("$NetBSD: t_atoi.c,v 1.3 2019/02/03 10:48:46 mrg Exp $");
#include <atf-c.h>
#include <float.h>
@ -46,7 +46,7 @@ ATF_TC_HEAD(atof_strtod, tc)
ATF_TC_BODY(atof_strtod, tc)
{
char buf[128];
char buf[320];
(void)snprintf(buf, sizeof(buf), "%f\n", DBL_MAX);

View File

@ -1,4 +1,4 @@
/* $NetBSD: rusers.c,v 1.25 2011/09/06 18:29:35 joerg Exp $ */
/* $NetBSD: rusers.c,v 1.26 2019/02/03 10:48:47 mrg Exp $ */
/*-
* Copyright (c) 1993 John Brezak
@ -30,7 +30,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: rusers.c,v 1.25 2011/09/06 18:29:35 joerg Exp $");
__RCSID("$NetBSD: rusers.c,v 1.26 2019/02/03 10:48:47 mrg Exp $");
#endif /* not lint */
#include <sys/types.h>
@ -163,7 +163,7 @@ rusers_reply(char *replyp, struct netbuf *raddrp, struct netconfig *nconf)
for (x = 0; x < up->uia_cnt; x++) {
unsigned int minutes;
char date[26], idle[8];
char date[26], idle[11];
char remote[HOSTWID + 3]; /* "(" host ")" \0 */
char local[HOSTWID + LINEWID + 2]; /* host ":" line \0 */
time_t uttime;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ps.c,v 1.37 2017/01/10 21:14:51 christos Exp $ */
/* $NetBSD: ps.c,v 1.38 2019/02/03 10:48:47 mrg Exp $ */
/*-
* Copyright (c) 1999
@ -45,7 +45,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: ps.c,v 1.37 2017/01/10 21:14:51 christos Exp $");
__RCSID("$NetBSD: ps.c,v 1.38 2019/02/03 10:48:47 mrg Exp $");
#endif /* not lint */
#include <sys/param.h>
@ -340,7 +340,7 @@ time2str(struct kinfo_proc2 *kp)
{
long secs;
long psecs; /* "parts" of a second. first micro, then centi */
static char timestr[10];
static char timestr[18];
/* XXX - I don't like this. */
if (kp->p_stat == SZOMB) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: arm.c,v 1.2 2018/01/16 08:23:18 mrg Exp $ */
/* $NetBSD: arm.c,v 1.3 2019/02/03 10:48:47 mrg Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@ -32,7 +32,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: arm.c,v 1.2 2018/01/16 08:23:18 mrg Exp $");
__RCSID("$NetBSD: arm.c,v 1.3 2019/02/03 10:48:47 mrg Exp $");
#endif /* not lint */
#include <sys/types.h>
@ -168,7 +168,7 @@ print_features(const char *cpuname, const char *setname,
for (u_int j = 0; isar != 0 && j < 8; j++, isar >>= 4) {
const char *name = NULL;
const char *value = "";
char namebuf[12], valuebuf[12], tmpbuf[30];
char namebuf[24], valuebuf[12], tmpbuf[30];
if ((isar & 0x0f) == 0
&& (id_present == NULL
|| (id_present[i] & (1 << j))) == 0) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: disks.c,v 1.28 2018/11/27 17:13:41 martin Exp $ */
/* $NetBSD: disks.c,v 1.29 2019/02/03 10:48:47 mrg Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -69,7 +69,7 @@
/* Disk descriptions */
struct disk_desc {
char dd_name[SSTRSIZE];
char dd_descr[70];
char dd_descr[256];
bool dd_no_mbr, dd_no_part;
uint dd_cyl;
uint dd_head;