aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix/grantpt.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-09-18 17:59:03 +0000
committerUlrich Drepper <drepper@redhat.com>1998-09-18 17:59:03 +0000
commit00bc5db059212a20afb42da40b38d7f145a46dfd (patch)
tree090b419ffc6087f15fe9cba759f3055cb5d315ca /sysdeps/unix/grantpt.c
parent88263bc9ac99b5c99659173239a5a6e1bef25df6 (diff)
downloadglibc-00bc5db059212a20afb42da40b38d7f145a46dfd.tar
glibc-00bc5db059212a20afb42da40b38d7f145a46dfd.tar.gz
glibc-00bc5db059212a20afb42da40b38d7f145a46dfd.tar.bz2
glibc-00bc5db059212a20afb42da40b38d7f145a46dfd.zip
Update.
1998-09-18 17:41 Ulrich Drepper <drepper@cygnus.com> * libio/fileops.c (_IO_new_file_underflow): Before allocating buffer make sure the pushback buffer is destroyed. (_IO_new_file_seekoff): Likewise. If mode==0 quit early with the result. Clear OEF flag after successful fseek. * libio/libio.h (_IO_FILE_complete): Add _IO_save_ptr. * libio/ftello.c (ftello): Add offset from original buffer if stream has pushed back characters. * libio/ftello64.c (ftello64): Likewise. * libio/iofgetpos.c (_IO_fgetpos): Likewise. * libio/iofgetpos64.c (_IO_fgetpos64): Likewise. * libio/ioftell.c (_IO_ftell): Likewise. * libio/genops.c (_IO_switch_to_main_get_area): Swap _IO_read_ptr and _IO_save_ptr. (_IO_switch_to_backup_area): Save _IO_read_ptr in _IO_save_ptr. (_IO_default_pbackfail): Only stored push back character in original buffer if it is the same as the one in the file at this position. * libio/iofclose.c: Free backup buffer if one is available. * libio/ioseekoff.c (_IO_seekoff): Only remove pushback buffer if mode!=0. * strdlib/strtol.c (strtol): Handle 0x... string for base!=0 correctly. * time/strftime.c [_LIBC] (ampm): Use tp->tm_hour not hour12. 1998-09-18 Mark Kettenis <kettenis@phys.uva.nl> * login/programs/pt_chown.c (more_help): Correct message that describes the purpose of the program. * login/openpty.c: Do not include pty-private.h. (pts_name): New function. Return name of slave pseudo terminal in an allocated buffer if necessary. (openpty): Use pts_name to get name of the slave end of the pseudo terminal pair. * sysdeps/unix/grantpt.c (grantpt): Free buffer allocated by pts_name before return. 1998-09-18 11:15 Ulrich Drepper <drepper@cygnus.com> * math/math.h: Define __NO_MATH_INLINES if __STRICT_ANSI__.
Diffstat (limited to 'sysdeps/unix/grantpt.c')
-rw-r--r--sysdeps/unix/grantpt.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/sysdeps/unix/grantpt.c b/sysdeps/unix/grantpt.c
index d216baa476..76bda071e7 100644
--- a/sysdeps/unix/grantpt.c
+++ b/sysdeps/unix/grantpt.c
@@ -90,6 +90,7 @@ pts_name (int fd, char **pts, size_t buf_len)
int
grantpt (int fd)
{
+ int retval = -1;
#ifdef PATH_MAX
char _buf[PATH_MAX];
#else
@@ -107,9 +108,9 @@ grantpt (int fd)
if (pts_name (fd, &buf, sizeof (_buf)))
return -1;
-
+
if (__stat (buf, &st) < 0)
- return -1;
+ goto cleanup;
/* Make sure that we own the device. */
uid = __getuid ();
@@ -143,14 +144,15 @@ grantpt (int fd)
goto helper;
}
- return 0;
+ retval = 0;
+ goto cleanup;
/* We have to use the helper program. */
helper:
pid = __fork ();
if (pid == -1)
- return -1;
+ goto cleanup;
else if (pid == 0)
{
/* Disable core dumps. */
@@ -168,36 +170,38 @@ grantpt (int fd)
else
{
int w;
-
+
if (__waitpid (pid, &w, 0) == -1)
- return -1;
+ goto cleanup;
if (!WIFEXITED (w))
- {
- __set_errno (ENOEXEC);
- return -1;
- }
+ __set_errno (ENOEXEC);
else
switch (WEXITSTATUS(w))
{
case 0:
+ retval = 0;
break;
case FAIL_EBADF:
__set_errno (EBADF);
- return -1;
+ break;
case FAIL_EINVAL:
__set_errno (EINVAL);
- return -1;
+ break;
case FAIL_EACCES:
__set_errno (EACCES);
- return -1;
+ break;
case FAIL_EXEC:
__set_errno (ENOEXEC);
- return -1;
+ break;
default:
assert(! "getpt: internal error: invalid exit code from pt_chown");
}
}
- return 0;
+ cleanup:
+ if (buf != _buf)
+ free (buf);
+
+ return retval;
}