summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Josefsson <simon@josefsson.org>2006-08-13 15:27:49 +0000
committerSimon Josefsson <simon@josefsson.org>2006-08-13 15:27:49 +0000
commit340615f1e5fe2891233aa72d39effbd969c8a648 (patch)
treee3c403c9f3a81304226766806c5de92c72b71a6c
parentb76be1005aec4966c3c9d4357b1bfb3320a5bc2d (diff)
downloadgnutls-340615f1e5fe2891233aa72d39effbd969c8a648.tar.gz
Update.
-rw-r--r--gl/Makefile.am1
-rw-r--r--gl/m4/gc.m48
-rw-r--r--gl/m4/getaddrinfo.m44
-rw-r--r--gl/m4/gnulib-comp.m44
-rw-r--r--gl/m4/inet_ntop.m43
-rw-r--r--gl/m4/inet_pton.m43
-rw-r--r--gl/m4/memxor.m45
-rw-r--r--gl/m4/restrict.m438
-rw-r--r--gl/snprintf.c38
9 files changed, 46 insertions, 58 deletions
diff --git a/gl/Makefile.am b/gl/Makefile.am
index c2d3995d83..7e6e2afc93 100644
--- a/gl/Makefile.am
+++ b/gl/Makefile.am
@@ -17,6 +17,7 @@ noinst_LTLIBRARIES = libgnu.la
libgnu_la_SOURCES =
libgnu_la_LIBADD = @LTLIBOBJS@
noinst_HEADERS =
+pkgdata_DATA =
EXTRA_DIST =
BUILT_SOURCES =
SUFFIXES =
diff --git a/gl/m4/gc.m4 b/gl/m4/gc.m4
index e01ae29d61..359b9f12ad 100644
--- a/gl/m4/gc.m4
+++ b/gl/m4/gc.m4
@@ -1,4 +1,4 @@
-# gc.m4 serial 2
+# gc.m4 serial 3
dnl Copyright (C) 2005, 2006 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -21,4 +21,8 @@ AC_DEFUN([gl_GC],
])
# Prerequisites of lib/gc.h
-AC_DEFUN([gl_PREREQ_GC], [:])
+AC_DEFUN([gl_PREREQ_GC],
+[
+ AC_REQUIRE([AC_C_RESTRICT])
+ :
+])
diff --git a/gl/m4/getaddrinfo.m4 b/gl/m4/getaddrinfo.m4
index 8d57bb3276..db285d9423 100644
--- a/gl/m4/getaddrinfo.m4
+++ b/gl/m4/getaddrinfo.m4
@@ -1,4 +1,4 @@
-# getaddrinfo.m4 serial 10
+# getaddrinfo.m4 serial 11
dnl Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -52,7 +52,7 @@ AC_DEFUN([gl_PREREQ_GETADDRINFO], [
LIBS="$LIBS -lws2_32"
fi
])
- AC_REQUIRE([gl_C_RESTRICT])
+ AC_REQUIRE([AC_C_RESTRICT])
AC_REQUIRE([gl_SOCKET_FAMILIES])
AC_REQUIRE([gl_HEADER_SYS_SOCKET])
AC_REQUIRE([AC_C_INLINE])
diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4
index 8282c984f2..ddffb12eed 100644
--- a/gl/m4/gnulib-comp.m4
+++ b/gl/m4/gnulib-comp.m4
@@ -19,6 +19,8 @@
# any checks for libraries, header files, types and library functions.
AC_DEFUN([gl_EARLY],
[
+ m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace
+ m4_pattern_allow([^gl_ES$])dnl a valid locale name
AC_REQUIRE([AC_PROG_RANLIB])
AC_REQUIRE([AC_GNU_SOURCE])
AC_REQUIRE([gl_LOCK])
@@ -59,7 +61,6 @@ AC_DEFUN([gl_INIT],
gl_HEADER_NETINET_IN
gl_FUNC_READ_FILE
gl_FUNC_READLINE
- gl_C_RESTRICT
gl_SIZE_MAX
gl_FUNC_SNPRINTF
gl_TYPE_SOCKLEN_T
@@ -208,7 +209,6 @@ AC_DEFUN([gl_FILE_LIST], [
m4/progtest.m4
m4/read-file.m4
m4/readline.m4
- m4/restrict.m4
m4/rijndael.m4
m4/sha1.m4
m4/signed.m4
diff --git a/gl/m4/inet_ntop.m4 b/gl/m4/inet_ntop.m4
index 5eec8692e7..bb02d2298b 100644
--- a/gl/m4/inet_ntop.m4
+++ b/gl/m4/inet_ntop.m4
@@ -1,4 +1,4 @@
-# inet_ntop.m4 serial 2
+# inet_ntop.m4 serial 3
dnl Copyright (C) 2005, 2006 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -15,4 +15,5 @@ AC_DEFUN([gl_PREREQ_INET_NTOP], [
AC_CHECK_HEADERS_ONCE([netinet/in.h arpa/inet.h])
AC_CHECK_DECLS([inet_ntop],,,[#include <arpa/inet.h>])
AC_REQUIRE([gl_SOCKET_FAMILIES])
+ AC_REQUIRE([AC_C_RESTRICT])
])
diff --git a/gl/m4/inet_pton.m4 b/gl/m4/inet_pton.m4
index dd8c31854d..85e802c8bd 100644
--- a/gl/m4/inet_pton.m4
+++ b/gl/m4/inet_pton.m4
@@ -1,4 +1,4 @@
-# inet_pton.m4 serial 1
+# inet_pton.m4 serial 2
dnl Copyright (C) 2006 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -15,4 +15,5 @@ AC_DEFUN([gl_PREREQ_INET_PTON], [
AC_CHECK_HEADERS_ONCE([netinet/in.h arpa/inet.h])
AC_CHECK_DECLS([inet_pton],,,[#include <arpa/inet.h>])
AC_REQUIRE([gl_SOCKET_FAMILIES])
+ AC_REQUIRE([AC_C_RESTRICT])
])
diff --git a/gl/m4/memxor.m4 b/gl/m4/memxor.m4
index 96764cfbf6..bf88a410dc 100644
--- a/gl/m4/memxor.m4
+++ b/gl/m4/memxor.m4
@@ -1,5 +1,5 @@
-# memxor.m4 serial 1
-dnl Copyright (C) 2005 Free Software Foundation, Inc.
+# memxor.m4 serial 2
+dnl Copyright (C) 2006 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -8,4 +8,5 @@ AC_DEFUN([gl_MEMXOR],
[
AC_LIBSOURCES([memxor.h, memxor.c])
AC_LIBOBJ([memxor])
+ AC_REQUIRE([AC_C_RESTRICT])
])
diff --git a/gl/m4/restrict.m4 b/gl/m4/restrict.m4
deleted file mode 100644
index 1f3bbb92c4..0000000000
--- a/gl/m4/restrict.m4
+++ /dev/null
@@ -1,38 +0,0 @@
-#serial 1003
-dnl Copyright (C) 2003 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-# This macro can be removed once we can rely on Autoconf 2.57a or later,
-# since we can then use its AC_C_RESTRICT.
-
-# gl_C_RESTRICT
-# --------------
-# Determine whether the C/C++ compiler supports the "restrict" keyword
-# introduced in ANSI C99, or an equivalent. Do nothing if the compiler
-# accepts it. Otherwise, if the compiler supports an equivalent,
-# define "restrict" to be that. Here are some variants:
-# - GCC supports both __restrict and __restrict__
-# - older DEC Alpha C compilers support only __restrict
-# - _Restrict is the only spelling accepted by Sun WorkShop 6 update 2 C
-# Otherwise, define "restrict" to be empty.
-AC_DEFUN([gl_C_RESTRICT],
-[AC_CACHE_CHECK([for C/C++ restrict keyword], gl_cv_c_restrict,
- [gl_cv_c_restrict=no
- # Try the official restrict keyword, then gcc's __restrict, and
- # the less common variants.
- for ac_kw in restrict __restrict __restrict__ _Restrict; do
- AC_COMPILE_IFELSE([AC_LANG_SOURCE(
- [float * $ac_kw x;])],
- [gl_cv_c_restrict=$ac_kw; break])
- done
- ])
- case $gl_cv_c_restrict in
- restrict) ;;
- no) AC_DEFINE(restrict,,
- [Define to equivalent of C99 restrict keyword, or to nothing if this
- is not supported. Do not define if restrict is supported directly.]) ;;
- *) AC_DEFINE_UNQUOTED(restrict, $gl_cv_c_restrict) ;;
- esac
-])
diff --git a/gl/snprintf.c b/gl/snprintf.c
index e019fcece7..1018fb4a0f 100644
--- a/gl/snprintf.c
+++ b/gl/snprintf.c
@@ -1,6 +1,6 @@
/* Formatted output to strings.
- Copyright (C) 2004 Free Software Foundation, Inc.
- Written by Simon Josefsson.
+ Copyright (C) 2004, 2006 Free Software Foundation, Inc.
+ Written by Simon Josefsson and Paul Eggert.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -22,13 +22,19 @@
#include "snprintf.h"
+#include <errno.h>
+#include <limits.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
-#include "minmax.h"
#include "vasnprintf.h"
+/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */
+#ifndef EOVERFLOW
+# define EOVERFLOW E2BIG
+#endif
+
/* Print formatted output to string STR. Similar to sprintf, but
additional length SIZE limit how much is written into STR. Returns
string length of formatted string (which may be larger than SIZE).
@@ -39,22 +45,34 @@ snprintf (char *str, size_t size, const char *format, ...)
{
char *output;
size_t len;
+ size_t lenbuf = size;
va_list args;
va_start (args, format);
- len = size;
- output = vasnprintf (str, &len, format, args);
+ output = vasnprintf (str, &lenbuf, format, args);
+ len = lenbuf;
va_end (args);
if (!output)
return -1;
- if (str != NULL)
- if (len > size - 1) /* equivalent to: (size > 0 && len >= size) */
- str[size - 1] = '\0';
-
if (output != str)
- free (output);
+ {
+ if (size)
+ {
+ size_t pruned_len = (len < size ? len : size - 1);
+ memcpy (str, output, pruned_len);
+ str[pruned_len] = '\0';
+ }
+
+ free (output);
+ }
+
+ if (INT_MAX < len)
+ {
+ errno = EOVERFLOW;
+ return -1;
+ }
return len;
}