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

[commits] r14027 - in /fsf/trunk/libc: ./ debug/ elf/ locale/ locale/programs/ malloc/ posix/ sysdeps/unix/sysv/linux/



Author: eglibc
Date: Sun May 29 00:35:10 2011
New Revision: 14027

Log:
Import glibc-mainline for 2011-05-29

Added:
    fsf/trunk/libc/elf/sotruss-lib.c
    fsf/trunk/libc/elf/sotruss.ksh   (with props)
    fsf/trunk/libc/posix/bug-regex32.c   (with props)
Modified:
    fsf/trunk/libc/ChangeLog
    fsf/trunk/libc/Makeconfig
    fsf/trunk/libc/NEWS
    fsf/trunk/libc/debug/xtrace.sh
    fsf/trunk/libc/elf/Makefile
    fsf/trunk/libc/locale/findlocale.c
    fsf/trunk/libc/locale/programs/locarchive.c
    fsf/trunk/libc/malloc/memusage.sh
    fsf/trunk/libc/posix/Makefile
    fsf/trunk/libc/posix/glob.c
    fsf/trunk/libc/posix/regex_internal.c
    fsf/trunk/libc/posix/regexec.c
    fsf/trunk/libc/sysdeps/unix/sysv/linux/socketcall.h

Modified: fsf/trunk/libc/ChangeLog
==============================================================================
--- fsf/trunk/libc/ChangeLog (original)
+++ fsf/trunk/libc/ChangeLog Sun May 29 00:35:10 2011
@@ -1,4 +1,25 @@
 2011-05-28  Ulrich Drepper  <drepper@xxxxxxxxx>
