about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rw-r--r--elf/ldconfig.c4
-rw-r--r--locale/programs/localedef.c7
-rw-r--r--resolv/res_hconf.c47
-rw-r--r--stdio-common/psignal.c8
-rw-r--r--sunrpc/svc_simple.c26
6 files changed, 72 insertions, 33 deletions
diff --git a/ChangeLog b/ChangeLog
index 745dc0e2c1..4f38604c52 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2004-05-07  Dmitry V. Levin  <ldv@altlinux.org>
+
+	* argp/argp-help.c (__argp_error, __argp_failure): Check result
+	of __asprintf call and don't use string if it failed.
+	* stdio-common/psignal.c (psignal): Likewise.
+	* locale/programs/localedef.c (more_help): Likewise.
+	* resolv/res_hconf.c (arg_service_list, arg_trimdomain_list,
+	arg_bool, parse_line): Check result of __asprintf calls and
+	don't use string if they failed.
+	* sunrpc/svc_simple.c (registerrpc, universal): Likewise.
+	* elf/ldconfig.c (parse_conf_include): Check result of __asprintf
+	call and exit if it failed.
+
 2004-05-10  Jakub Jelinek  <jakub@redhat.com>
 
 	* sysdeps/posix/sysconf.c (__sysconf) <cases _SC_REALTIME_SIGNALS,
