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.25-112-ged3ea04


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  ed3ea040bae8ef2cf131081124a1248a9fd3dca9 (commit)
      from  f889e73f603dcf90b4db6a2065104a78c1a0e94d (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://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=ed3ea040bae8ef2cf131081124a1248a9fd3dca9

commit ed3ea040bae8ef2cf131081124a1248a9fd3dca9
Author: Florian Weimer <fweimer@redhat.com>
Date:   Wed Mar 15 13:13:58 2017 +0100

    support: Add error checking to close system calls [BZ #21244]

diff --git a/ChangeLog b/ChangeLog
index db9db56..c9a9a89 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 2017-03-15  Florian Weimer  <fweimer@redhat.com>
 
+	[BZ #21244]
+	* support/xclose.c: New file.
+	* support/Makefile (libsupport-routines): Add xclose.
+	* support/xunistd.h (xclose): Declare.
+	* support/resolv_test.c (server_thread_tcp_client)
+	(server_thread_tcp, make_server_sockets, resolv_test_start)
+	(resolv_test_end): Call xclose instead of close.
+	* support/support_enter_network_namespace.c
+	(support_enter_network_namespace): Likewise.
+	* support/support_run_diff.c (write_to_temp_file): Likewise.
+
+2017-03-15  Florian Weimer  <fweimer@redhat.com>
+
 	* support/support_format_dns_packet.c (support_format_dns_packet):
 	Handle CNAME records in the response.  Extract RDATA names from
 	rdata, not the whole packet.  Check AAAA record length.
diff --git a/support/Makefile b/support/Makefile
index db7bb13..1f33fa0 100644
--- a/support/Makefile
+++ b/support/Makefile
@@ -53,6 +53,7 @@ libsupport-routines = \
   xasprintf \
   xbind \
   xcalloc \
+  xclose \
   xconnect \
   xfclose \
   xfopen \
diff --git a/support/resolv_test.c b/support/resolv_test.c
index 2d0ea3c..49ed210 100644
--- a/support/resolv_test.c
+++ b/support/resolv_test.c
@@ -32,9 +32,10 @@
 #include <support/test-driver.h>
 #include <support/xsocket.h>
 #include <support/xthread.h>
+#include <support/xunistd.h>
 #include <unistd.h>
 
-/* Response builder. */
+/* Response builder.  */
 
 enum
   {
@@ -860,7 +861,7 @@ server_thread_tcp_client (void *arg)
         break;
     }
 
-  close (closure->client_socket);
+  xclose (closure->client_socket);
   free (closure);
   return NULL;
 }
@@ -881,7 +882,7 @@ server_thread_tcp (struct resolv_test *obj, int server_index)
       if (obj->termination_requested)
         {
           xpthread_mutex_unlock (&obj->lock);
-          close (client_socket);
+          xclose (client_socket);
           break;
         }
       xpthread_mutex_unlock (&obj->lock);
@@ -941,8 +942,8 @@ make_server_sockets (struct resolv_test_server *server)
              next local UDP address randomly.  */
           if (errno == EADDRINUSE)
             {
-              close (server->socket_udp);
-              close (server->socket_tcp);
+              xclose (server->socket_udp);
+              xclose (server->socket_tcp);
               continue;
             }
           FAIL_EXIT1 ("TCP bind: %m");
@@ -1025,7 +1026,7 @@ resolv_test_start (struct resolv_redirect_config config)
       struct resolv_test_server *server = obj->servers + server_index;
       if (config.servers[server_index].disable_udp)
         {
-          close (server->socket_udp);
+          xclose (server->socket_udp);
           server->socket_udp = -1;
         }
       else if (!config.single_thread_udp)
@@ -1033,7 +1034,7 @@ resolv_test_start (struct resolv_redirect_config config)
                                                   server_thread_udp);
       if (config.servers[server_index].disable_tcp)
         {
-          close (server->socket_tcp);
+          xclose (server->socket_tcp);
           server->socket_tcp = -1;
         }
       else
@@ -1114,7 +1115,7 @@ resolv_test_end (struct resolv_test *obj)
           xsendto (sock, "", 1, 0,
                    (struct sockaddr *) &obj->servers[server_index].address,
                    sizeof (obj->servers[server_index].address));
-          close (sock);
+          xclose (sock);
         }
       if (!obj->config.servers[server_index].disable_tcp)
         {
@@ -1122,7 +1123,7 @@ resolv_test_end (struct resolv_test *obj)
           xconnect (sock,
                     (struct sockaddr *) &obj->servers[server_index].address,
                     sizeof (obj->servers[server_index].address));
-          close (sock);
+          xclose (sock);
         }
     }
 