+
+	[BZ #12811]
+	* posix/regex_internal.c (build_wcs_buffer): Don't signal we have to
+	grow the buffers more if it already has to be sufficient.
+	(build_wcs_upper_buffer): Likewise.
+	* posix/regexec.c (check_matching): Likewise.
+	(clean_state_log_if_needed): Likewise.
+	(extend_buffers): Don't enlarge buffers beyond size of the input
+	buffer.
+	Patches mostly by Emil Wojak <emil@xxxxxxxx>.
+	* posix/bug-regex32.c: New file.
+	* posix/Makefile (tests): Add bug-regex32.
+
+	* locale/findlocale.c (_nl_find_locale): Return right away if
+	_nl_explode_name failed.
+	* locale/programs/locarchive.c (add_locale_to_archive): Likewise.
+
+	* sysdeps/unix/sysv/linux/socketcall.h (SOCKOP_sendmmsg): Define.
+
+	* debug/xtrace.sh: Unify messages.
+	* malloc/memusage.sh: Likewise.
 
 	[BZ #12813]
 	* sysdeps/unix/sysv/linux/x86_64/init-first.c (__vdso_time): Retrieve

Modified: fsf/trunk/libc/Makeconfig
==============================================================================
--- fsf/trunk/libc/Makeconfig (original)
+++ fsf/trunk/libc/Makeconfig Sun May 29 00:35:10 2011
@@ -277,6 +277,12 @@
 infodir = $(prefix)/info
 endif
 inst_infodir = $(install_root)$(infodir)
+
+# Where to install audit libraries.
+ifndef auditdir
+auditdir = $(libdir)/audit
+endif
+inst_auditdir = $(install_root)$(auditdir)
 
 # Where to install default configuration files.  These include the local
 # timezone specification and network data base files.

Modified: fsf/trunk/libc/NEWS
==============================================================================
--- fsf/trunk/libc/NEWS (original)
+++ fsf/trunk/libc/NEWS Sun May 29 00:35:10 2011
@@ -1,4 +1,4 @@
-GNU C Library NEWS -- history of user-visible changes.  2011-5-27
+GNU C Library NEWS -- history of user-visible changes.  2011-5-28
 Copyright (C) 1992-2009, 2010, 2011 Free Software Foundation, Inc.
 See the end for copying conditions.
 
@@ -17,7 +17,7 @@
   12545, 12551, 12582, 12583, 12587, 12597, 12601, 12611, 12625, 12626,
   12631, 12650, 12653, 12655, 12660, 12671, 12681, 12685, 12711, 12713,
   12714, 12717, 12723, 12724, 12734, 12738, 12746, 12766, 12775, 12777,
-  12782, 12788, 12792, 12795, 12813, 12814
+  12782, 12788, 12792, 12795, 12811, 12813, 12814
 
 * The RPC implementation in libc is obsoleted.  Old programs keep working
   but new programs cannot be linked with the routines in libc anymore.
@@ -36,6 +36,9 @@
   yue_HK, lij_IT, mhr_RU
 
 * New encodings: CP770, CP771, CP772, CP773, CP774
+
+* New program sotruss to trace calls through PLTs
+  Implemented by Ulrich Drepper.
 
 Version 2.13
 

Modified: fsf/trunk/libc/debug/xtrace.sh
==============================================================================
--- fsf/trunk/libc/debug/xtrace.sh (original)
+++ fsf/trunk/libc/debug/xtrace.sh Sun May 29 00:35:10 2011
@@ -30,13 +30,13 @@
 
 # Refer to --help option.
 help_info() {
-  printf >&2 $"Try \`xtrace --help' for more information.\n"
+  printf >&2 $"Try \`%s --help' or `%s --usage' for more information.\n" xtrace xtrace
   exit 1
 }
 
 # Message for missing argument.
 do_missing_arg() {
-  printf >&2 $"xtrace: option \`$1' requires an argument.\n"
+  printf >&2 $"%s: option '%s' requires an argument.\n" xtrace "$1"
   help_info
 }
 

Modified: fsf/trunk/libc/elf/Makefile
==============================================================================
--- fsf/trunk/libc/elf/Makefile (original)
+++ fsf/trunk/libc/elf/Makefile Sun May 29 00:35:10 2011
@@ -170,6 +170,28 @@
 endif
 endif
 
+ifeq ($(have-ksh)$(build-shared),yesyes)
+extra-objs += sotruss-lib.os sotruss-lib.so
+install-others += $(inst_auditdir)/sotruss-lib.so
+install-bin-script += sotruss
+generated += sotruss
+CPPFLAGS-sotruss-lib = -DNOT_IN_libc
+$(objpfx)sotruss-lib.so: $(objpfx)sotruss-lib.os $(common-objpfx)shlib.lds
+	$(build-module-asneeded)
+$(objpfx)sotruss-lib.so: $(common-objpfx)libc.so $(objpfx)ld.so \
+	$(common-objpfx)libc_nonshared.a
+
+$(objpfx)sotruss: sotruss.ksh $(common-objpfx)config.make
+	sed -e 's%@KSH@%$(KSH)%g' \
+	    -e 's%@VERSION@%$(version)%g' \
+	    -e 's%@TEXTDOMAINDIR@%$(msgcatdir)%g' \
+	    -e 's%@PREFIX@%$(prefix)%g' < $< > $@.new
+	chmod 555 $@.new
+	mv -f $@.new $@
+$(inst_auditdir)/sotruss-lib.so: $(objpfx)sotruss-lib.so $(+force)
+	$(do-install-program)
+endif
+
 tests = tst-tls1 tst-tls2 tst-tls9 tst-leaks1
 ifeq (yes,$(have-initfini-array))
 tests += tst-array1 tst-array2 tst-array3 tst-array4 tst-array5

Added: fsf/trunk/libc/elf/sotruss-lib.c
==============================================================================
--- fsf/trunk/libc/elf/sotruss-lib.c (added)
+++ fsf/trunk/libc/elf/sotruss-lib.c Sun May 29 00:35:10 2011
@@ -1,0 +1,333 @@
+/* Trace calls through PLTs and show caller, callee, and parameters.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@xxxxxxxxx>, 2011.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <error.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/param.h>
+#include <sys/uio.h>
+
+#include <ldsodefs.h>
+
+
+extern const char *__progname;
+extern const char *__progname_full;
+
+
+/* List of objects to trace calls from.  */
+static const char *fromlist;
+/* List of objects to trace calls to.  */
+static const char *tolist;
+
+/* If non-zero, also trace returns of the calls.  */
+static int do_exit;
+/* If non-zero print PID for each line.  */
+static int print_pid;
+
+/* The output stream to use.  */
+static FILE *out_file;
+
+
+static int
+match_pid (pid_t pid, const char *which)
+{
+  if (which == NULL || which[0] == '\0')
+    {
+      print_pid = 1;
+      return 1;
+    }
+
+  char *endp;
+  unsigned long n = strtoul (which, &endp, 0);
+  return *endp == '\0' && n == pid;
+}
+
+
+static void
+init (void)
+{
+  fromlist = getenv ("SOTRUSS_FROMLIST");
+  if (fromlist != NULL && fromlist[0] == '\0')
+    fromlist = NULL;
+  tolist = getenv ("SOTRUSS_TOLIST");
+  if (tolist != NULL && tolist[0] == '\0')
+    tolist = NULL;
+  do_exit = (getenv ("SOTRUSS_EXIT") ?: "")[0] != '\0';
+
+  /* Determine whether this process is supposed to be traced and if
+     yes, whether we should print into a file.  */
+  const char *which_process = getenv ("SOTRUSS_WHICH");
+  pid_t pid = getpid ();
+  int out_fd = -1;
+  if (match_pid (pid, which_process))
+    {
+      const char *out_filename = getenv ("SOTRUSS_OUTNAME");
+
+      if (out_filename != NULL && out_filename[0] != 0)
+	{
+	  size_t out_filename_len = strlen (out_filename) + 12;
+	  char fullname[out_filename_len];
+	  char *endp = stpcpy (fullname, out_filename);
+	  if (which_process == NULL || which_process[0] == '\0')
+	    snprintf (endp, 12, ".%lu", (unsigned long int) pid);
+
+	  out_fd = open (fullname, O_RDWR | O_CREAT | O_TRUNC, 0666);
+	  if (out_fd != -1)
+	    print_pid = 0;
+	}
+    }
+
+  /* If we do not write into a file write to stderr.  Duplicate the
+     descriptor so that we can keep printing in case the program
+     closes stderr.  Try first to allocate a descriptor with a value
+     usually not used as to minimize interference with the
+     program.  */
+  if (out_fd == -1)
+    {
+      out_fd = fcntl (STDERR_FILENO, F_DUPFD, 1000);
+      if (out_fd == -1)
+	out_fd = dup (STDERR_FILENO);
+    }
+
+  if (out_fd != -1)
+    {
+      /* Convert file descriptor into a stream.  */
+      out_file = fdopen (out_fd, "w");
+      if (out_file != NULL)
+	setlinebuf (out_file);
+    }
+}
+
+
+/* Audit interface verification.  We also initialize everything if
+   everything checks out OK.  */
+unsigned int
+la_version (unsigned int v)
+{
+  if (v != LAV_CURRENT)
+    error (1, 0, "cannot handle interface version %u", v);
+
+  init ();
+
+  return v;
+}
+
+
+/* Check whether a file name is on the colon-separated list of file
+   names.  */
+static unsigned int
+match_file (const char *list, const char *name, size_t name_len,
+	    unsigned int mask)
+{
+  if (list[0] == '\0')
+    return 0;
+
+  const char *cp = list;
+  while (1)
+    {
+      if (strncmp (cp, name, name_len) == 0
+	  && (cp[name_len] == ':' || cp[name_len] == '\0'))
+	return mask;
+
+      cp = strchr (cp, ':');
+      if (cp == NULL)
+	return 0;
+      ++cp;
+    }
+}
+
+
+unsigned int
+la_objopen (struct link_map *map, Lmid_t lmid, uintptr_t *cookie)
+{
+  if (out_file == NULL)
+    return 0;
+
+  const char *full_name = map->l_name ?: "";
+  if (full_name[0] == '\0')
+    full_name = __progname_full;
+  size_t full_name_len = strlen (full_name);
+  const char *base_name = basename (full_name);
+  if (base_name[0] == '\0')
+    base_name = __progname;
+  size_t base_name_len = strlen (base_name);
+
+  int result = 0;
+  const char *print_name = NULL;
+  for (struct libname_list *l = map->l_libname; l != NULL; l = l->next)
+    {
+      if (print_name == NULL || (print_name[0] == '/' && l->name[0] != '/'))
+	print_name = l->name;
+
+      if (fromlist != NULL)
+	result |= match_file (fromlist, l->name, strlen (l->name),
+			      LA_FLG_BINDFROM);
+
+      if (tolist != NULL)
+	result |= match_file (tolist, l->name, strlen (l->name),LA_FLG_BINDTO);
+    }
+
+  if (print_name == NULL)
+    print_name = base_name;
+  if (print_name[0] == '\0')
+    print_name = __progname;
+
+  /* We cannot easily get to the object name in the PLT handling
+     functions.  Use the cookie to get the string pointer passed back
+     to us.  */
+  *cookie = (uintptr_t) print_name;
+
+  /* The object name has to be on the list of objects to trace calls
+     from or that list must be empty.  In the latter case we trace
+     only calls from the main binary.  */
+  if (fromlist == NULL)
+    result |= map->l_name[0] == '\0' ? LA_FLG_BINDFROM : 0;
+  else
+    result |= (match_file (fromlist, full_name, full_name_len,
+			   LA_FLG_BINDFROM)
+	       | match_file (fromlist, base_name, base_name_len,
+			     LA_FLG_BINDFROM));
+
+  /* The object name has to be on the list of objects to trace calls
+     to or that list must be empty.  In the latter case we trace
+     calls toall objects.  */
+  if (tolist == NULL)
+    result |= LA_FLG_BINDTO;
+  else
+    result |= (match_file (tolist, full_name, full_name_len, LA_FLG_BINDTO)
+	       | match_file (tolist, base_name, base_name_len, LA_FLG_BINDTO));
+
+  return result;
+}
+
+
+#if __ELF_NATIVE_CLASS == 32
+# define la_symbind la_symbind32
+typedef Elf32_Sym Elf_Sym;
+#else
+# define la_symbind la_symbind64
+typedef Elf64_Sym Elf_Sym;
+#endif
+
+uintptr_t
+la_symbind (Elf_Sym *sym, unsigned int ndx, uintptr_t *refcook,
+	    uintptr_t *defcook, unsigned int *flags, const char *symname)
+{
+  if (!do_exit)
+    *flags = LA_SYMB_NOPLTEXIT;
+
+  return sym->st_value;
+}
+
+
+static void
+print_enter (uintptr_t *refcook, uintptr_t *defcook, const char *symname,
+	     unsigned long int reg1, unsigned long int reg2,
+	     unsigned long int reg3, unsigned int flags)
+{
+  char buf[3 * sizeof (pid_t) + 3];
+  buf[0] = '\0';
+  if (print_pid)
+    snprintf (buf, sizeof (buf), "%5ld: ", (long int) getpid ());
+
+  fprintf (out_file, "%s%15s -> %-15s:%s%s(0x%lx, 0x%lx, 0x%lx)\n",
+	   buf, (char *) *refcook, (char *) *defcook,
+	   (flags & LA_SYMB_NOPLTEXIT) ? "*" : " ", symname, reg1, reg2, reg3);
+}
+
+
+#ifdef __i386__
+Elf32_Addr
+la_i86_gnu_pltenter (Elf32_Sym *sym __attribute__ ((unused)),
+		     unsigned int ndx __attribute__ ((unused)),
+		     uintptr_t *refcook, uintptr_t *defcook,
+		     La_i86_regs *regs, unsigned int *flags,
+		     const char *symname, long int *framesizep)
+{
+  unsigned long int *sp = (unsigned long int *) regs->lr_esp;
+
+  print_enter (refcook, defcook, symname, sp[1], sp[2], sp[3], *flags);
+
+  /* No need to copy anything, we will not need the parameters in any case.  */
+  *framesizep = 0;
+
+  return sym->st_value;
+}
+#elif defined __x86_64__
+Elf64_Addr
+la_x86_64_gnu_pltenter (Elf64_Sym *sym __attribute__ ((unused)),
+			unsigned int ndx __attribute__ ((unused)),
+			uintptr_t *refcook, uintptr_t *defcook,
+			La_x86_64_regs *regs, unsigned int *flags,
+			const char *symname, long int *framesizep)
+{
+  print_enter (refcook, defcook, symname,
+	       regs->lr_rdi, regs->lr_rsi, regs->lr_rdx, *flags);
+
+  /* No need to copy anything, we will not need the parameters in any case.  */
+  *framesizep = 0;
+
+  return sym->st_value;
+}
+#elif !defined HAVE_ARCH_PLTENTER
+# warning "pltenter for architecture not supported"
+#endif
+
+
+static void
+print_exit (uintptr_t *refcook, uintptr_t *defcook, const char *symname,
+	    unsigned long int reg)
+{
+  char buf[3 * sizeof (pid_t) + 3];
+  buf[0] = '\0';
+  if (print_pid)
+    snprintf (buf, sizeof (buf), "%5ld: ", (long int) getpid ());
+
+  fprintf (out_file, "%s%15s -> %-15s:%s%s - 0x%lu\n",
+	   buf, (char *) *refcook, (char *) *defcook, " ", symname, reg);
+}
+
+
+#ifdef __i386__
+unsigned int
+la_i86_gnu_pltexit (Elf32_Sym *sym, unsigned int ndx, uintptr_t *refcook,
+		    uintptr_t *defcook, const struct La_i86_regs *inregs,
+		    struct La_i86_retval *outregs, const char *symname)
+{
+  print_exit (refcook, defcook, symname, outregs->lrv_eax);
+
+  return 0;
+}
+#elif defined __x86_64__
+unsigned int
+la_x86_64_gnu_pltexit (Elf64_Sym *sym, unsigned int ndx, uintptr_t *refcook,
+		       uintptr_t *defcook, const struct La_x86_64_regs *inregs,
+		       struct La_x86_64_retval *outregs, const char *symname)
+{
+  print_exit (refcook, defcook, symname, outregs->lrv_rax);
+
+  return 0;
+}
+#elif !defined HAVE_ARCH_PLTEXIT
+# warning "pltexit for architecture not supported"
+#endif

Added: fsf/trunk/libc/elf/sotruss.ksh
==============================================================================
--- fsf/trunk/libc/elf/sotruss.ksh (added)
+++ fsf/trunk/libc/elf/sotruss.ksh Sun May 29 00:35:10 2011
@@ -1,0 +1,154 @@
+#! @KSH@
+# Copyright (C) 2011 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+# We should be able to find the translation right at the beginning.
+TEXTDOMAIN=libc
+TEXTDOMAINDIR=@TEXTDOMAINDIR@
+
+unset SOTRUSS_FROMLIST
+unset SOTRUSS_TOLIST
+unset SOTRUSS_OUTNAME
+unset SOTRUSS_EXIT
+unset SOTRUSS_NOINDENT
+SOTRUSS_WHICH=$$
+lib='@PREFIX@/$LIB/audit/sotruss-lib.so'
+
+function do_help {
+  echo $"Usage: sotruss [OPTION...] [--] EXECUTABLE [EXECUTABLE-OPTION...]
+  -F, --from FROMLIST     trace calls from objects on FORMLIST
+  -T, --to TOLIST         trace calls to objects on TOLIST
+
+  -e, --exit              also show exits from the function calls
+  -f, --follow            trace child processes
+  -o, --output FILENAME   write output to FILENAME (or FILENAME.$PID in case
+			  -f is also used) instead of standard error
+
+      --help              print this help and exit
+      --version           print version information and exit"
+
+  echo
+  printf $"Mandatory arguments to long options are also mandatory for any corresponding\nshort options.\n"
+  echo
+
+  echo $"For bug reporting instructions, please see:
+<http://www.gnu.org/software/libc/bugs.html>.
+"
+  exit 0
+}
+
+function do_missing_arg {
+  printf >&2 $"%s: option requires an argument -- '%s'\n" sotruss "$1"
+  printf >&2 $"Try \`%s --help' or \`%s --usage' for more information.\n" sotruss sotruss
+  exit 1
+}
+
+function do_ambiguous {
+  printf >&2 $"%s: option is ambiguous; possibilities:"
+  while test $# -gt 0; do
+    printf >&2 " '%s'" $1
+    shift
+  done
+  printf >&2 "\n"
+  printf >&2 $"Try \`%s --help' or \`%s --usage' for more information.\n" sotruss sotruss
+  exit 1
+}
+
+while test $# -gt 0; do
+  case "$1" in
+  --v | --ve | --ver | --vers | --versi | --versio | --version)
+    echo "sotruss (GNU libc) @VERSION@"
+    printf $"Copyright (C) %s Free Software Foundation, Inc.
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+" "2011"
+    printf $"Written by %s.\n" "Ulrich Drepper"
+    exit 0
+    ;;
+  --h | --he | --hel | --help)
+    do_help
+    ;;
+  --u | --us | --usa | --usag | --usage)
+    printf $"Usage: %s [-ef] [-F FROMLIST] [-o FILENAME] [-T TOLIST] [--exit]
+	    [--follow] [--from FROMLIST] [--output FILENAME] [--to TOLIST]\n" sotruss
+    exit 0
+    ;;
+  -F | --fr | --fro | --from)
+    if test $# -eq 1; then
+      do_missing_arg "$1"
+    fi
+    shift
+    SOTRUSS_FROMLIST="$2"
+    ;;
+  -T | --t | --to)
+    if test $# -eq 1; then
+      do_missing_arg "$1"
+    fi
+    shift
+    SOTRUSS_TOLIST="$2"
+    ;;
+  -o | --o | --ou | --out | --outp | --outpu | --output)
+    if test $# -eq 1; then
+      do_missing_arg "$1"
+    fi
+    shift
+    SOTRUSS_OUTNAME="$1"
+    ;;
+  -f | --fo | --fol | --foll | --follo | --follow)
+    unset SOTRUSS_WHICH
+    ;;
+  -l | --l | --li | --lib)
+    if test $# -eq 1; then
+      do_missing_arg "$1"
+    fi
+    shift
+    lib="$1"
+    ;;
+  -e | --e | --ex | --exi | --exit)
+    SOTRUSS_EXIT=1
+    ;;
+  --f)
+    do_ambiguous '--from' '--follow'
+    ;;
+  --)
+    shift
+    break
+    ;;
+  -*)
+    printf >&2 $"%s: unrecognized option '%c%s'\n" sotruss '-' ${1#-}
+    printf >&2 $"Try \`%s --help' or \`%s --usage' for more information.\n" sotruss sotruss
+    exit 1
+    ;;
+  *)
+    break
+    ;;
+  esac
+  shift
+done
+
+export SOTRUSS_FROMLIST
+export SOTRUSS_TOLIST
+export SOTRUSS_OUTNAME
+export SOTRUSS_WHICH
+export SOTRUSS_EXIT
+export LD_AUDIT="$lib"
+
+exec "$@"
+# Local Variables:
+#  mode:ksh
+# End:

