aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-07-06 16:26:03 +0000
committerUlrich Drepper <drepper@redhat.com>1999-07-06 16:26:03 +0000
commit2e65ca2b226a55e7d25ef687ce33185c0a71bd99 (patch)
tree0b76ef817b2b4977374fe025016e80fcd2e4f3ff
parent4708015f24a69bd0a436483c4d1244d1fb1f2e87 (diff)
downloadglibc-2e65ca2b226a55e7d25ef687ce33185c0a71bd99.tar.xz
glibc-2e65ca2b226a55e7d25ef687ce33185c0a71bd99.zip
Update.
1999-07-06 Ulrich Drepper <drepper@cygnus.com> * sysdeps/unix/sysv/linux/alpha/ioperm.c: Update for some more motherboards. Patch by Jay Estabrook. * sysdeps/unix/sysv/linux/configure.in: Don't test for libc4 in ldd for SPARC. * /sysdeps/unix/sysv/linux/sparc/ldd-rewrite.sed: New file. Patch by Cristian Gafton. 1999-07-02 Cristian Gafton <gafton@redhat.com> * sysdeps/unix/sysv/linux/bits/socket.h (__cmsg_nxthdr): "return 0" instead of "return NULL" to make C++ happy. 1999-07-04 Mark Kettenis <kettenis@gnu.org> * libio/iofdopen.c (_IO_new_fdopen): Set EINVAL if MODE is not allowed by the file access mode of the open file. 1999-07-06 Ulrich Drepper <drepper@cygnus.com> * sysdeps/generic/setfpucw.c: Include math.h to get all needed macros defined. 1999-07-03 Jakub Jelinek <jj@ultra.linux.cz> * sysdeps/sparc/sparc64/submul_1.S: Fix carry handling. Optimize. * sysdeps/sparc/sparc64/lshift.S: Make a leaf subroutine. Optimize. * sysdeps/sparc/sparc64/rshift.S: Likewise. * sysdeps/sparc/sparc64/mul_1.S: Optimize. 1999-07-04 Wolfram Gloger <wmglo@dent.med.uni-muenchen.de> * malloc/malloc.c (request2size): Check for overflow and return NULL whenever it is encountered. 1999-07-04 Zack Weinberg <zack@rabi.columbia.edu> * sysdeps/posix/tempname.c (__gen_tempname): Add ability to create directories. Replace OPENIT and LARGEFILE args with a single flags parameter. * sysdeps/generic/tempname.c: Likewise. * include/stdio.h: Adjust prototype of __gen_tempname to match. Define symbolic constants for second argument. * misc/mkdtemp.c: New file, provides new function mkdtemp(). * stdlib/stdlib.h: Prototype it. * misc/Versions: Export it. * misc/Makefile (routines): Add mktemp. * manual/filesys.texi: Document it. * misc/mktemp.c: Adjust call of __gen_tempname to match new convention. * misc/mkstemp.c: Likewise. * stdio-common/tempnam.c: Likewise. * stdio-common/tmpfile.c: Likewise. * stdio-common/tmpfile64.c: Likewise. * stdio-common/tmpnam.c: Likewise. * stdio-common/tmpnam_r.c: Likewise. 1999-07-05 Jakub Jelinek <jj@ultra.linux.cz> * sysdeps/sparc/sparc64/dl-machine.h (elf_machine_rela): Support R_SPARC_OLO10 relocations. * elf/elf.h (R_SPARC_OLO10): Fix comment.
-rw-r--r--BUGS10
-rw-r--r--ChangeLog68
-rw-r--r--elf/elf.h2
-rw-r--r--include/stdio.h7
-rw-r--r--libio/iofdopen.c11
-rw-r--r--malloc/malloc.c51
-rw-r--r--manual/filesys.texi27
-rw-r--r--misc/Makefile2
-rw-r--r--misc/Versions4
-rw-r--r--misc/mkdtemp.c35
-rw-r--r--misc/mkstemp.c4
-rw-r--r--misc/mktemp.c4
-rw-r--r--stdio-common/tempnam.c4
-rw-r--r--stdio-common/tmpfile.c4
-rw-r--r--stdio-common/tmpfile64.c4
-rw-r--r--stdio-common/tmpnam.c4
-rw-r--r--stdio-common/tmpnam_r.c4
-rw-r--r--stdlib/stdlib.h9
-rw-r--r--sysdeps/generic/setfpucw.c3
-rw-r--r--sysdeps/generic/tempname.c16
-rw-r--r--sysdeps/posix/tempname.c65
-rw-r--r--sysdeps/sparc/sparc64/dl-machine.h16
-rw-r--r--sysdeps/sparc/sparc64/lshift.S127
-rw-r--r--sysdeps/sparc/sparc64/mul_1.S7
-rw-r--r--sysdeps/sparc/sparc64/rshift.S121
-rw-r--r--sysdeps/sparc/sparc64/submul_1.S38
-rw-r--r--sysdeps/unix/sysv/linux/alpha/ioperm.c383
-rw-r--r--sysdeps/unix/sysv/linux/bits/socket.h4
-rw-r--r--sysdeps/unix/sysv/linux/configure.in5
-rw-r--r--sysdeps/unix/sysv/linux/sparc/ldd-rewrite.sed2
30 files changed, 656 insertions, 385 deletions
diff --git a/BUGS b/BUGS
index 9a6dd62ab8..9b546c60dd 100644
--- a/BUGS
+++ b/BUGS
@@ -1,7 +1,7 @@
List of known bugs (certainly very incomplete)
----------------------------------------------
-Time-stamp: <1999-04-19T17:58:10-0700 drepper>
+Time-stamp: <1999-07-06T15:37:11-0700 drepper>
This following list contains those bugs which I'm aware of. Please
make sure that bugs you report are not listed here. If you can fix one
@@ -56,13 +56,13 @@ Severity: [ *] to [***]
[ *] The libm-ieee `scalb' function gives wrong results for
non-integral second parameters.
-[ *] The *scanf() functions currently do not handle %l[ and %ls parameters
- correctly since the parsing of the multi-byte characters does not
- yet use mbsrtowcs().
-
[ *] The strftime() implementation cannot handle multibyte locales really
good since the TOLOWER and TOUPPER are not prepared.
+[ *] The putenv() function copies it's argument which means that the
+ string (and possible later changes to it) are not automatically
+ reflected in the environment.
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ulrich Drepper
drepper@cygnus.com
diff --git a/ChangeLog b/ChangeLog
index 5950790ad1..c931262070 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,71 @@
+1999-07-06 Ulrich Drepper <drepper@cygnus.com>
+
+ * sysdeps/unix/sysv/linux/alpha/ioperm.c: Update for some more
+ motherboards.
+ Patch by Jay Estabrook.
+
+ * sysdeps/unix/sysv/linux/configure.in: Don't test for libc4 in
+ ldd for SPARC.
+ * /sysdeps/unix/sysv/linux/sparc/ldd-rewrite.sed: New file.
+ Patch by Cristian Gafton.
+
+1999-07-02 Cristian Gafton <gafton@redhat.com>
+
+ * sysdeps/unix/sysv/linux/bits/socket.h (__cmsg_nxthdr): "return 0"
+ instead of "return NULL" to make C++ happy.
+
+1999-07-04 Mark Kettenis <kettenis@gnu.org>
+
+ * libio/iofdopen.c (_IO_new_fdopen): Set EINVAL if MODE is not
+ allowed by the file access mode of the open file.
+
+1999-07-06 Ulrich Drepper <drepper@cygnus.com>
+
+ * sysdeps/generic/setfpucw.c: Include math.h to get all needed
+ macros defined.
+
+1999-07-03 Jakub Jelinek <jj@ultra.linux.cz>
+
+ * sysdeps/sparc/sparc64/submul_1.S: Fix carry handling. Optimize.
+ * sysdeps/sparc/sparc64/lshift.S: Make a leaf subroutine. Optimize.
+ * sysdeps/sparc/sparc64/rshift.S: Likewise.
+ * sysdeps/sparc/sparc64/mul_1.S: Optimize.
+
+1999-07-04 Wolfram Gloger <wmglo@dent.med.uni-muenchen.de>
+
+ * malloc/malloc.c (request2size): Check for overflow and return
+ NULL whenever it is encountered.
+
+1999-07-04 Zack Weinberg <zack@rabi.columbia.edu>
+
+ * sysdeps/posix/tempname.c (__gen_tempname): Add
+ ability to create directories. Replace OPENIT and LARGEFILE
+ args with a single flags parameter.
+ * sysdeps/generic/tempname.c: Likewise.
+ * include/stdio.h: Adjust prototype of __gen_tempname to
+ match. Define symbolic constants for second argument.
+
+ * misc/mkdtemp.c: New file, provides new function mkdtemp().
+ * stdlib/stdlib.h: Prototype it.
+ * misc/Versions: Export it.
+ * misc/Makefile (routines): Add mktemp.
+ * manual/filesys.texi: Document it.
+
+ * misc/mktemp.c: Adjust call of __gen_tempname to match new
+ convention.
+ * misc/mkstemp.c: Likewise.
+ * stdio-common/tempnam.c: Likewise.
+ * stdio-common/tmpfile.c: Likewise.
+ * stdio-common/tmpfile64.c: Likewise.
+ * stdio-common/tmpnam.c: Likewise.
+ * stdio-common/tmpnam_r.c: Likewise.
+
+1999-07-05 Jakub Jelinek <jj@ultra.linux.cz>
+
+ * sysdeps/sparc/sparc64/dl-machine.h (elf_machine_rela): Support
+ R_SPARC_OLO10 relocations.
+ * elf/elf.h (R_SPARC_OLO10): Fix comment.
+
1999-07-02 Tim Waugh <tim@cyberelk.demon.co.uk>
* posix/wordexp-test.c: Revert bogus 'unset IFS' change. It
diff --git a/elf/elf.h b/elf/elf.h
index 9b368bb44d..7c98051396 100644
--- a/elf/elf.h
+++ b/elf/elf.h
@@ -929,7 +929,7 @@ typedef struct
#define R_SPARC_10 30 /* Direct 10 bit */
#define R_SPARC_11 31 /* Direct 11 bit */
#define R_SPARC_64 32 /* Direct 64 bit */
-#define R_SPARC_OLO10 33 /* ?? */
+#define R_SPARC_OLO10 33 /* 10bit with secondary 13bit addend */
#define R_SPARC_HH22 34 /* Top 22 bits of direct 64 bit */
#define R_SPARC_HM10 35 /* High middle 10 bits of ... */
#define R_SPARC_LM22 36 /* Low middle 22 bits of ... */
diff --git a/include/stdio.h b/include/stdio.h
index dcc9c15ec7..eff125f476 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -36,7 +36,12 @@ extern int __path_search __P ((char *__tmpl, size_t __tmpl_len,
__const char *__dir, __const char *__pfx,
int __try_tempdir));
-extern int __gen_tempname __P ((char *__tmpl, int __openit, int __large_file));
+extern int __gen_tempname __P ((char *__tmpl, int __kind));
+/* The __kind argument to __gen_tempname may be one of: */
+#define __GT_FILE 0 /* create a file */
+#define __GT_BIGFILE 1 /* create a file, using open64 */
+#define __GT_DIR 2 /* create a directory */
+#define __GT_NOCREATE 3 /* just find a name not currently in use */
/* Print out MESSAGE on the error output and abort. */
extern void __libc_fatal __P ((__const char *__message))
diff --git a/libio/iofdopen.c b/libio/iofdopen.c
index 3bfa40c7c6..e8e32e03dc 100644
--- a/libio/iofdopen.c
+++ b/libio/iofdopen.c
@@ -77,10 +77,15 @@ _IO_new_fdopen (fd, mode)
#ifndef O_ACCMODE
#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
#endif
- if (fd_flags == -1
- || ((fd_flags & O_ACCMODE) == O_RDONLY && !(read_write & _IO_NO_WRITES))
- || ((fd_flags & O_ACCMODE) == O_WRONLY && !(read_write & _IO_NO_READS)))
+ if (fd_flags == -1)
return NULL;
+
+ if (((fd_flags & O_ACCMODE) == O_RDONLY && !(read_write & _IO_NO_WRITES))
+ || ((fd_flags & O_ACCMODE) == O_WRONLY && !(read_write & _IO_NO_READS)))
+ {
+ MAYBE_SET_EINVAL;
+ return NULL;
+ }
/* The May 93 draft of P1003.4/D14.1 (redesignated as 1003.1b)
[System Application Program Interface (API) Amendment 1:
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 01ff7aa304..e096f00eeb 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -1259,12 +1259,12 @@ static void free_atfork();
#define chunk2mem(p) ((Void_t*)((char*)(p) + 2*SIZE_SZ))
#define mem2chunk(mem) ((mchunkptr)((char*)(mem) - 2*SIZE_SZ))
-/* pad request bytes into a usable size */
+/* pad request bytes into a usable size, return non-zero on overflow */
-#define request2size(req) \
- (((long)((req) + (SIZE_SZ + MALLOC_ALIGN_MASK)) < \
- (long)(MINSIZE + MALLOC_ALIGN_MASK)) ? MINSIZE : \
- (((req) + (SIZE_SZ + MALLOC_ALIGN_MASK)) & ~(MALLOC_ALIGN_MASK)))
+#define request2size(req, nb) \
+ ((nb = (req) + (SIZE_SZ + MALLOC_ALIGN_MASK)),\
+ ((long)nb <= 0 ? 1 : ((nb < (MINSIZE + MALLOC_ALIGN_MASK) ? (nb = MINSIZE) :\
+ (nb &= ~MALLOC_ALIGN_MASK)), 0)))
/* Check if m has acceptable alignment */
@@ -2622,7 +2622,8 @@ Void_t* mALLOc(bytes) size_t bytes;
}
#endif
- nb = request2size(bytes);
+ if(request2size(bytes, nb))
+ return 0;
arena_get(ar_ptr, nb);
if(!ar_ptr)
return 0;
@@ -3133,7 +3134,8 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
oldp = mem2chunk(oldmem);
oldsize = chunksize(oldp);
- nb = request2size(bytes);
+ if(request2size(bytes, nb))
+ return 0;
#if HAVE_MMAP
if (chunk_is_mmapped(oldp))
@@ -3399,7 +3401,8 @@ Void_t* mEMALIGn(alignment, bytes) size_t alignment; size_t bytes;
if (alignment < MINSIZE) alignment = MINSIZE;
- nb = request2size(bytes);
+ if(request2size(bytes, nb))
+ return 0;
arena_get(ar_ptr, nb + alignment + MINSIZE);
if(!ar_ptr)
return 0;
@@ -3574,7 +3577,8 @@ Void_t* cALLOc(n, elem_size) size_t n; size_t elem_size;
}
#endif
- sz = request2size(n * elem_size);
+ if(request2size(n * elem_size, sz))
+ return 0;
arena_get(ar_ptr, sz);
if(!ar_ptr)
return 0;
@@ -4364,8 +4368,10 @@ malloc_check(sz, caller) size_t sz; const Void_t *caller;
#endif
{
mchunkptr victim;
- INTERNAL_SIZE_T nb = request2size(sz + 1);
+ INTERNAL_SIZE_T nb;
+ if(request2size(sz+1, nb))
+ return 0;
(void)mutex_lock(&main_arena.mutex);
victim = (top_check() >= 0) ? chunk_alloc(&main_arena, nb) : NULL;
(void)mutex_unlock(&main_arena.mutex);
@@ -4434,7 +4440,10 @@ realloc_check(oldmem, bytes, caller)
}
oldsize = chunksize(oldp);
- nb = request2size(bytes+1);
+ if(request2size(bytes+1, nb)) {
+ (void)mutex_unlock(&main_arena.mutex);
+ return 0;
+ }
#if HAVE_MMAP
if (chunk_is_mmapped(oldp)) {
@@ -4491,7 +4500,8 @@ memalign_check(alignment, bytes, caller)
if (alignment <= MALLOC_ALIGNMENT) return malloc_check(bytes, NULL);
if (alignment < MINSIZE) alignment = MINSIZE;
- nb = request2size(bytes+1);
+ if(request2size(bytes+1, nb))
+ return 0;
(void)mutex_lock(&main_arena.mutex);
p = (top_check() >= 0) ? chunk_align(&main_arena, nb, alignment) : NULL;
(void)mutex_unlock(&main_arena.mutex);
@@ -4511,7 +4521,12 @@ malloc_starter(size_t sz, const Void_t *caller)
malloc_starter(sz, caller) size_t sz; const Void_t *caller;
#endif
{
- mchunkptr victim = chunk_alloc(&main_arena, request2size(sz));
+ INTERNAL_SIZE_T nb;
+ mchunkptr victim;
+
+ if(request2size(sz, nb))
+ return 0;
+ victim = chunk_alloc(&main_arena, nb);
return victim ? chunk2mem(victim) : 0;
}
@@ -4547,16 +4562,20 @@ malloc_atfork(sz, caller) size_t sz; const Void_t *caller;
#endif
{
Void_t *vptr = NULL;
+ INTERNAL_SIZE_T nb;
mchunkptr victim;
tsd_getspecific(arena_key, vptr);
if(!vptr) {
if(save_malloc_hook != malloc_check) {
- victim = chunk_alloc(&main_arena, request2size(sz));
+ if(request2size(sz, nb))
+ return 0;
+ victim = chunk_alloc(&main_arena, nb);
return victim ? chunk2mem(victim) : 0;
} else {
- if(top_check() < 0) return 0;
- victim = chunk_alloc(&main_arena, request2size(sz+1));
+ if(top_check()<0 || request2size(sz+1, nb))
+ return 0;
+ victim = chunk_alloc(&main_arena, nb);
return victim ? chunk2mem_check(victim, sz) : 0;
}
} else {
diff --git a/manual/filesys.texi b/manual/filesys.texi
index 51af84633d..29f20758e8 100644
--- a/manual/filesys.texi
+++ b/manual/filesys.texi
@@ -2935,7 +2935,7 @@ end with @samp{XXXXXX}, @code{mkstemp} returns @code{-1} and does not
modify @var{template}.
The file is opened using mode @code{0600}. If the file is meant to be
-used by other users the mode must explicitly changed.
+used by other users the mode must be changed explicitly.
@end deftypefun
Unlike @code{mktemp}, @code{mkstemp} is actually guaranteed to create a
@@ -2943,3 +2943,28 @@ unique file that cannot possibly clash with any other program trying to
create a temporary file. This is because it works by calling
@code{open} with the @code{O_EXCL} flag bit, which says you want to
always create a new file, and get an error if the file already exists.
+
+@comment stdlib.h
+@comment BSD
+@deftypefun {char *} mkdtemp (char *@var{template})
+The @code{mkdtemp} function creates a directory with a unique name. If
+it succeeds, it overwrites @var{template} with the name of the
+directory, and returns @var{template}. As with @code{mktemp} and
+@code{mkstemp}, @var{template} should be a string ending with
+@samp{XXXXXX}.
+
+If @code{mkdtemp} cannot create an uniquely named directory, it returns
+@code{NULL} and sets @var{errno} appropriately. If @var{template} does
+not end with @samp{XXXXXX}, @code{mkdtemp} returns @code{NULL} and does
+not modify @var{template}. @var{errno} will be set to @code{EINVAL} in
+this case.
+
+The directory is created using mode @code{0700}.
+@end deftypefun
+
+The directory created by @code{mkdtemp} cannot clash with temporary
+files or directories created by other users. This is because directory
+creation always works like @code{open} with @code{O_EXCL}.
+@xref{Creating Directories}.
+
+The @code{mkdtemp} function comes from OpenBSD.
diff --git a/misc/Makefile b/misc/Makefile
index 948c087edf..a1aeaa6c32 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -42,7 +42,7 @@ routines := brk sbrk sstk ioctl \
acct chroot fsync sync fdatasync reboot \
gethostid sethostid \
revoke vhangup \
- swapon swapoff mktemp mkstemp \
+ swapon swapoff mktemp mkstemp mkdtemp \
ualarm usleep \
gtty stty \
ptrace \
diff --git a/misc/Versions b/misc/Versions
index 110606330e..d9eee7a746 100644
--- a/misc/Versions
+++ b/misc/Versions
@@ -102,4 +102,8 @@ libc {
# t*
tdestroy; truncate64;
}
+ GLIBC_2.2 {
+ # m*
+ mkdtemp;
+ }
}
diff --git a/misc/mkdtemp.c b/misc/mkdtemp.c
new file mode 100644
index 0000000000..3961c7a097
--- /dev/null
+++ b/misc/mkdtemp.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 1999 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
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+/* Generate a unique temporary directory from TEMPLATE.
+ The last six characters of TEMPLATE must be "XXXXXX";
+ they are replaced with a string that makes the filename unique.
+ The directory is created, mode 700, and its name is returned.
+ (This function comes from OpenBSD.) */
+char *
+mkdtemp (template)
+ char *template;
+{
+ if (__gen_tempname (template, __GT_DIR))
+ return NULL;
+ else
+ return template;
+}
diff --git a/misc/mkstemp.c b/misc/mkstemp.c
index fc911da9a1..8441c8ee2a 100644
--- a/misc/mkstemp.c
+++ b/misc/mkstemp.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 1999 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
@@ -27,5 +27,5 @@ int
mkstemp (template)
char *template;
{
- return __gen_tempname (template, 1, 0);
+ return __gen_tempname (template, __GT_FILE);
}
diff --git a/misc/mk