+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,
char *copy = NULL;
if (pattern[0] != '/' && strchr (config_file, '/') != NULL)
{
- asprintf (©, "%s/%s", dirname (strdupa (config_file)), pattern);
+ if (asprintf (©, "%s/%s", dirname (strdupa (config_file)),
+ pattern) < 0)
+ error (EXIT_FAILURE, 0, _("memory exhausted"));
pattern = copy;
}
{
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;
{
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)
{
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)
{
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)
{
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)
{
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)
{
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)
{
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)
{
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)
{
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);
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)
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_));
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);
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);