Propchange: fsf/trunk/libc/elf/sotruss.ksh
------------------------------------------------------------------------------
    svn:executable = *

Propchange: fsf/trunk/libc/elf/sotruss.ksh
------------------------------------------------------------------------------
    svn:mime-type = text/script

Modified: fsf/trunk/libc/locale/findlocale.c
==============================================================================
--- fsf/trunk/libc/locale/findlocale.c (original)
+++ fsf/trunk/libc/locale/findlocale.c Sun May 29 00:35:10 2011
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996-2001, 2002, 2003, 2006, 2010 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2003, 2006, 2010, 2011 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@xxxxxxxxxx>, 1996.
 
@@ -140,6 +140,9 @@
    */
   mask = _nl_explode_name (loc_name, &language, &modifier, &territory,
 			   &codeset, &normalized_codeset);
+  if (mask == -1)
+    /* Memory allocate problem.  */
+    return NULL;
 
   /* If exactly this locale was already asked for we have an entry with
      the complete name.  */

Modified: fsf/trunk/libc/locale/programs/locarchive.c
==============================================================================
--- fsf/trunk/libc/locale/programs/locarchive.c (original)
+++ fsf/trunk/libc/locale/programs/locarchive.c Sun May 29 00:35:10 2011
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2005, 2007, 2009 Free Software Foundation, Inc.
+/* Copyright (C) 2002,2003,2005,2007,2009,2011 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@xxxxxxxxxx>, 2002.
 
@@ -1079,6 +1079,8 @@
   int mask = _nl_explode_name (strdupa (name),
 			       &language, &modifier, &territory,
 			       &codeset, &normalized_codeset);
+  if (mask == -1)
+    return -1;
 
   if (mask & XPG_NORM_CODESET)
     /* This name contains a codeset in unnormalized form.
@@ -1128,6 +1130,7 @@
 
   /* Now read the locale.alias files looking for lines whose
      right hand side matches our name after normalization.  */
