about summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/generic/getenv.c23
-rw-r--r--sysdeps/generic/prof-freq.c2
-rw-r--r--sysdeps/generic/pty.c3
-rw-r--r--sysdeps/generic/strsep.c3
-rw-r--r--sysdeps/generic/sys/sysinfo.h8
-rw-r--r--sysdeps/posix/getcwd.c4
-rw-r--r--sysdeps/posix/mk-stdiolim.c8
-rw-r--r--sysdeps/posix/tempname.c58
-rw-r--r--sysdeps/posix/ttyname.c2
-rw-r--r--sysdeps/posix/ttyname_r.c2
-rw-r--r--sysdeps/stub/getenv.c1
-rw-r--r--sysdeps/stub/nanosleep.c6
-rw-r--r--sysdeps/stub/tempname.c4
-rw-r--r--sysdeps/unix/nlist.c4
-rw-r--r--sysdeps/unix/sysv/linux/getsysstats.c9
-rw-r--r--sysdeps/unix/sysv/linux/sleep.c2
-rw-r--r--sysdeps/unix/sysv/linux/sys/sysinfo.h8
-rw-r--r--sysdeps/unix/sysv/linux/syscalls.list14
18 files changed, 98 insertions, 63 deletions
diff --git a/sysdeps/generic/getenv.c b/sysdeps/generic/getenv.c
index d4099a9733..daf292743a 100644
--- a/sysdeps/generic/getenv.c
+++ b/sysdeps/generic/getenv.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1994, 1996 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
@@ -16,7 +16,6 @@ License along with the GNU C Library; see the file COPYING.LIB.  If
 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
 Cambridge, MA 02139, USA.  */
 
-#include <ansidecl.h>
 #include <errno.h>
 #include <stdlib.h>
 #include <string.h>
@@ -28,17 +27,29 @@ Cambridge, MA 02139, USA.  */
 
 /* Return the value of the environment variable NAME.  */
 char *
-DEFUN(getenv, (name), register CONST char *name)
+getenv (name)
+     const char *name;
 {
-  register CONST size_t len = strlen(name);
-  register char **ep;
+  const size_t len = strlen (name);
+  char **ep;
 
   if (__environ == NULL)
     return NULL;
 
   for (ep = __environ; *ep != NULL; ++ep)
-    if (!strncmp(*ep, name, len) && (*ep)[len] == '=')
+    if (!strncmp (*ep, name, len) && (*ep)[len] == '=')
       return &(*ep)[len + 1];
 
   return NULL;
 }
+
+
+/* Some programs and especially the libc itself have to be careful
+   what values to accept from the environment.  This special version
+   checks for SUID or SGID first before doing any work.  */
+char *
+__secure_getenv (name)
+     const char *name;
+{
+  return __libc_enable_secure ? NULL : getenv (name);
+}
diff --git a/sysdeps/generic/prof-freq.c b/sysdeps/generic/prof-freq.c
index 4ad42124e8..ff085145b5 100644
--- a/sysdeps/generic/prof-freq.c
+++ b/sysdeps/generic/prof-freq.c
@@ -37,7 +37,7 @@
 #include <sys/time.h>
 
 int
