diff options
author | Ulrich Drepper <drepper@redhat.com> | 2001-12-06 08:49:08 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2001-12-06 08:49:08 +0000 |
commit | 383bd1c5033b466ffcc1a0be766d8a8b003c73e9 (patch) | |
tree | 06aec2446da55eee38518fb8296728d0910f258d /inet | |
parent | 1e06620a7b9c6c65284c52b4625eabd23b14c77c (diff) | |
download | glibc-383bd1c5033b466ffcc1a0be766d8a8b003c73e9.zip glibc-383bd1c5033b466ffcc1a0be766d8a8b003c73e9.tar.gz glibc-383bd1c5033b466ffcc1a0be766d8a8b003c73e9.tar.bz2 |
Update.
2001-12-06 Ulrich Drepper <drepper@redhat.com>
* libio/vasprintf.c (_IO_vasprintf): Free buffer on failure.
* assert/assert.c: Check result of __asprintf call and don't use
string if it failed.
* assert/assert-perr.c: Likewise.
* inet/rcmd.c: Likewise.
* locale/programs/localedef.c (main): Check result of
construct_output_path and exit if it failed.
(construct_output_path): Check result of asprintf and mkdir calls and
fail if they failed.
* posix/getopt.c: Check result of __asprintf calls and fail if
they failed.
Patch by Dmitry V. Levin <ldv@alt-linux.org>.
Diffstat (limited to 'inet')
-rw-r--r-- | inet/rcmd.c | 105 |
1 files changed, 60 insertions, 45 deletions
diff --git a/inet/rcmd.c b/inet/rcmd.c index 2c0a34d..4010bac 100644 --- a/inet/rcmd.c +++ b/inet/rcmd.c @@ -206,13 +206,17 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) NULL, 0, NI_NUMERICHOST); - __asprintf (&buf, _("connect to address %s: "), paddr); + if (__asprintf (&buf, _("connect to address %s: "), + paddr) >= 0) + { #ifdef USE_IN_LIBIO - if (_IO_fwide (stderr, 0) > 0) - __fwprintf(stderr, L"%s", buf); - else + if (_IO_fwide (stderr, 0) > 0) + __fwprintf(stderr, L"%s", buf); + else #endif - fputs (buf, stderr); + fputs (buf, stderr); + free (buf); + } __set_errno (oerrno); perror(0); ai = ai->ai_next; @@ -220,14 +224,16 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) paddr, sizeof(paddr), NULL, 0, NI_NUMERICHOST); - __asprintf (&buf, _("Trying %s...\n"), paddr); + if (__asprintf (&buf, _("Trying %s...\n"), paddr) >= 0) + { #ifdef USE_IN_LIBIO - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s", buf); - else + if (_IO_fwide (stderr, 0) > 0) + __fwprintf (stderr, L"%s", buf); + else #endif - fputs (buf, stderr); - free (buf); + fputs (buf, stderr); + free (buf); + } continue; } if (refused && timo <= 16) { @@ -267,15 +273,17 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af) if (__write(s, num, strlen(num)+1) != (ssize_t)strlen(num)+1) { char *buf = NULL; - __asprintf (&buf, _("\ -rcmd: write (setting up stderr): %m\n")); + if (__asprintf (&buf, _("\ +rcmd: write (setting up stderr): %m\n")) >= 0) + { #ifdef USE_IN_LIBIO - if (_IO_fwide (stderr, 0) > 0) - __fwprintf(stderr, L"%s", buf); - else + if (_IO_fwide (stderr, 0) > 0) + __fwprintf(stderr, L"%s", buf); + else #endif - fputs (buf, stderr); - free (buf); + fputs (buf, stderr); + free (buf); + } (void)__close(s2); goto bad; } @@ -285,19 +293,21 @@ rcmd: write (setting up stderr): %m\n")); if (__poll (pfd, 2, -1) < 1 || (pfd[1].revents & POLLIN) == 0){ char *buf = NULL; - if (errno != 0) - __asprintf(&buf, - _("rcmd: poll (setting up stderr): %m\n")); - else - __asprintf(&buf, - _("poll: protocol failure in circuit setup\n")); + if ((errno != 0 + && __asprintf(&buf, _("\ +rcmd: poll (setting up stderr): %m\n")) >= 0) + || (errno == 0 + && __asprintf(&buf, _("\ +poll: protocol failure in circuit setup\n")) >= 0)) + { #ifdef USE_IN_LIBIO - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s", buf); - else + if (_IO_fwide (stderr, 0) > 0) + __fwprintf (stderr, L"%s", buf); + else #endif - fputs (buf, stderr); - free (buf); + fputs (buf, stderr); + free (buf); + } (void)__close(s2); goto bad; } @@ -331,15 +341,17 @@ rcmd: write (setting up stderr): %m\n")); if (rport >= IPPORT_RESERVED || rport < IPPORT_RESERVED / 2){ char *buf = NULL; - __asprintf(&buf, - _("socket: protocol failure in circuit setup\n")); + if (__asprintf(&buf, _("\ +socket: protocol failure in circuit setup\n")) >= 0) + { #ifdef USE_IN_LIBIO - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s", buf); - else + if (_IO_fwide (stderr, 0) > 0) + __fwprintf (stderr, L"%s", buf); + else #endif - fputs (buf, stderr); - free (buf); + fputs (buf, stderr); + free (buf); + } goto bad2; } } @@ -350,17 +362,20 @@ rcmd: write (setting up stderr): %m\n")); if (n != 1) { char *buf = NULL; - if (n == 0) - __asprintf(&buf, _("rcmd: %s: short read"), *ahost); - else - __asprintf(&buf, "rcmd: %s: %m\n", *ahost); + if ((n == 0 + && __asprintf(&buf, _("rcmd: %s: short read"), + *ahost) >= 0) + || (n != 0 + && __asprintf(&buf, "rcmd: %s: %m\n", *ahost) >= 0)) + { #ifdef USE_IN_LIBIO - if (_IO_fwide (stderr, 0) > 0) - __fwprintf (stderr, L"%s", buf); - else + if (_IO_fwide (stderr, 0) > 0) + __fwprintf (stderr, L"%s", buf); + else #endif - fputs (buf, stderr); - free (buf); + fputs (buf, stderr); + free (buf); + } goto bad2; } if (c != 0) { |