+  int result = 0;
   if (alias_file != NULL)
     {
       FILE *fp;
@@ -1207,6 +1210,11 @@
 						     &rhs_territory,
 						     &rhs_codeset,
 						     &rhs_normalized_codeset);
+		    if (rhs_mask == 1)
+		      {
+			result = -1;
+			goto out;
+		      }
 		    if (!strcmp (language, rhs_language)
 			&& ((rhs_mask & XPG_CODESET)
 			    /* He has a codeset, it must match normalized.  */
@@ -1240,6 +1248,7 @@
 	    }
 	}
 
+    out:
       fclose (fp);
     }
 
@@ -1248,7 +1257,7 @@
   if (mask & XPG_NORM_CODESET)
     free ((char *) normalized_codeset);
 
-  return 0;
+  return result;
 }
 
 

Modified: fsf/trunk/libc/malloc/memusage.sh
==============================================================================
--- fsf/trunk/libc/malloc/memusage.sh (original)
+++ fsf/trunk/libc/malloc/memusage.sh Sun May 29 00:35:10 2011
@@ -24,13 +24,13 @@
 
 # Print usage message.
 do_usage() {
-  echo >&2 $"Try \`memusage --help' for more information."
+  printf >&2 $"Try \`%s --help' or `%s --usage' for more information.\n" memusage memusage
   exit 1
 }
 
 # Message for missing argument.
 do_missing_arg() {
-  echo >&2 $"memusage: option \`$1' requires an argument"
+  printf >&2 $"%s: option '%s' requires an argument\n" memusage "$1"
   do_usage
 }
 

