Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-7]: src/usr.bin/find Pull up the following revisions(s) (requeste...
details: https://anonhg.NetBSD.org/src/rev/a0d64aa9183d
branches: netbsd-7
changeset: 800551:a0d64aa9183d
user: sborrill <sborrill%NetBSD.org@localhost>
date: Tue Oct 30 10:07:08 2018 +0000
description:
Pull up the following revisions(s) (requested by mrg in ticket #1642):
usr.bin/find/function.c: revision 1.77
When calculating the length of the args that can be
appended in a "find .... -exec something {} +"
usage, remember to allow for the arg pointers, which
form part of what is allowed in ARG_MAX.
diffstat:
usr.bin/find/function.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diffs (40 lines):
diff -r 2cbb5b858c52 -r a0d64aa9183d usr.bin/find/function.c
--- a/usr.bin/find/function.c Tue Oct 30 09:57:05 2018 +0000
+++ b/usr.bin/find/function.c Tue Oct 30 10:07:08 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: function.c,v 1.72 2013/05/04 06:29:32 uebayasi Exp $ */
+/* $NetBSD: function.c,v 1.72.6.1 2018/10/30 10:07:08 sborrill Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "from: @(#)function.c 8.10 (Berkeley) 5/4/95";
#else
-__RCSID("$NetBSD: function.c,v 1.72 2013/05/04 06:29:32 uebayasi Exp $");
+__RCSID("$NetBSD: function.c,v 1.72.6.1 2018/10/30 10:07:08 sborrill Exp $");
#endif
#endif /* not lint */
@@ -669,7 +669,9 @@
size_t c, bufsize;
cnt = ap - *argvp - 1; /* units are words */
- new->ep_maxargs = 5000;
+ new->ep_maxargs = ARG_MAX / (sizeof (char *) + 16);
+ if (new->ep_maxargs > 5000)
+ new->ep_maxargs = 5000;
new->e_argv = emalloc((cnt + new->ep_maxargs)
* sizeof(*new->e_argv));
@@ -690,7 +692,9 @@
errx(1, "Arguments too long");
new->e_argv[cnt] = *argv;
}
- bufsize = MAXARG - c;
+ if (c + new->ep_maxargs * sizeof (char *) >= MAXARG)
+ errx(1, "Arguments too long");
+ bufsize = MAXARG - c - new->ep_maxargs * sizeof (char *);
/*
* Allocate, and then initialize current, base, and
Home |
Main Index |
Thread Index |
Old Index