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.
This commit is contained in:
Ulrich Drepper 2004-06-01 22:18:24 +00:00
parent 9ddfc0595a
commit 322861e8b6
6 changed files with 72 additions and 33 deletions

View File

@ -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> 2004-05-10 Jakub Jelinek <jakub@redhat.com>
* sysdeps/posix/sysconf.c (__sysconf) <cases _SC_REALTIME_SIGNALS, * sysdeps/posix/sysconf.c (__sysconf) <cases _SC_REALTIME_SIGNALS,

View File

@ -1034,7 +1034,9 @@ parse_conf_include (const char *config_file, unsigned int lineno,
char *copy = NULL; char *copy = NULL;
if (pattern[0] != '/' && strchr (config_file, '/') != 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; pattern = copy;
} }

View File

@ -364,14 +364,15 @@ more_help (int key, const char *text, void *input)
{ {
case ARGP_KEY_HELP_EXTRA: case ARGP_KEY_HELP_EXTRA:
/* We print some extra information. */ /* We print some extra information. */
asprintf (&cp, gettext ("\ if (asprintf (&cp, gettext ("\
System's directory for character maps : %s\n\ System's directory for character maps : %s\n\
repertoire maps: %s\n\ repertoire maps: %s\n\
locale path : %s\n\ locale path : %s\n\
%s"), %s"),
CHARMAP_PATH, REPERTOIREMAP_PATH, LOCALE_PATH, gettext ("\ CHARMAP_PATH, REPERTOIREMAP_PATH, LOCALE_PATH, gettext ("\
For bug reporting instructions, please see:\n\ 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; return cp;
default: default:
break; break;

View File

@ -145,8 +145,10 @@ arg_service_list (const char *fname, int line_num, const char *args,
{ {
char *buf; char *buf;
__asprintf (&buf, _("%s: line %d: expected service, found `%s'\n"), if (__asprintf (&buf,
fname, line_num, start); _("%s: line %d: expected service, found `%s'\n"),
fname, line_num, start) < 0)
return 0;
#ifdef USE_IN_LIBIO #ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0) if (_IO_fwide (stderr, 0) > 0)
@ -162,9 +164,10 @@ arg_service_list (const char *fname, int line_num, const char *args,
{ {
char *buf; char *buf;
__asprintf (&buf, if (__asprintf (&buf, _("\
_("%s: line %d: cannot specify more than %d services"), %s: line %d: cannot specify more than %d services"),
fname, line_num, SERVICE_MAX); fname, line_num, SERVICE_MAX) < 0)
return 0;
#ifdef USE_IN_LIBIO #ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0) if (_IO_fwide (stderr, 0) > 0)
@ -189,9 +192,10 @@ arg_service_list (const char *fname, int line_num, const char *args,
{ {
char *buf; char *buf;
__asprintf (&buf, _("\ if (__asprintf (&buf, _("\
%s: line %d: list delimiter not followed by keyword"), %s: line %d: list delimiter not followed by keyword"),
fname, line_num); fname, line_num) < 0)
return 0;
#ifdef USE_IN_LIBIO #ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0) if (_IO_fwide (stderr, 0) > 0)
@ -229,9 +233,10 @@ arg_trimdomain_list (const char *fname, int line_num, const char *args,
{ {
char *buf; char *buf;
__asprintf (&buf, _("\ if (__asprintf (&buf, _("\
%s: line %d: cannot specify more than %d trim domains"), %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 #ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0) if (_IO_fwide (stderr, 0) > 0)
@ -254,9 +259,10 @@ arg_trimdomain_list (const char *fname, int line_num, const char *args,
{ {
char *buf; char *buf;
__asprintf (&buf, _("\ if (__asprintf (&buf, _("\
%s: line %d: list delimiter not followed by domain"), %s: line %d: list delimiter not followed by domain"),
fname, line_num); fname, line_num) < 0)
return 0;
#ifdef USE_IN_LIBIO #ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0) 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; char *buf;
__asprintf (&buf, if (__asprintf (&buf,
_("%s: line %d: expected `on' or `off', found `%s'\n"), _("%s: line %d: expected `on' or `off', found `%s'\n"),
fname, line_num, args); fname, line_num, args) < 0)
return 0;
#ifdef USE_IN_LIBIO #ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0) if (_IO_fwide (stderr, 0) > 0)
@ -364,8 +371,9 @@ parse_line (const char *fname, int line_num, const char *str)
{ {
char *buf; char *buf;
__asprintf (&buf, _("%s: line %d: bad command `%s'\n"), if (__asprintf (&buf, _("%s: line %d: bad command `%s'\n"),
fname, line_num, start); fname, line_num, start) < 0)
return;
#ifdef USE_IN_LIBIO #ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0) if (_IO_fwide (stderr, 0) > 0)
@ -392,9 +400,10 @@ parse_line (const char *fname, int line_num, const char *str)
{ {
char *buf; char *buf;
__asprintf (&buf, if (__asprintf (&buf,
_("%s: line %d: ignoring trailing garbage `%s'\n"), _("%s: line %d: ignoring trailing garbage `%s'\n"),
fname, line_num, str); fname, line_num, str) < 0)
break;
#ifdef USE_IN_LIBIO #ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0) if (_IO_fwide (stderr, 0) > 0)

View File

@ -57,7 +57,13 @@ psignal (int sig, const char *s)
{ {
char *buf; 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) if (_IO_fwide (stderr, 0) > 0)
(void) __fwprintf (stderr, L"%s", buf); (void) __fwprintf (stderr, L"%s", buf);

View File

@ -84,8 +84,9 @@ registerrpc (u_long prognum, u_long versnum, u_long procnum,
if (procnum == NULLPROC) if (procnum == NULLPROC)
{ {
(void) __asprintf (&buf, _("can't reassign procedure number %ld\n"), if (__asprintf (&buf, _("can't reassign procedure number %ld\n"),
NULLPROC); NULLPROC) < 0)
buf = NULL;
goto err_out; goto err_out;
} }
if (transp == 0) 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, if (!svc_register (transp, (u_long) prognum, (u_long) versnum,
universal, IPPROTO_UDP)) universal, IPPROTO_UDP))
{ {
(void) __asprintf (&buf, _("couldn't register prog %ld vers %ld\n"), if (__asprintf (&buf, _("couldn't register prog %ld vers %ld\n"),
prognum, versnum); prognum, versnum) < 0)
buf = NULL;
goto err_out; goto err_out;
} }
pl = (struct proglst_ *) malloc (sizeof (struct proglst_)); pl = (struct proglst_ *) malloc (sizeof (struct proglst_));
@ -121,6 +123,8 @@ registerrpc (u_long prognum, u_long versnum, u_long procnum,
return 0; return 0;
err_out: err_out:
if (buf == NULL)
return -1;
#ifdef USE_IN_LIBIO #ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0) if (_IO_fwide (stderr, 0) > 0)
(void) __fwprintf (stderr, L"%s", buf); (void) __fwprintf (stderr, L"%s", buf);
@ -171,16 +175,20 @@ universal (struct svc_req *rqstp, SVCXPRT *transp_l)
return; return;
if (!INTUSE(svc_sendreply) (transp_l, pl->p_outproc, outdata)) if (!INTUSE(svc_sendreply) (transp_l, pl->p_outproc, outdata))
{ {
(void) __asprintf (&buf, if (__asprintf (&buf, _("trouble replying to prog %d\n"),
_("trouble replying to prog %d\n"), pl->p_prognum) < 0)
pl->p_prognum); buf = NULL;
exit (1); goto err_out2;
} }
/* free the decoded arguments */ /* free the decoded arguments */
(void) svc_freeargs (transp_l, pl->p_inproc, xdrbuf); (void) svc_freeargs (transp_l, pl->p_inproc, xdrbuf);
return; 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 #ifdef USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0) if (_IO_fwide (stderr, 0) > 0)
__fwprintf (stderr, L"%s", buf); __fwprintf (stderr, L"%s", buf);