Modified: fsf/trunk/libc/posix/Makefile
==============================================================================
--- fsf/trunk/libc/posix/Makefile (original)
+++ fsf/trunk/libc/posix/Makefile Sun May 29 00:35:10 2011
@@ -82,7 +82,7 @@
 		   bug-regex17 bug-regex18 bug-regex19 bug-regex20 \
 		   bug-regex21 bug-regex22 bug-regex23 bug-regex24 \
 		   bug-regex25 bug-regex26 bug-regex27 bug-regex28 \
-		   bug-regex29 bug-regex30 bug-regex31 \
+		   bug-regex29 bug-regex30 bug-regex31 bug-regex32 \
 		   tst-nice tst-nanosleep tst-regex2 \
 		   transbug tst-rxspencer tst-pcre tst-boost \
 		   bug-ga1 tst-vfork1 tst-vfork2 tst-vfork3 tst-waitid \

Added: fsf/trunk/libc/posix/bug-regex32.c
==============================================================================
--- fsf/trunk/libc/posix/bug-regex32.c (added)
+++ fsf/trunk/libc/posix/bug-regex32.c Sun May 29 00:35:10 2011
@@ -1,0 +1,36 @@
+// BZ 12811
+#include <regex.h>
+#include <stdio.h>
+#include <locale.h>
+
+static int
+do_test (void)
+{
+  char buf[1000];
+  regex_t preg;
+  if (setlocale (LC_CTYPE, "de_DE.UTF-8") == NULL)
+    {
+      puts ("setlocale failed");
+      return 1;
+    }
+
+  int e = regcomp (&preg, ".*ab", REG_ICASE);
+  if (e != 0)
+    {
+      regerror (e, &preg, buf, sizeof (buf));
+      printf ("regcomp = %d \"%s\"\n", e, buf);
+      return 1;
+    }
+
+  // Incomplete character at the end of the buffer
+  e = regexec (&preg, "aaaaaaaaaaaa\xc4", 0, NULL, 0);
+
+  regfree (&preg);
+  regerror (e, &preg, buf, sizeof (buf));
+  printf ("regexec = %d \"%s\"\n", e, buf);
+
+  return e != REG_NOMATCH;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"

Propchange: fsf/trunk/libc/posix/bug-regex32.c
------------------------------------------------------------------------------
    svn:mime-type = text/cpp

Modified: fsf/trunk/libc/posix/glob.c
==============================================================================
--- fsf/trunk/libc/posix/glob.c (original)
+++ fsf/trunk/libc/posix/glob.c Sun May 29 00:35:10 2011
@@ -762,7 +762,6 @@
 	  char *end_name = strchr (dirname, '/');
 	  char *user_name;
 	  int malloc_user_name = 0;
-	  const char *home_dir;
 	  char *unescape = NULL;
 
 	  if (!(flags & GLOB_NOESCAPE))

Modified: fsf/trunk/libc/posix/regex_internal.c
==============================================================================
--- fsf/trunk/libc/posix/regex_internal.c (original)
+++ fsf/trunk/libc/posix/regex_internal.c Sun May 29 00:35:10 2011
@@ -237,13 +237,8 @@
       else
 	p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx;
       mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state);
