Update.
authorUlrich Drepper <drepper@redhat.com>
Tue, 1 Jun 2004 22:18:24 +0000 (22:18 +0000)
committerUlrich Drepper <drepper@redhat.com>
Tue, 1 Jun 2004 22:18:24 +0000 (22:18 +0000)
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.

ChangeLog
elf/ldconfig.c
locale/programs/localedef.c
resolv/res_hconf.c
stdio-common/psignal.c
sunrpc/svc_simple.c

index 745dc0e..4f38604 100644 (file)
--- 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,
index 222d862..bf103c7 100644 (file)
@@ -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;
     }
 
index 1c01272..28cb7b3 100644 (file)
@@ -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;
index 59f186e..91cd300 100644 (file)
@@ -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)
index 0764af5..3a75224 100644 (file)
@@ -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);
index 57bedba..5ac21ff 100644 (file)
@@ -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);