@@ -1137,12 +1138,12 @@ resolv_test_end (struct resolv_test *obj)
         {
           if (!obj->config.single_thread_udp)
             xpthread_join (obj->servers[server_index].thread_udp);
-          close (obj->servers[server_index].socket_udp);
+          xclose (obj->servers[server_index].socket_udp);
         }
       if (!obj->config.servers[server_index].disable_tcp)
         {
           xpthread_join (obj->servers[server_index].thread_tcp);
-          close (obj->servers[server_index].socket_tcp);
+          xclose (obj->servers[server_index].socket_tcp);
         }
     }
 
diff --git a/support/support_enter_network_namespace.c b/support/support_enter_network_namespace.c
index d2e78fe..28b0ee2 100644
--- a/support/support_enter_network_namespace.c
+++ b/support/support_enter_network_namespace.c
@@ -23,9 +23,10 @@
 #include <stdio.h>
 #include <string.h>
 #include <support/check.h>
+#include <support/xsocket.h>
+#include <support/xunistd.h>
 #include <sys/ioctl.h>
 #include <unistd.h>
-#include <xsocket.h>
 
 static bool in_uts_namespace;
 
@@ -58,7 +59,7 @@ support_enter_network_namespace (void)
           req.ifr_flags |= IFF_UP | IFF_RUNNING;
           TEST_VERIFY_EXIT (ioctl (fd, SIOCSIFFLAGS, &req) == 0);
         }
-      close (fd);
+      xclose (fd);
 
       return !already_up;
     }
diff --git a/support/support_run_diff.c b/support/support_run_diff.c
index 3085037..f5155de 100644
--- a/support/support_run_diff.c
+++ b/support/support_run_diff.c
@@ -24,8 +24,8 @@
 #include <support/check.h>
 #include <support/support.h>
 #include <support/temp_file.h>
+#include <support/xunistd.h>
 #include <sys/wait.h>
-#include <xunistd.h>
 
 static char *
 write_to_temp_file (const char *prefix, const char *str)
@@ -36,7 +36,7 @@ write_to_temp_file (const char *prefix, const char *str)
   TEST_VERIFY_EXIT (fd >= 0);
   free (template);
   xwrite (fd, str, strlen (str));
-  TEST_VERIFY_EXIT (close (fd) == 0);
+  xclose (fd);
   return name;
 }
 
diff --git a/support/xunistd.h b/support/xclose.c
similarity index 52%
copy from support/xunistd.h
copy to support/xclose.c
index a83b1f4..c931e08 100644
--- a/support/xunistd.h
+++ b/support/xclose.c
@@ -1,5 +1,5 @@
-/* POSIX-specific extra functions.
-   Copyright (C) 2016-2017 Free Software Foundation, Inc.
+/* close with error checking.
+   Copyright (C) 2017 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,28 +16,13 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-/* These wrapper functions use POSIX types and therefore cannot be
-   declared in <support/support.h>.  */
+#include <support/xunistd.h>
+#include <support/check.h>
+#include <errno.h>
 
-#ifndef SUPPORT_XUNISTD_H
-#define SUPPORT_XUNISTD_H
-
-#include <unistd.h>
-#include <sys/cdefs.h>
-
-__BEGIN_DECLS
-
-pid_t xfork (void);
-pid_t xwaitpid (pid_t, int *status, int flags);
-
-/* Write the buffer.  Retry on short writes.  */
-void xwrite (int, const void *, size_t);
-
-/* Invoke mmap with a zero file offset.  */
-void *xmmap (void *addr, size_t length, int prot, int flags, int fd);
-
-void xmunmap (void *addr, size_t length);
-
-__END_DECLS
-
-#endif /* SUPPORT_XUNISTD_H */
+void
+xclose (int fd)
+{
+  if (close (fd) < 0 && errno != EINTR)
+    FAIL_EXIT1 ("close of descriptor %d failed: %m", fd);
+}
diff --git a/support/xunistd.h b/support/xunistd.h
index a83b1f4..258bab5 100644
--- a/support/xunistd.h
+++ b/support/xunistd.h
@@ -30,6 +30,10 @@ __BEGIN_DECLS
 pid_t xfork (void);
 pid_t xwaitpid (pid_t, int *status, int flags);
 
+/* Close the file descriptor.  Ignore EINTR errors, but terminate the
+   process on other errors.  */
+void xclose (int);
+
 /* Write the buffer.  Retry on short writes.  */
 void xwrite (int, const void *, size_t);
 

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

Summary of changes:
 ChangeLog                                     |   13 +++++++++++++
 support/Makefile                              |    1 +
 support/resolv_test.c                         |   23 ++++++++++++-----------
 support/support_enter_network_namespace.c     |    5 +++--
 support/support_run_diff.c                    |    4 ++--
 support/{xpthread_attr_destroy.c => xclose.c} |   12 +++++++-----
 support/xunistd.h                             |    4 ++++
 7 files changed, 42 insertions(+), 20 deletions(-)
 copy support/{xpthread_attr_destroy.c => xclose.c} (78%)


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]