-      if (BE (mbclen == (size_t) -2, 0))
-	{
-	  /* The buffer doesn't have enough space, finish to build.  */
-	  pstr->cur_state = prev_st;
-	  break;
-	}
-      else if (BE (mbclen == (size_t) -1 || mbclen == 0, 0))
+      if (BE (mbclen == (size_t) -1 || mbclen == 0
+	      || (mbclen == (size_t) -2 && pstr->bufs_len >= pstr->len), 0))
 	{
 	  /* We treat these cases as a singlebyte character.  */
 	  mbclen = 1;
@@ -251,6 +246,12 @@
 	  if (BE (pstr->trans != NULL, 0))
 	    wc = pstr->trans[wc];
 	  pstr->cur_state = prev_st;
+	}
+      else if (BE (mbclen == (size_t) -2, 0))
+	{
+	  /* The buffer doesn't have enough space, finish to build.  */
+	  pstr->cur_state = prev_st;
+	  break;
 	}
 
       /* Write wide character and padding.  */
@@ -334,9 +335,11 @@
 	      for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;)
 		pstr->wcs[byte_idx++] = WEOF;
 	    }
-	  else if (mbclen == (size_t) -1 || mbclen == 0)
+	  else if (mbclen == (size_t) -1 || mbclen == 0
+		   || (mbclen == (size_t) -2 && pstr->bufs_len >= pstr->len))
 	    {
-	      /* It is an invalid character or '\0'.  Just use the byte.  */
+	      /* It is an invalid character, an incomplete character
+		 at the end of the string, or '\0'.  Just use the byte.  */
 	      int ch = pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx];
 	      pstr->mbs[byte_idx] = ch;
 	      /* And also cast it to wide char.  */