-__profile_frequency ()
+__profile_frequency (void)
 {
   /*
    * Discover the tick frequency of the machine if something goes wrong,
diff --git a/sysdeps/generic/pty.c b/sysdeps/generic/pty.c
index dda2125836..6995417d3a 100644
--- a/sysdeps/generic/pty.c
+++ b/sysdeps/generic/pty.c
@@ -46,6 +46,7 @@ static char sccsid[] = "@(#)pty.c	8.1 (Berkeley) 6/4/93";
 #include <stdio.h>
 #include <string.h>
 #include <grp.h>
+#include <pty.h>
 
 int
 openpty(amaster, aslave, name, termp, winp)
@@ -105,7 +106,7 @@ forkpty(amaster, name, termp, winp)
 	struct termios *termp;
 	struct winsize *winp;
 {
-	extern int login_tty();
+	extern int login_tty __P ((int fd));
 	int master, slave, pid;
 
 	if (openpty(&master, &slave, name, termp, winp) == -1)
diff --git a/sysdeps/generic/strsep.c b/sysdeps/generic/strsep.c
index 6fbcb084a6..15c5891044 100644
--- a/sysdeps/generic/strsep.c
+++ b/sysdeps/generic/strsep.c
@@ -19,7 +19,7 @@ Boston, MA 02111-1307, USA.  */
 #include <string.h>
 
 char *
-strsep (char **stringp, const char *delim)
+__strsep (char **stringp, const char *delim)
 {
   char *begin, *end;
 
@@ -41,3 +41,4 @@ strsep (char **stringp, const char *delim)
 
   return begin;
 }
+weak_alias (__strsep, strsep)
diff --git a/sysdeps/generic/sys/sysinfo.h b/sysdeps/generic/sys/sysinfo.h
index e9f667499e..f68fcc032c 100644
--- a/sysdeps/generic/sys/sysinfo.h
+++ b/sysdeps/generic/sys/sysinfo.h
@@ -22,12 +22,12 @@ Boston, MA 02111-1307, USA.  */
 #include <features.h>
 
 /* Return number of configured processors.  */
-extern int __get_nproc_conf __P ((void));
-extern int get_nproc_conf __P ((void));
+extern int __get_nprocs_conf __P ((void));
+extern int get_nprocs_conf __P ((void));
 
 /* Return number of available processors.  */
-extern int __get_nproc __P ((void));
-extern int get_nproc __P ((void));
+extern int __get_nprocs __P ((void));
+extern int get_nprocs __P ((void));
 
 
 /* Return number of physical pages of memory in the system.  */
diff --git a/sysdeps/posix/getcwd.c b/sysdeps/posix/getcwd.c
index a9536b95cf..825599f370 100644
--- a/sysdeps/posix/getcwd.c
+++ b/sysdeps/posix/getcwd.c
@@ -298,7 +298,7 @@ __getcwd (buf, size)
 	      (d->d_name[1] == '\0' ||
 	       (d->d_name[1] == '.' && d->d_name[2] == '\0')))
 	    continue;