diff --git a/elf/ldconfig.c b/elf/ldconfig.c
index 222d862bd2..bf103c7269 100644
--- a/elf/ldconfig.c
+++ b/elf/ldconfig.c
@@ -1034,7 +1034,9 @@ parse_conf_include (const char *config_file, unsigned int lineno,
   char *copy = NULL;
   if (pattern[0] != '/' && strchr (config_file, '/') != NULL)
     {
-      asprintf (&copy, "%s/%s", dirname (strdupa (config_file)), pattern);
+      if (asprintf (&copy, "%s/%s", dirname (strdupa (config_file)),
+		    pattern) < 0)
+	error (EXIT_FAILURE, 0, _("memory exhausted"));
       pattern = copy;
     }
 
diff --git a/locale/programs/localedef.c b/locale/programs/localedef.c
index 1c01272e2a..28cb7b316e 100644
--- a/locale/programs/localedef.c
+++ b/locale/programs/localedef.c
@@ -364,14 +364,15 @@ more_help (int key, const char *text, void *input)
     {
     case ARGP_KEY_HELP_EXTRA:
       /* We print some extra information.  */
-      asprintf (&cp, gettext ("\
+      if (asprintf (&cp, gettext ("\
 System's directory for character maps : %s\n\
                        repertoire maps: %s\n\
                        locale path    : %s\n\
 %s"),
-		CHARMAP_PATH, REPERTOIREMAP_PATH, LOCALE_PATH, gettext ("\
+		    CHARMAP_PATH, REPERTOIREMAP_PATH, LOCALE_PATH, gettext ("\
 For bug reporting instructions, please see:\n\
-<http://www.gnu.org/software/libc/bugs.html>.\n"));
+<http://www.gnu.org/software/libc/bugs.html>.\n")) < 0)
+	return NULL;
       return cp;
     default:
       break;
diff --git a/resolv/res_hconf.c b/resolv/res_hconf.c
index 59f186e246..91cd300482 100644
--- a/resolv/res_hconf.c
+++ b/resolv/res_hconf.c
@@ -145,8 +145,10 @@ arg_service_list (const char *fname, int line_num, const char *args,
 	{
 	  char *buf;
 
-	  __asprintf (&buf, _("%s: line %d: expected service, found `%s'\n"),
-		      fname, line_num, start);
+	  if (__asprintf (&buf,
+			  _("%s: line %d: expected service, found `%s'\n"),
+			  fname, line_num, start) < 0)
+	    return 0;
 
 #ifdef USE_IN_LIBIO
 	  if (_IO_fwide (stderr, 0) > 0)
@@ -162,9 +164,10 @@ arg_service_list (const char *fname, int line_num, const char *args,
 	{
 	  char *buf;
 
-	  __asprintf (&buf,
-		      _("%s: line %d: cannot specify more than %d services"),
-		      fname, line_num, SERVICE_MAX);
+	  if (__asprintf (&buf, _("\
+%s: line %d: cannot specify more than %d services"),
+			  fname, line_num, SERVICE_MAX) < 0)
+	    return 0;
 
 #ifdef USE_IN_LIBIO
 	  if (_IO_fwide (stderr, 0) > 0)
@@ -189,9 +192,10 @@ arg_service_list (const char *fname, int line_num, const char *args,
 	    {
 	      char *buf;
 
-	      __asprintf (&buf, _("\
+	      if (__asprintf (&buf, _("\
 %s: line %d: list delimiter not followed by keyword"),
-			  fname, line_num);
+			      fname, line_num) < 0)
+		return 0;
 
 #ifdef USE_IN_LIBIO
 	      if (_IO_fwide (stderr, 0) > 0)
@@ -229,9 +233,10 @@ arg_trimdomain_list (const char *fname, int line_num, const char *args,
 	{
 	  char *buf;
 
-	  __asprintf (&buf, _("\
+	  if (__asprintf (&buf, _("\
 %s: line %d: cannot specify more than %d trim domains"),
-		      fname, line_num, TRIMDOMAINS_MAX);
+			  fname, line_num, TRIMDOMAINS_MAX) < 0)
+	    return 0;
 
 #ifdef USE_IN_LIBIO
 	      if (_IO_fwide (stderr, 0) > 0)
@@ -254,9 +259,10 @@ arg_trimdomain_list (const char *fname, int line_num, const char *args,
 	    {
 	      char *buf;
 
-	      __asprintf (&buf, _("\
+	      if (__asprintf (&buf, _("\
 %s: line %d: list delimiter not followed by domain"),
-			  fname, line_num);
+			      fname, line_num) < 0)
+		return 0;
 
 #ifdef USE_IN_LIBIO
 	      if (_IO_fwide (stderr, 0) > 0)
@@ -316,9 +322,10 @@ arg_bool (const char *fname, int line_num, const char *args, unsigned flag)
     {
       char *buf;
 
-      __asprintf (&buf,
-		  _("%s: line %d: expected `on' or `off', found `%s'\n"),
-		  fname, line_num, args);
+      if (__asprintf (&buf,
+		      _("%s: line %d: expected `on' or `off', found `%s'\n"),
+		      fname, line_num, args) < 0)
+	return 0;
 
 #ifdef USE_IN_LIBIO
       if (_IO_fwide (stderr, 0) > 0)
@@ -364,8 +371,9 @@ parse_line (const char *fname, int line_num, const char *str)
     {
       char *buf;
 
-      __asprintf (&buf, _("%s: line %d: bad command `%s'\n"),
-		  fname, line_num, start);
+      if (__asprintf (&buf, _("%s: line %d: bad command `%s'\n"),
+		      fname, line_num, start) < 0)
+	return;
 
 #ifdef USE_IN_LIBIO
       if (_IO_fwide (stderr, 0) > 0)
@@ -392,9 +400,10 @@ parse_line (const char *fname, int line_num, const char *str)
 	  {
 	    char *buf;
 
-	    __asprintf (&buf,
-			_("%s: line %d: ignoring trailing garbage `%s'\n"),
-			fname, line_num, str);
+	    if (__asprintf (&buf,
+			    _("%s: line %d: ignoring trailing garbage `%s'\n"),
+			    fname, line_num, str) < 0)
+	      break;
 
 #ifdef USE_IN_LIBIO
 	    if (_IO_fwide (stderr, 0) > 0)
diff --git a/stdio-common/psignal.c b/stdio-common/psignal.c
index 0764af536b..3a75224b78 100644
--- a/stdio-common/psignal.c
+++ b/stdio-common/psignal.c
@@ -57,7 +57,13 @@ psignal (int sig, const char *s)
     {
       char *buf;
 
-      (void) __asprintf (&buf, _("%s%sUnknown signal %d\n"), s, colon, sig);
+      if (__asprintf (&buf, _("%s%sUnknown signal %d\n"), s, colon, sig) < 0)
+	{
+	  if (_IO_fwide (stderr, 0) > 0)
+	    (void) __fwprintf (stderr, L"%s%s%s\n", s, colon, _("Unknown signal"));
+	  else
+	    (void) fprintf (stderr, "%s%s%s\n", s, colon, _("Unknown signal"));
+	}
 
       if (_IO_fwide (stderr, 0) > 0)
 	(void) __fwprintf (stderr, L"%s",  buf);
diff --git a/sunrpc/svc_simple.c b/sunrpc/svc_simple.c
index 57bedba163..5ac21ffdbd 100644
--- a/sunrpc/svc_simple.c
+++ b/sunrpc/svc_simple.c
@@ -84,8 +84,9 @@ registerrpc (u_long prognum, u_long versnum, u_long procnum,
   if (procnum == NULLPROC)
     {
 
-      (void) __asprintf (&buf, _("can't reassign procedure number %ld\n"),
-			 NULLPROC);
+      if (__asprintf (&buf, _("can't reassign procedure number %ld\n"),
+		      NULLPROC) < 0)
+	buf = NULL;
       goto err_out;
     }
   if (transp == 0)
@@ -101,8 +102,9 @@ registerrpc (u_long prognum, u_long versnum, u_long procnum,
   if (!svc_register (transp, (u_long) prognum, (u_long) versnum,
 		     universal, IPPROTO_UDP))
     {
-      (void) __asprintf (&buf, _("couldn't register prog %ld vers %ld\n"),
-			 prognum, versnum);
+      if (__asprintf (&buf, _("couldn't register prog %ld vers %ld\n"),
+		      prognum, versnum) < 0)
+	buf = NULL;
       goto err_out;
     }
   pl = (struct proglst_ *) malloc (sizeof (struct proglst_));
@@ -121,6 +123,8 @@ registerrpc (u_long prognum, u_long versnum, u_long procnum,
   return 0;
 
  err_out:
+  if (buf == NULL)
+    return -1;
 #ifdef USE_IN_LIBIO
   if (_IO_fwide (stderr, 0) > 0)
     (void) __fwprintf (stderr, L"%s", buf);
@@ -171,16 +175,20 @@ universal (struct svc_req *rqstp, SVCXPRT *transp_l)
 	  return;
 	if (!INTUSE(svc_sendreply) (transp_l, pl->p_outproc, outdata))
 	  {
-	    (void) __asprintf (&buf,
-			       _("trouble replying to prog %d\n"),
-			       pl->p_prognum);
-	    exit (1);
+	    if (__asprintf (&buf, _("trouble replying to prog %d\n"),
+			    pl->p_prognum) < 0)
+	      buf = NULL;
+	    goto err_out2;
 	  }
 	/* free the decoded arguments */
 	(void) svc_freeargs (transp_l, pl->p_inproc, xdrbuf);
 	return;
       }
-  (void) __asprintf (&buf, _("never registered prog %d\n"), prog);
+  if (__asprintf (&buf, _("never registered prog %d\n"), prog) < 0)
+    buf = NULL;
+ err_out2:
+  if (buf == NULL)
+    exit (1);
 #ifdef USE_IN_LIBIO
   if (_IO_fwide (stderr, 0) > 0)
     __fwprintf (stderr, L"%s", buf);