@@ -449,7 +452,8 @@
 	    for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;)
 	      pstr->wcs[byte_idx++] = WEOF;
 	  }
-	else if (mbclen == (size_t) -1 || mbclen == 0)
+	else if (mbclen == (size_t) -1 || mbclen == 0
+		 || (mbclen == (size_t) -2 && pstr->bufs_len >= pstr->len))
 	  {
 	    /* It is an invalid character or '\0'.  Just use the byte.  */
 	    int ch = pstr->raw_mbs[pstr->raw_mbs_idx + src_idx];

Modified: fsf/trunk/libc/posix/regexec.c
==============================================================================
--- fsf/trunk/libc/posix/regexec.c (original)
+++ fsf/trunk/libc/posix/regexec.c Sun May 29 00:35:10 2011
@@ -1,5 +1,5 @@
 /* Extended regular expression matching and search library.
-   Copyright (C) 2002-2005, 2007, 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 2002-2005,2007,2009,2010,2011 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Isamu Hasegawa <isamu@xxxxxxxxxxxxxx>.
 
@@ -1156,7 +1156,8 @@
       re_dfastate_t *old_state = cur_state;
       int next_char_idx = re_string_cur_idx (&mctx->input) + 1;
 
-      if (BE (next_char_idx >= mctx->input.bufs_len, 0)
+      if ((BE (next_char_idx >= mctx->input.bufs_len, 0)
+	   && mctx->input.bufs_len < mctx->input.len)
 	  || (BE (next_char_idx >= mctx->input.valid_len, 0)
 	      && mctx->input.valid_len < mctx->input.len))
 	{
@@ -1732,7 +1733,8 @@
 {
   int top = mctx->state_log_top;
 
-  if (next_state_log_idx >= mctx->input.bufs_len
+  if ((next_state_log_idx >= mctx->input.bufs_len
+       && mctx->input.bufs_len < mctx->input.len)
       || (next_state_log_idx >= mctx->input.valid_len
 	  && mctx->input.valid_len < mctx->input.len))
     {
@@ -4111,7 +4113,7 @@
     return REG_ESPACE;
 
   /* Double the lengthes of the buffers.  */
-  ret = re_string_realloc_buffers (pstr, pstr->bufs_len * 2);
+  ret = re_string_realloc_buffers (pstr, MIN (pstr->len, pstr->bufs_len * 2));
   if (BE (ret != REG_NOERROR, 0))
     return ret;
 

Modified: fsf/trunk/libc/sysdeps/unix/sysv/linux/socketcall.h
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/sysv/linux/socketcall.h (original)
+++ fsf/trunk/libc/sysdeps/unix/sysv/linux/socketcall.h Sun May 29 00:35:10 2011
@@ -1,5 +1,5 @@
 /* ID for functions called via socketcall system call.
-   Copyright (C) 1995, 1996, 2008, 2009 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 2008, 2009, 2011 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -45,5 +45,6 @@
 #define SOCKOP_recvmsg		17
 #define SOCKOP_accept4		18
 #define SOCKOP_recvmmsg		19
+#define SOCKOP_sendmmsg		20
 
 #endif /* sys/socketcall.h */