-	  if (mount_point || d->d_ino == thisino)
+	  if (mount_point || (ino_t) d->d_ino == thisino)
 	    {
 	      char name[dotlist + dotsize - dotp + 1 + _D_ALLOC_NAMLEN (d)];
 	      memcpy (name, dotp, dotlist + dotsize - dotp);
@@ -326,7 +326,7 @@ __getcwd (buf, size)
 	{
 	  size_t namlen = _D_EXACT_NAMLEN (d);
 
-	  if (pathp - path < namlen)
+	  if ((size_t) (pathp - path) < namlen)
 	    {
 	      if (buf != NULL)
 		{
diff --git a/sysdeps/posix/mk-stdiolim.c b/sysdeps/posix/mk-stdiolim.c
index da78a98394..5df460e89a 100644
--- a/sysdeps/posix/mk-stdiolim.c
+++ b/sysdeps/posix/mk-stdiolim.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1993, 1996 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
@@ -23,7 +23,7 @@ main()
 {
   /* These values correspond to the code in sysdeps/posix/tempname.c.
      Change the values here if you change that code.  */
-  printf("#define L_tmpnam %u\n", sizeof("/usr/tmp/") + 8);
+  printf("#define L_tmpnam %u\n", sizeof("/usr/tmp/") + 9);
   printf("#define TMP_MAX %u\n", 62 * 62 * 62);
 
   puts  ("#ifdef __USE_POSIX");
@@ -36,7 +36,7 @@ main()
      is the case in the Hurd).  ANSI still requires that FOPEN_MAX and
      FILENAME_MAX be defined, however.  */
 
-  printf("#define FOPEN_MAX %u\n", 
+  printf("#define FOPEN_MAX %u\n",
 #ifdef	OPEN_MAX
 
 	 OPEN_MAX
@@ -51,7 +51,7 @@ main()
 
 	 );
 
-  printf("#define FILENAME_MAX %u\n", 
+  printf("#define FILENAME_MAX %u\n",
 #ifdef	PATH_MAX
 	 PATH_MAX
 #else
diff --git a/sysdeps/posix/tempname.c b/sysdeps/posix/tempname.c
index 6fd698e2b8..d58024fe7e 100644
--- a/sysdeps/posix/tempname.c
+++ b/sysdeps/posix/tempname.c
@@ -81,21 +81,24 @@ static const char letters[] =
    existing file will be returned.  When the cycle reaches its end
    (12345ZZZ), NULL is returned.  */
 char *
-__stdio_gen_tempname (const char *dir, const char *pfx, int dir_search,
-		      size_t *lenptr, FILE **streamptr)
+__stdio_gen_tempname (char *buf, size_t bufsize, const char *dir,
+		      const char *pfx, int dir_search, size_t *lenptr,
+		      FILE **streamptr)
 {
   int saverrno = errno;
   static const char tmpdir[] = P_tmpdir;
   static size_t indices[2];
   size_t *idx;
-  static char buf[FILENAME_MAX];
+#if 0
   static pid_t oldpid = (pid_t) 0;
+#endif
   pid_t pid = __getpid();
   register size_t len, plen, dlen;
+  int wrapped;
 
   if (dir_search)
     {
-      register const char *d = getenv ("TMPDIR");
+      register const char *d = __secure_getenv ("TMPDIR");
       if (d != NULL && !diraccess (d))
 	d = NULL;
       if (d == NULL && dir != NULL && diraccess (dir))
@@ -133,34 +136,51 @@ __stdio_gen_tempname (const char *dir, const char *pfx, int dir_search,
     dir = tmpdir;
   idx = &indices[(plen == 0 && dir == tmpdir) ? 1 : 0];
 
+#if 0
+  /* XXX Is this ever useful???  At least when using a thread package
+     which uses different PIDs for the threads it is not helpful.  */
   if (pid != oldpid)
     {
       oldpid = pid;
       indices[0] = indices[1] = 0;
     }
+#endif
 
+  wrapped = 0; /* We have not yet wrapped around the index counter.  */
   len = dlen + 1 + plen + 5 + 3;
-  while (*idx < ((sizeof (letters) - 1) * (sizeof (letters) - 1) *
-		 (sizeof (letters) - 1)))
+  while (1)
     {
-      const size_t i = (*idx)++;
+      const size_t i;
+
+      if (*idx >= ((sizeof (letters) - 1) * (sizeof (letters) - 1) *
+		   (sizeof (letters) - 1)))
+	{
+	  if (wrapped)
+	    /* We really wrapped around this call.  Can't believe it
+	       but nevertheless stop the endless loop.  */
+	    break;
+
+	  indices[0] = indices[1] = 0;
+	  wrapped = 1;
+	}
+
+      i = (*idx)++;
 
       /* Construct a file name and see if it already exists.
 
 	 We use a single counter in *IDX to cycle each of three
 	 character positions through each of 62 possible letters.  */
 
-      if (sizeof (buf) < len ||
-	  sprintf (buf, "%.*s/%.*s%.5d%c%c%c",
-		   (int) dlen, dir, (int) plen,
-		   pfx, pid % 100000,
-		   letters[i % (sizeof (letters) - 1)],
-		   letters[(i / (sizeof (letters) - 1))
-			   % (sizeof (letters) - 1)],
-		   letters[(i / ((sizeof (letters) - 1) *
-				 (sizeof (letters) - 1)))
-			   % (sizeof (letters) - 1)]
-		   ) != (int) len)
+      if (__snprintf (buf, bufsize, "%.*s/%.*s%.5d%c%c%c",
+		      (int) dlen, dir, (int) plen,
+		      pfx, pid % 100000,
+		      letters[i % (sizeof (letters) - 1)],
+		      letters[(i / (sizeof (letters) - 1))
+			     % (sizeof (letters) - 1)],
+		      letters[(i / ((sizeof (letters) - 1) *
+				    (sizeof (letters) - 1)))
+			     % (sizeof (letters) - 1)]
+		    ) != (int) len)
 	return NULL;
 
       if (streamptr != NULL)
@@ -176,7 +196,7 @@ __stdio_gen_tempname (const char *dir, const char *pfx, int dir_search,
 	      struct _IO_FILE_plus *fp;
 
 	      fp = (struct _IO_FILE_plus *)
-		malloc(sizeof (struct _IO_FILE_plus));
+		malloc (sizeof (struct _IO_FILE_plus));
 	      if (fp == NULL)
 		{
 		  /* We lost trying to create a stream (out of memory?).
diff --git a/sysdeps/posix/ttyname.c b/sysdeps/posix/ttyname.c
index be82827d00..9668117b47 100644
--- a/sysdeps/posix/ttyname.c
+++ b/sysdeps/posix/ttyname.c
@@ -57,7 +57,7 @@ ttyname (fd)
     return NULL;
 
   while ((d = readdir (dirstream)) != NULL)
-    if (d->d_fileno == myino)
+    if ((ino_t) d->d_fileno == myino)
       {
 	size_t dlen = _D_ALLOC_NAMLEN (d);
 	if (sizeof (dev) + dlen > namelen)
diff --git a/sysdeps/posix/ttyname_r.c b/sysdeps/posix/ttyname_r.c
index 1fb4b047d4..d7f6026d8a 100644
--- a/sysdeps/posix/ttyname_r.c
+++ b/sysdeps/posix/ttyname_r.c
@@ -72,7 +72,7 @@ __ttyname_r (fd, buf, buflen)
   buflen -= sizeof (dev);
 
   while ((d = readdir (dirstream)) != NULL)
-    if (d->d_fileno == myino)
+    if ((ino_t) d->d_fileno == myino)
       {
 	char *cp;
 
diff --git a/sysdeps/stub/getenv.c b/sysdeps/stub/getenv.c
index fab9f08c75..f12964ed70 100644
--- a/sysdeps/stub/getenv.c
+++ b/sysdeps/stub/getenv.c
@@ -27,6 +27,7 @@ getenv (name)
   __set_errno (ENOSYS);
   return NULL;
 }
+strong_alias (getenv, __secure_getenv)
 
 
 stub_warning (getenv)
diff --git a/sysdeps/stub/nanosleep.c b/sysdeps/stub/nanosleep.c
index 0995bb9654..bdc9d28f2d 100644
--- a/sysdeps/stub/nanosleep.c
+++ b/sysdeps/stub/nanosleep.c
@@ -22,9 +22,13 @@ Boston, MA 02111-1307, USA.  */
 
 /* Pause execution for a number of nanoseconds.  */
 int
-nanosleep (const struct timespec *requested_time, struct timespec *remaining)
+__libc_nanosleep (const struct timespec *requested_time,
+		  struct timespec *remaining)
 {
   __set_errno (ENOSYS);
   return -1;
 }
 stub_warning (nanosleep)
+
+weak_alias (__libc_nanosleep, __nanosleep)
+weak_alias (__libc_nanosleep, nanosleep)
diff --git a/sysdeps/stub/tempname.c b/sysdeps/stub/tempname.c
index 939c70fb0d..e38345721e 100644
--- a/sysdeps/stub/tempname.c
+++ b/sysdeps/stub/tempname.c
@@ -26,7 +26,9 @@ Cambridge, MA 02139, USA.  */
    Return the generated filename or NULL if one could not
    be generated, putting the length of the string in *LENPTR.  */
 char *
-__stdio_gen_tempname (dir, pfx, dir_search, lenptr)
+__stdio_gen_tempname (buf, bufsize, dir, pfx, dir_search, lenptr)
+     char *buf;
+     size_t bufsize;
      const char *dir;
      const char *pfx;
      int dir_search;
diff --git a/sysdeps/unix/nlist.c b/sysdeps/unix/nlist.c
index b40aedbc82..ffdd21d796 100644
--- a/sysdeps/unix/nlist.c
+++ b/sysdeps/unix/nlist.c
@@ -26,9 +26,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
    which is terminated by an element with a NULL `n_un.n_name' member,
    and fill in the elements of NL.  */
 int
-nlist (file, nl)
-     const char *file;
-     struct nlist *nl;
+nlist (const char *file, struct nlist *nl)
 {
   FILE *f;
   struct exec header;
diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
index c4c6fd78f6..349da98e90 100644
--- a/sysdeps/unix/sysv/linux/getsysstats.c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
@@ -33,14 +33,11 @@ get_proc_path (char *buffer, size_t bufsize)
   FILE *fp;
   struct mntent mount_point;
   struct mntent *entry;
-  char *result;
+  char *result = NULL;
 
   /* First find the mount point of the proc filesystem.  */
   fp = __setmntent (_PATH_MNTTAB, "r");
-  if (fp == NULL)
-    /* Cannot find mount table file.  */
-    result = NULL;
-  else
+  if (fp != NULL)
     {
       while ((entry = __getmntent_r (fp, &mount_point, buffer, bufsize))
 	     != NULL)
@@ -108,7 +105,7 @@ weak_alias (__get_nprocs, get_nprocs)
 
 /* As far as I know Linux has no separate numbers for configured and
    available processors.  So make the `get_nprocs_conf' function an
-   prototype.  */
+   alias.  */
 strong_alias (__get_nprocs, __get_nprocs_conf)
 weak_alias (__get_nprocs, get_nprocs_conf)
 
diff --git a/sysdeps/unix/sysv/linux/sleep.c b/sysdeps/unix/sysv/linux/sleep.c
index 1094df5129..a4cf47bb0b 100644
--- a/sysdeps/unix/sysv/linux/sleep.c
+++ b/sysdeps/unix/sysv/linux/sleep.c
@@ -26,7 +26,7 @@ sleep (unsigned int seconds)
   struct timespec ts = { tv_sec: (long int) seconds, tv_nsec: 0 };
   unsigned int result;
 
-  if (nanosleep (&ts, &ts) == 0)
+  if (__nanosleep (&ts, &ts) == 0)
     result = 0;
   else
     /* Round remaining time.  */
diff --git a/sysdeps/unix/sysv/linux/sys/sysinfo.h b/sysdeps/unix/sysv/linux/sys/sysinfo.h
index 1fabb06392..fbdb1def2b 100644
--- a/sysdeps/unix/sysv/linux/sys/sysinfo.h
+++ b/sysdeps/unix/sysv/linux/sys/sysinfo.h
@@ -29,12 +29,12 @@ extern int sysinfo __P ((struct sysinfo *__info));
 
 
 /* Return number of configured processors.  */
-extern int __get_nproc_conf __P ((void));
-extern int get_nproc_conf __P ((void));
+extern int __get_nprocs_conf __P ((void));
+extern int get_nprocs_conf __P ((void));
 
 /* Return number of available processors.  */
-extern int __get_nproc __P ((void));
-extern int get_nproc __P ((void));
+extern int __get_nprocs __P ((void));
+extern int get_nprocs __P ((void));
 
 
 /* Return number of physical pages of memory in the system.  */
diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list
index 3601b5f357..f831b41072 100644
--- a/sysdeps/unix/sysv/linux/syscalls.list
+++ b/sysdeps/unix/sysv/linux/syscalls.list
@@ -1,6 +1,6 @@
 # File name	Caller	Syscall name	# args	Strong name	Weak names
 
-adjtimex	adjtime	adjtimex	1	__adjtimex
+adjtimex	adjtime	adjtimex	1	__adjtimex	adjtimex
 bdflush		EXTRA	bdflush		2	bdflush
 create_module	EXTRA	create_module	3	create_module
 delete_module	EXTRA	delete_module	3	delete_module
@@ -20,13 +20,13 @@ iopl		-	iopl		1	iopl
 ipc		msgget	ipc		5	__ipc
 klogctl		EXTRA	syslog		3	klogctl
 llseek		EXTRA	_llseek		5	llseek
-mlock		-	mlock		2	__mlock	mlock
-mlockall	-	mlockall	1	__mlockall	mlockall
+mlock		EXTRA	mlock		2	__mlock	mlock
+mlockall	EXTRA	mlockall	1	__mlockall	mlockall
 mount		EXTRA	mount		5	__mount	mount
-mremap		-	mremap		4	__mremap	mremap
-munlock		-	munlock		2	__munlock	munlock
-munlockall	-	munlockall	0	__munlockall	munlockall
-nanosleep	-	nanosleep	2	__libc_nanosleep	nanosleep
+mremap		EXTRA	mremap		4	__mremap	mremap
+munlock		EXTRA	munlock		2	__munlock	munlock
+munlockall	EXTRA	munlockall	0	__munlockall	munlockall
+nanosleep	-	nanosleep	2	__libc_nanosleep	__nanosleep nanosleep
 pause		-	pause		0	__libc_pause	pause
 personality	init-first personality	1	__personality	personality
 pipe		-	pipe		1	__pipe		pipe