This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch master updated. glibc-2.16-ports-merge-719-g986cab9


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  986cab95e068f79e752fc11e981de8e472c23961 (commit)
      from  6d33cc9d9bde501e0906c42ee396d42cb4ca603c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=986cab95e068f79e752fc11e981de8e472c23961

commit 986cab95e068f79e752fc11e981de8e472c23961
Author: Pino Toscano <toscano.pino@tiscali.it>
Date:   Tue Nov 20 00:49:11 2012 +0100

    Hurd: fixes for ptsname and ptsname_r
    
    ptsname_r on failure returns the value that is also set as errno; furthermore,
    add more checks to it:
    - set errno and return it on __term_get_peername failure
    - set errno to ERANGE other than returning it
    - change the type of PEERNAME to string_t, and check its length with __strnlen
    
    In ptsname:
    - change the type of PEERNAME to string_t
    - do not set errno manually, since ptsname_r has set it already

diff --git a/ChangeLog b/ChangeLog
index 7e85f77..55f5dde 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2012-11-19  Pino Toscano  <toscano.pino@tiscali.it>
+
+	* sysdeps/mach/hurd/ptsname.c (ptsname): Change the type of PEERNAME to
+	string_t.  Do not manually set errno.
+	(__ptsname_r): Change the type of PEERNAME to string_t, and check its
+	length with __strnlen.  Make sure to both set errno and return it on
+	failure.
+
 2012-11-19  David S. Miller  <davem@davemloft.net>
 
 	With help from Joseph Myers.
diff --git a/sysdeps/mach/hurd/ptsname.c b/sysdeps/mach/hurd/ptsname.c
index 1a32311..c7b52ff 100644
--- a/sysdeps/mach/hurd/ptsname.c
+++ b/sysdeps/mach/hurd/ptsname.c
@@ -1,5 +1,5 @@
 /* ptsname -- return the name of a pty slave given an FD to the pty master
-   Copyright (C) 1999 Free Software Foundation, Inc.
+   Copyright (C) 1999-2012 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
@@ -29,12 +29,10 @@
 char *
 ptsname (int fd)
 {
-  static char peername[1024];  /* XXX */
+  static string_t peername;
   error_t err;
 
   err = __ptsname_r (fd, peername, sizeof (peername));
-  if (err)
-    __set_errno (err);
 
   return err ? NULL : peername;
 }
@@ -46,17 +44,19 @@ ptsname (int fd)
 int
 __ptsname_r (int fd, char *buf, size_t buflen)
 {
-  char peername[1024];  /* XXX */
+  string_t peername;
   size_t len;
   error_t err;
 
-  peername[0] = '\0';
   if (err = HURD_DPORT_USE (fd, __term_get_peername (port, peername)))
-    return _hurd_fd_error (fd, err);
+    return __hurd_dfail (fd, err), errno;
 
-  len = strlen (peername) + 1;
+  len = __strnlen (peername, sizeof peername - 1) + 1;
   if (len > buflen)
-    return ERANGE;
+    {
+      errno = ERANGE;
+      return ERANGE;
+    }
 
   memcpy (buf, peername, len);
   return 0;

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                   |    8 ++++++++
 sysdeps/mach/hurd/ptsname.c |   18 +++++++++---------
 2 files changed, 17 insertions(+), 9 deletions(-)


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]