emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master abd7691 1/2: Merge from gnulib


From: Paul Eggert
Subject: [Emacs-diffs] master abd7691 1/2: Merge from gnulib
Date: Thu, 27 Apr 2017 18:24:13 -0400 (EDT)

branch: master
commit abd769131dae3f9693faff9a080267e86936ce99
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Merge from gnulib
    
    This incorporates:
    2017-04-24 time_rz: fix heap buffer overflow vulnerability
    2017-04-23 stat-time: Update comments.
    2017-04-22 ftoastr: cite a newer paper
    2017-04-21 gettext-h: Avoid -Wundef warning.
    * lib/ftoastr.c, lib/gettext.h, lib/stat-time.h, lib/time_rz.c:
    * m4/getopt.m4: Copy from gnulib.
    * m4/gnulib-comp.m4: Regenerate.
---
 lib/ftoastr.c     |  8 ++++----
 lib/gettext.h     |  5 +++--
 lib/stat-time.h   |  2 +-
 lib/time_rz.c     | 15 +++++++++++++--
 m4/getopt.m4      |  9 +++++++++
 m4/gnulib-comp.m4 |  3 +++
 6 files changed, 33 insertions(+), 9 deletions(-)

diff --git a/lib/ftoastr.c b/lib/ftoastr.c
index ef861e2..f243416 100644
--- a/lib/ftoastr.c
+++ b/lib/ftoastr.c
@@ -105,10 +105,10 @@ FTOASTR (char *buf, size_t bufsize, int flags, int width, 
FLOAT x)
   /* The following method is simple but slow.
      For ideas about speeding things up, please see:
 
-     Florian Loitsch, Printing floating-point numbers quickly and accurately
-     with integers.  ACM SIGPLAN notices 46, 6 (June 2010), 233-243
-     <http://dx.doi.org/10.1145/1809028.1806623>; also see the
-     2010-03-21 draft <http://florian.loitsch.com/tmp/article.pdf>.  */
+     Andrysco M, Jhala R, Lerner S. Printing floating-point numbers:
+     a faster, always correct method. ACM SIGPLAN notices - POPL '16.
+     2016;51(1):555-67 <http://dx.doi.org/10.1145/2914770.2837654>; draft at
+     <http://cseweb.ucsd.edu/~lerner/papers/fp-printing-popl16.pdf>.  */
 
   PROMOTED_FLOAT promoted_x = x;
   char format[sizeof "%-+ 0*.*Lg"];
diff --git a/lib/gettext.h b/lib/gettext.h
index 0465d7a..e7520af 100644
--- a/lib/gettext.h
+++ b/lib/gettext.h
@@ -18,8 +18,9 @@
 #ifndef _LIBGETTEXT_H
 #define _LIBGETTEXT_H 1
 
-/* NLS can be disabled through the configure --disable-nls option.  */
-#if ENABLE_NLS
+/* NLS can be disabled through the configure --disable-nls option
+   or through "#define ENABLE NLS 0" before including this file.  */
+#if defined ENABLE_NLS && ENABLE_NLS
 
 /* Get declarations of GNU message catalog functions.  */
 # include <libintl.h>
diff --git a/lib/stat-time.h b/lib/stat-time.h
index 4746989..154d62a 100644
--- a/lib/stat-time.h
+++ b/lib/stat-time.h
@@ -169,7 +169,7 @@ get_stat_birthtime (struct stat const *st)
 #elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
   /* Native Windows platforms (but not Cygwin) put the "file creation
      time" in st_ctime (!).  See
-     <http://msdn2.microsoft.com/de-de/library/14h5k7ff(VS.80).aspx>.  */
+     <https://msdn.microsoft.com/en-us/library/14h5k7ff(VS.80).aspx>.  */
   t.tv_sec = st->st_ctime;
   t.tv_nsec = 0;
 #else
diff --git a/lib/time_rz.c b/lib/time_rz.c
index adb9c1c..c41a8ef 100644
--- a/lib/time_rz.c
+++ b/lib/time_rz.c
@@ -27,6 +27,7 @@
 #include <time.h>
 
 #include <errno.h>
+#include <limits.h>
 #include <stdbool.h>
 #include <stddef.h>
 #include <stdlib.h>
@@ -35,6 +36,10 @@
 #include "flexmember.h"
 #include "time-internal.h"
 
+#ifndef SIZE_MAX
+# define SIZE_MAX ((size_t) -1)
+#endif
+
 #if !HAVE_TZSET
 static void tzset (void) { }
 #endif
@@ -43,7 +48,7 @@ static void tzset (void) { }
    the largest "small" request for the GNU C library malloc.  */
 enum { DEFAULT_MXFAST = 64 * sizeof (size_t) / 4 };
 
-/* Minimum size of the ABBRS member of struct abbr.  ABBRS is larger
+/* Minimum size of the ABBRS member of struct tm_zone.  ABBRS is larger
    only in the unlikely case where an abbreviation longer than this is
    used.  */
 enum { ABBR_SIZE_MIN = DEFAULT_MXFAST - offsetof (struct tm_zone, abbrs) };
@@ -150,7 +155,13 @@ save_abbr (timezone_t tz, struct tm *tm)
           if (! (*zone_copy || (zone_copy == tz->abbrs && tz->tz_is_set)))
             {
               size_t zone_size = strlen (zone) + 1;
-              if (zone_size < tz->abbrs + ABBR_SIZE_MIN - zone_copy)
+              size_t zone_used = zone_copy - tz->abbrs;
+              if (SIZE_MAX - zone_used < zone_size)
+                {
+                  errno = ENOMEM;
+                  return false;
+                }
+              if (zone_used + zone_size < ABBR_SIZE_MIN)
                 extend_abbrs (zone_copy, zone, zone_size);
               else
                 {
diff --git a/m4/getopt.m4 b/m4/getopt.m4
index ac3b38e..3ebc7b7 100644
--- a/m4/getopt.m4
+++ b/m4/getopt.m4
@@ -32,7 +32,16 @@ AC_DEFUN([gl_FUNC_GETOPT_POSIX],
 # getopt_long_only.
 AC_DEFUN([gl_FUNC_GETOPT_GNU],
 [
+  dnl Set the variable gl_getopt_required, so that all invocations of
+  dnl gl_GETOPT_CHECK_HEADERS in the scope of the current configure file
+  dnl will check for getopt with GNU extensions.
+  dnl This means that if one gnulib-tool invocation requests getopt-posix
+  dnl and another gnulib-tool invocation requests getopt-gnu, it is as if
+  dnl both had requested getopt-gnu.
   m4_divert_text([INIT_PREPARE], [gl_getopt_required=GNU])
+
+  dnl No need to invoke gl_FUNC_GETOPT_POSIX here; this is automatically
+  dnl done through the module dependency getopt-gnu -> getopt-posix.
 ])
 
 # Determine whether to replace the entire getopt facility.
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index bfac944..030304d 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -259,6 +259,9 @@ AC_DEFUN([gl_INIT],
   fi
   gl_STDLIB_MODULE_INDICATOR([getloadavg])
   gl_FUNC_GETOPT_GNU
+  dnl Because of the way gl_FUNC_GETOPT_GNU is implemented (the 
gl_getopt_required
+  dnl mechanism), there is no need to do any AC_LIBOBJ or AC_SUBST here; they 
are
+  dnl done in the getopt-posix module.
   gl_FUNC_GETOPT_POSIX
   if test $REPLACE_GETOPT = 1; then
     AC_LIBOBJ([getopt])



reply via email to

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