grep-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

grep branch, master, updated. v2.25-59-gf2c1faa


From: Paul Eggert
Subject: grep branch, master, updated. v2.25-59-gf2c1faa
Date: Mon, 22 Aug 2016 06:23:13 +0000 (UTC)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  f2c1faafe4464227bfe2dd684052f2be2c493914 (commit)
      from  6f67b1313cc1f8964f5440012b161962453ded2d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=f2c1faafe4464227bfe2dd684052f2be2c493914


commit f2c1faafe4464227bfe2dd684052f2be2c493914
Author: Paul Eggert <address@hidden>
Date:   Sun Aug 21 23:22:35 2016 -0700

    grep: minor tweaks of initial buffer alloc
    
    * src/grep.c (main): Allocate input buffer only when about
    to do I/O.  Avoid int overflow on systems with 2 GiB pages.
    Fix size_t overflow check.

diff --git a/src/grep.c b/src/grep.c
index 63487d6..0c84b2a 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -2320,12 +2320,6 @@ main (int argc, char **argv)
   set_program_name (argv[0]);
   program_name = argv[0];
 
-  pagesize = getpagesize ();
-  if (pagesize == 0 || 2 * pagesize + 1 <= pagesize)
-    abort ();
-  bufalloc = (ALIGN_TO (INITIAL_BUFSIZE, pagesize) + pagesize + sizeof 
(uword));
-  buffer = xmalloc (bufalloc);
-
   keys = NULL;
   keycc = 0;
   with_filenames = false;
@@ -2777,6 +2771,18 @@ main (int argc, char **argv)
   if (max_count == 0)
     return EXIT_FAILURE;
 
+  /* Prefer sysconf for page size, as getpagesize typically returns int.  */
+#ifdef _SC_PAGESIZE
+  long psize = sysconf (_SC_PAGESIZE);
+#else
+  long psize = getpagesize ();
+#endif
+  if (! (0 < psize && psize <= (SIZE_MAX - sizeof (uword)) / 2))
+    abort ();
+  pagesize = psize;
+  bufalloc = ALIGN_TO (INITIAL_BUFSIZE, pagesize) + pagesize + sizeof (uword);
+  buffer = xmalloc (bufalloc);
+
   if (fts_options & FTS_LOGICAL && devices == READ_COMMAND_LINE_DEVICES)
     devices = READ_DEVICES;
 

-----------------------------------------------------------------------

Summary of changes:
 src/grep.c |   18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)


hooks/post-receive
-- 
grep



reply via email to

[Prev in Thread] Current Thread [Next in Thread]