resolv: fixed styles according to review suggestions.

pull/348/head
Datong Sun 7 years ago
parent afe905f34c
commit dafba43e9f
No known key found for this signature in database
GPG Key ID: 1908AE626BFCE242

@ -1,5 +1,5 @@
diff --git a/src/core/ngx_resolver.c b/src/core/ngx_resolver.c
index cd55520c..e61a6d53 100644
index cd55520c..6a3f98bb 100644
--- a/src/core/ngx_resolver.c
+++ b/src/core/ngx_resolver.c
@@ -5,6 +5,7 @@
@ -10,17 +10,22 @@ index cd55520c..e61a6d53 100644
#include <ngx_config.h>
#include <ngx_core.h>
#include <ngx_event.h>
@@ -15,6 +16,9 @@
@@ -15,6 +16,14 @@
#define NGX_RESOLVER_TCP_RSIZE (2 + 65535)
#define NGX_RESOLVER_TCP_WSIZE 8192
+/*
+ * note that 2KB should be more than enough for majority of the
+ * resolv.conf files out there. it also acts as a safety guard to prevent
+ * abuse.
+ */
+#define NGX_RESOLVER_FILE_BUF_SIZE 2048
+#define NGX_RESOLVER_FILE_NAME "/etc/resolv.conf"
+
typedef struct {
u_char ident_hi;
@@ -131,6 +135,144 @@ static ngx_resolver_node_t *ngx_resolver_lookup_addr6(ngx_resolver_t *r,
@@ -131,6 +140,138 @@ static ngx_resolver_node_t *ngx_resolver_lookup_addr6(ngx_resolver_t *r,
#endif
@ -60,8 +65,6 @@ index cd55520c..e61a6d53 100644
+ ngx_memzero(&file, sizeof(ngx_file_t));
+
+ file.fd = fd;
+ file.name.data = path;
+ file.name.len = ngx_strlen(path) - 1;
+ file.log = cf->log;
+
+ state = sw_nameserver;
@ -81,7 +84,7 @@ index cd55520c..e61a6d53 100644
+ return NGX_OK;
+ }
+
+ for (i = 0; i < n; total < MAXNS) {
+ for (i = 0; i < n && total < MAXNS; /* void */) {
+ if (buf[i] == '#' || buf[i] == ';') {
+ state = sw_skip;
+ }
@ -95,8 +98,8 @@ index cd55520c..e61a6d53 100644
+ sizeof("nameserver ") - 1) == 0)
+ {
+ state = sw_address;
+ address = 0;
+ i += sizeof("nameserver ") - 1;
+ address = i;
+
+ continue;
+ }
@ -105,10 +108,6 @@ index cd55520c..e61a6d53 100644
+
+ case sw_address:
+
+ if (address == 0) {
+ address = i;
+ }
+
+ if (buf[i] == CR || buf[i] == LF || i == n - 1) {
+ ngx_memzero(&u, sizeof(ngx_url_t));
+
@ -165,7 +164,7 @@ index cd55520c..e61a6d53 100644
ngx_resolver_t *
ngx_resolver_create(ngx_conf_t *cf, ngx_str_t *names, ngx_uint_t n)
{
@@ -246,6 +388,33 @@ ngx_resolver_create(ngx_conf_t *cf, ngx_str_t *names, ngx_uint_t n)
@@ -246,6 +387,33 @@ ngx_resolver_create(ngx_conf_t *cf, ngx_str_t *names, ngx_uint_t n)
}
#endif
@ -173,7 +172,7 @@ index cd55520c..e61a6d53 100644
+
+ if (ngx_strcmp(&names[i].data[6], "on") == 0) {
+ if (ngx_resolver_read_resolv_conf(cf, r,
+ NGX_RESOLVER_FILE_NAME)
+ (u_char *) NGX_RESOLVER_FILE_NAME)
+ != NGX_OK)
+ {
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,

Loading…
Cancel
Save