aboutsummaryrefslogtreecommitdiff
path: root/inet
diff options
context:
space:
mode:
Diffstat (limited to 'inet')
-rw-r--r--inet/getnetgrent.c18
-rw-r--r--inet/rcmd.c20
-rw-r--r--inet/rexec.c14
3 files changed, 26 insertions, 26 deletions
diff --git a/inet/getnetgrent.c b/inet/getnetgrent.c
index d464c10cde..07634daef2 100644
--- a/inet/getnetgrent.c
+++ b/inet/getnetgrent.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 2000, 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -21,8 +21,8 @@
#include <stdlib.h>
#include <bits/libc-lock.h>
-/* Statis buffer for return value. We allocate it when needed. */
-static char *buffer;
+/* Static buffer for return value. We allocate it when needed. */
+libc_freeres_ptr (static char *buffer);
/* All three strings should fit in a block of 1kB size. */
#define BUFSIZE 1024
@@ -48,15 +48,3 @@ getnetgrent (char **hostp, char **userp, char **domainp)
return __getnetgrent_r (hostp, userp, domainp, buffer, BUFSIZE);
}
-
-
-/* Make sure the memory is freed if the programs ends while in
- memory-debugging mode and something actually was allocated. */
-static void
-__attribute__ ((unused))
-free_mem (void)
-{
- free (buffer);
-}
-
-text_set_element (__libc_subfreeres, free_mem);
diff --git a/inet/rcmd.c b/inet/rcmd.c
index 08d9337431..eed5ed389e 100644
--- a/inet/rcmd.c
+++ b/inet/rcmd.c
@@ -101,7 +101,7 @@ int iruserok (u_int32_t raddr, int superuser, const char *ruser,
libc_hidden_proto (iruserok_af)
-static char ahostbuf[NI_MAXHOST];
+libc_freeres_ptr(static char *ahostbuf);
int
rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
@@ -153,11 +153,21 @@ rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
pfd[1].events = POLLIN;
if (res->ai_canonname){
- strncpy(ahostbuf, res->ai_canonname, sizeof(ahostbuf));
- ahostbuf[sizeof(ahostbuf)-1] = '\0';
+ free (ahostbuf);
+ ahostbuf = strdup (res->ai_canonname);
+ if (ahostbuf == NULL) {
+#ifdef USE_IN_LIBIO
+ if (_IO_fwide (stderr, 0) > 0)
+ __fwprintf(stderr, L"%s",
+ _("rcmd: Cannot allocate memory\n"));
+ else
+#endif
+ fputs(_("rcmd: Cannot allocate memory\n"),
+ stderr);
+ return (-1);
+ }
*ahost = ahostbuf;
- }
- else
+ } else
*ahost = NULL;
ai = res;
refused = 0;
diff --git a/inet/rexec.c b/inet/rexec.c
index 8f6190a834..c6b432a6f8 100644
--- a/inet/rexec.c
+++ b/inet/rexec.c
@@ -45,7 +45,7 @@ static char sccsid[] = "@(#)rexec.c 8.1 (Berkeley) 6/4/93";
#include <unistd.h>
int rexecoptions;
-static char ahostbuf[NI_MAXHOST];
+libc_freeres_ptr (static char *ahostbuf);
int
rexec_af(ahost, rport, name, pass, cmd, fd2p, af)
@@ -79,13 +79,15 @@ rexec_af(ahost, rport, name, pass, cmd, fd2p, af)
}
if (res0->ai_canonname){
- strncpy(ahostbuf, res0->ai_canonname, sizeof(ahostbuf));
- ahostbuf[sizeof(ahostbuf)-1] = '\0';
+ free (ahostbuf);
+ ahostbuf = strdup (res0->ai_canonname);
+ if (ahostbuf == NULL) {
+ perror ("rexec: strdup");
+ return (-1);
+ }
*ahost = ahostbuf;
- }
- else{
+ } else
*ahost = NULL;
- }
ruserpass(res0->ai_canonname, &name, &pass);
retry:
s = __socket(res0->ai_family, res0->ai_socktype, 0);