downstream: ocloexec
authorAnas Nashif <anas.nashif@intel.com>
Tue, 30 Oct 2012 20:57:52 +0000 (13:57 -0700)
committerPhilippe Coval <philippe.coval@open.eurogiciel.org>
Mon, 8 Dec 2014 12:26:59 +0000 (13:26 +0100)
Change-Id: Ie10c7a5414603781405af5b7a094c9cc359e2465
Author:    Anas Nashif <anas.nashif@intel.com>

ares_gethostbyaddr.c
ares_gethostbyname.c
ares_init.c
ares_process.c
ares_search.c

index 85862e2..0c832bb 100644 (file)
@@ -215,7 +215,7 @@ static int file_lookup(struct ares_addr *addr, struct hostent **host)
     return ARES_ENOTFOUND;
 #endif
 
-  fp = fopen(PATH_HOSTS, "r");
+  fp = fopen(PATH_HOSTS, "re");
   if (!fp)
     {
       error = ERRNO;
index 2b27b2e..5bb0d35 100644 (file)
@@ -373,7 +373,7 @@ static int file_lookup(const char *name, int family, struct hostent **host)
     return ARES_ENOTFOUND;
 #endif
 
-  fp = fopen(PATH_HOSTS, "r");
+  fp = fopen(PATH_HOSTS, "re");
   if (!fp)
     {
       error = ERRNO;
index d23c1b0..9a0b6d2 100644 (file)
@@ -1158,7 +1158,7 @@ static int init_by_resolv_conf(ares_channel channel)
     if (ARES_CONFIG_CHECK(channel))
         return ARES_SUCCESS;
 
-    fp = fopen(PATH_RESOLV_CONF, "r");
+    fp = fopen(PATH_RESOLV_CONF, "re");
     if (fp) {
       while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS)
       {
@@ -1200,7 +1200,7 @@ static int init_by_resolv_conf(ares_channel channel)
 
     if ((status == ARES_EOF) && (!channel->lookups)) {
       /* Many systems (Solaris, Linux, BSD's) use nsswitch.conf */
-      fp = fopen("/etc/nsswitch.conf", "r");
+      fp = fopen("/etc/nsswitch.conf", "re");
       if (fp) {
         while ((status = ares__read_line(fp, &line, &linesize)) ==
                ARES_SUCCESS)
@@ -1230,7 +1230,7 @@ static int init_by_resolv_conf(ares_channel channel)
 
     if ((status == ARES_EOF) && (!channel->lookups)) {
       /* Linux / GNU libc 2.x and possibly others have host.conf */
-      fp = fopen("/etc/host.conf", "r");
+      fp = fopen("/etc/host.conf", "re");
       if (fp) {
         while ((status = ares__read_line(fp, &line, &linesize)) ==
                ARES_SUCCESS)
@@ -1260,7 +1260,7 @@ static int init_by_resolv_conf(ares_channel channel)
 
     if ((status == ARES_EOF) && (!channel->lookups)) {
       /* Tru64 uses /etc/svc.conf */
-      fp = fopen("/etc/svc.conf", "r");
+      fp = fopen("/etc/svc.conf", "re");
       if (fp) {
         while ((status = ares__read_line(fp, &line, &linesize)) ==
                ARES_SUCCESS)
@@ -1896,7 +1896,7 @@ static void randomize_key(unsigned char* key,int key_data_len)
     }
 #else /* !WIN32 */
 #ifdef RANDOM_FILE
-  FILE *f = fopen(RANDOM_FILE, "rb");
+  FILE *f = fopen(RANDOM_FILE, "rbe");
   if(f) {
     counter = aresx_uztosi(fread(key, 1, key_data_len, f));
     fclose(f);
index bbeca5e..4d7dcd3 100644 (file)
@@ -915,7 +915,7 @@ static int configure_socket(ares_socket_t s, int family, ares_channel channel)
 
   setsocknonblock(s, TRUE);
 
-#if defined(FD_CLOEXEC) && !defined(MSDOS)
+#if  !defined(SOCK_CLOEXEC) && defined(FD_CLOEXEC) && !defined(MSDOS)
   /* Configure the socket fd as close-on-exec. */
   if (fcntl(s, F_SETFD, FD_CLOEXEC) == -1)
     return -1;
@@ -1004,7 +1004,7 @@ static int open_tcp_socket(ares_channel channel, struct server_state *server)
     }
 
   /* Acquire a socket. */
-  s = socket(server->addr.family, SOCK_STREAM, 0);
+  s = socket(server->addr.family, SOCK_STREAM | SOCK_CLOEXEC, 0);
   if (s == ARES_SOCKET_BAD)
     return -1;
 
@@ -1096,7 +1096,7 @@ static int open_udp_socket(ares_channel channel, struct server_state *server)
     }
 
   /* Acquire a socket. */
-  s = socket(server->addr.family, SOCK_DGRAM, 0);
+  s = socket(server->addr.family, SOCK_DGRAM | SOCK_CLOEXEC, 0);
   if (s == ARES_SOCKET_BAD)
     return -1;
 
index ec07640..45ba0a0 100644 (file)
@@ -251,7 +251,7 @@ static int single_domain(ares_channel channel, const char *name, char **s)
       hostaliases = getenv("HOSTALIASES");
       if (hostaliases)
         {
-          fp = fopen(hostaliases, "r");
+          fp = fopen(hostaliases, "re");
           if (fp)
             {
               while ((status = ares__read_line(fp, &line, &linesize))