diff --git a/libc/bionic/debug_mapinfo.cpp b/libc/bionic/debug_mapinfo.cpp index d83799afa..698ab6b87 100644 --- a/libc/bionic/debug_mapinfo.cpp +++ b/libc/bionic/debug_mapinfo.cpp @@ -71,7 +71,7 @@ __LIBC_HIDDEN__ mapinfo_t* mapinfo_create(pid_t pid) { struct mapinfo_t* milist = NULL; char data[1024]; // Used to read lines as well as to construct the filename. snprintf(data, sizeof(data), "/proc/%d/maps", pid); - FILE* fp = fopen(data, "r"); + FILE* fp = fopen(data, "re"); if (fp != NULL) { while (fgets(data, sizeof(data), fp) != NULL) { mapinfo_t* mi = parse_maps_line(data); diff --git a/libc/bionic/pututline.c b/libc/bionic/pututline.c index c8427f720..8cbf47057 100644 --- a/libc/bionic/pututline.c +++ b/libc/bionic/pututline.c @@ -36,7 +36,7 @@ void pututline(struct utmp* utmp) struct utmp u; long i; - if (!(f = fopen(_PATH_UTMP, "w+"))) + if (!(f = fopen(_PATH_UTMP, "w+e"))) return; while (fread(&u, sizeof(struct utmp), 1, f) == 1) @@ -55,7 +55,7 @@ void pututline(struct utmp* utmp) fclose(f); - if (!(f = fopen(_PATH_UTMP, "w+"))) + if (!(f = fopen(_PATH_UTMP, "w+e"))) return; fwrite(utmp, sizeof(struct utmp), 1, f); diff --git a/libc/bionic/sysconf.cpp b/libc/bionic/sysconf.cpp index 8309f087a..d8aac4fe0 100644 --- a/libc/bionic/sysconf.cpp +++ b/libc/bionic/sysconf.cpp @@ -95,7 +95,7 @@ static int __sysconf_nprocessors_conf() { } static int __sysconf_nprocessors_onln() { - FILE* fp = fopen("/proc/stat", "r"); + FILE* fp = fopen("/proc/stat", "re"); if (fp == NULL) { return 1; } @@ -118,7 +118,7 @@ static int __sysconf_nprocessors_onln() { } static int __get_meminfo(const char* pattern) { - FILE* fp = fopen("/proc/meminfo", "r"); + FILE* fp = fopen("/proc/meminfo", "re"); if (fp == NULL) { return -1; } diff --git a/libc/dns/gethnamaddr.c b/libc/dns/gethnamaddr.c index 80fdcbee1..cc33c612c 100644 --- a/libc/dns/gethnamaddr.c +++ b/libc/dns/gethnamaddr.c @@ -899,7 +899,7 @@ _sethtent(int f) res_static rs = __res_get_static(); if (rs == NULL) return; if (!rs->hostf) - rs->hostf = fopen(_PATH_HOSTS, "r" ); + rs->hostf = fopen(_PATH_HOSTS, "re" ); else rewind(rs->hostf); rs->stayopen = f; @@ -925,7 +925,7 @@ _gethtent(void) int af, len; res_static rs = __res_get_static(); - if (!rs->hostf && !(rs->hostf = fopen(_PATH_HOSTS, "r" ))) { + if (!rs->hostf && !(rs->hostf = fopen(_PATH_HOSTS, "re" ))) { h_errno = NETDB_INTERNAL; return NULL; } diff --git a/libc/dns/net/getaddrinfo.c b/libc/dns/net/getaddrinfo.c index 65fd1c197..a4923187e 100644 --- a/libc/dns/net/getaddrinfo.c +++ b/libc/dns/net/getaddrinfo.c @@ -2017,7 +2017,7 @@ _sethtent(FILE **hostf) { if (!*hostf) - *hostf = fopen(_PATH_HOSTS, "r" ); + *hostf = fopen(_PATH_HOSTS, "re"); else rewind(*hostf); } @@ -2046,7 +2046,7 @@ _gethtent(FILE **hostf, const char *name, const struct addrinfo *pai) assert(name != NULL); assert(pai != NULL); - if (!*hostf && !(*hostf = fopen(_PATH_HOSTS, "r" ))) + if (!*hostf && !(*hostf = fopen(_PATH_HOSTS, "re"))) return (NULL); again: if (!(p = fgets(hostbuf, sizeof hostbuf, *hostf))) diff --git a/libc/dns/resolv/res_cache.c b/libc/dns/resolv/res_cache.c index 77a1b4d19..0201aa8f1 100644 --- a/libc/dns/resolv/res_cache.c +++ b/libc/dns/resolv/res_cache.c @@ -1436,7 +1436,7 @@ _dump_answer(const void* answer, int answerlen) char* buf; int fileLen; - fp = fopen("/data/reslog.txt", "w+"); + fp = fopen("/data/reslog.txt", "w+e"); if (fp != NULL) { statep = __res_get_state(); diff --git a/libc/dns/resolv/res_init.c b/libc/dns/resolv/res_init.c index f1cbed8ac..c05352a5d 100644 --- a/libc/dns/resolv/res_init.c +++ b/libc/dns/resolv/res_init.c @@ -289,7 +289,7 @@ __res_vinit(res_state statp, int preinit) { line[sizeof(name) - 1] == '\t')) nserv = 0; - if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) { + if ((fp = fopen(_PATH_RESCONF, "re")) != NULL) { /* read the config file */ while (fgets(buf, sizeof(buf), fp) != NULL) { /* skip comments */