aboutsummaryrefslogtreecommitdiff
path: root/src/gns/nss/nss_gns.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gns/nss/nss_gns.c')
-rw-r--r--src/gns/nss/nss_gns.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/gns/nss/nss_gns.c b/src/gns/nss/nss_gns.c
index 29dbfd87b..5991c5a0f 100644
--- a/src/gns/nss/nss_gns.c
+++ b/src/gns/nss/nss_gns.c
@@ -7,12 +7,12 @@
7 it under the terms of the GNU General Public License as published 7 it under the terms of the GNU General Public License as published
8 by the Free Software Foundation; either version 3 of the License, 8 by the Free Software Foundation; either version 3 of the License,
9 or (at your option) any later version. 9 or (at your option) any later version.
10 10
11 nss-mdns is distributed in the hope that it will be useful, but1 11 nss-mdns is distributed in the hope that it will be useful, but1
12 WITHOUT ANY WARRANTY; without even the implied warranty of 12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details. 14 General Public License for more details.
15 15
16 You should have received a copy of the GNU Lesser General Public License 16 You should have received a copy of the GNU Lesser General Public License
17 along with nss-mdns; if not, write to the Free Software 17 along with nss-mdns; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@@ -67,7 +67,7 @@ static int ends_with(const char *name, const char* suffix) {
67 * @return 1 if true 67 * @return 1 if true
68 */ 68 */
69static int verify_name_allowed (const char *name) { 69static int verify_name_allowed (const char *name) {
70 return ends_with(name, ".gnu") || ends_with(name, ".zkey"); 70 return ends_with(name, ".gnu") || ends_with(name, ".zkey");
71} 71}
72 72
73/** 73/**
@@ -96,7 +96,7 @@ enum nss_status _nss_gns_gethostbyname2_r(
96 int i; 96 int i;
97 size_t address_length, l, idx, astart; 97 size_t address_length, l, idx, astart;
98 int name_allowed; 98 int name_allowed;
99 99
100 if (af == AF_UNSPEC) 100 if (af == AF_UNSPEC)
101#ifdef NSS_IPV6_ONLY 101#ifdef NSS_IPV6_ONLY
102 af = AF_INET6; 102 af = AF_INET6;
@@ -105,13 +105,13 @@ enum nss_status _nss_gns_gethostbyname2_r(
105#endif 105#endif
106 106
107#ifdef NSS_IPV4_ONLY 107#ifdef NSS_IPV4_ONLY
108 if (af != AF_INET) 108 if (af != AF_INET)
109#elif NSS_IPV6_ONLY 109#elif NSS_IPV6_ONLY
110 if (af != AF_INET6) 110 if (af != AF_INET6)
111#else 111#else
112 if (af != AF_INET && af != AF_INET6) 112 if (af != AF_INET && af != AF_INET6)
113#endif 113#endif
114 { 114 {
115 *errnop = EINVAL; 115 *errnop = EINVAL;
116 *h_errnop = NO_RECOVERY; 116 *h_errnop = NO_RECOVERY;
117 117
@@ -122,19 +122,19 @@ enum nss_status _nss_gns_gethostbyname2_r(
122 if (buflen < 122 if (buflen <
123 sizeof(char*)+ /* alias names */ 123 sizeof(char*)+ /* alias names */
124 strlen(name)+1) { /* official name */ 124 strlen(name)+1) { /* official name */
125 125
126 *errnop = ERANGE; 126 *errnop = ERANGE;
127 *h_errnop = NO_RECOVERY; 127 *h_errnop = NO_RECOVERY;
128 status = NSS_STATUS_TRYAGAIN; 128 status = NSS_STATUS_TRYAGAIN;
129 129
130 goto finish; 130 goto finish;
131 } 131 }
132 132
133 u.count = 0; 133 u.count = 0;
134 u.data_len = 0; 134 u.data_len = 0;
135 135
136 name_allowed = verify_name_allowed(name); 136 name_allowed = verify_name_allowed(name);
137 137
138 if (name_allowed) { 138 if (name_allowed) {
139 139
140 if (!gns_resolve_name(af, name, &u) == 0) 140 if (!gns_resolve_name(af, name, &u) == 0)
@@ -156,22 +156,22 @@ enum nss_status _nss_gns_gethostbyname2_r(
156 goto finish; 156 goto finish;
157 } 157 }
158 158
159 159
160 /* Alias names */ 160 /* Alias names */
161 *((char**) buffer) = NULL; 161 *((char**) buffer) = NULL;
162 result->h_aliases = (char**) buffer; 162 result->h_aliases = (char**) buffer;
163 idx = sizeof(char*); 163 idx = sizeof(char*);
164 164
165 /* Official name */ 165 /* Official name */
166 strcpy(buffer+idx, name); 166 strcpy(buffer+idx, name);
167 result->h_name = buffer+idx; 167 result->h_name = buffer+idx;
168 idx += strlen(name)+1; 168 idx += strlen(name)+1;
169 169
170 ALIGN(idx); 170 ALIGN(idx);
171 171
172 result->h_addrtype = af; 172 result->h_addrtype = af;
173 result->h_length = address_length; 173 result->h_length = address_length;
174 174
175 /* Check if there's enough space for the addresses */ 175 /* Check if there's enough space for the addresses */
176 if (buflen < idx+u.data_len+sizeof(char*)*(u.count+1)) { 176 if (buflen < idx+u.data_len+sizeof(char*)*(u.count+1)) {
177 *errnop = ERANGE; 177 *errnop = ERANGE;
@@ -195,7 +195,7 @@ enum nss_status _nss_gns_gethostbyname2_r(
195 result->h_addr_list = (char**) (buffer+idx); 195 result->h_addr_list = (char**) (buffer+idx);
196 196
197 status = NSS_STATUS_SUCCESS; 197 status = NSS_STATUS_SUCCESS;
198 198
199finish: 199finish:
200 return status; 200 return status;
201} 201}
@@ -254,9 +254,9 @@ enum nss_status _nss_gns_gethostbyaddr_r(
254 int *h_errnop) { 254 int *h_errnop) {
255 255
256 /* we dont do this */ 256 /* we dont do this */
257 257
258 enum nss_status status = NSS_STATUS_UNAVAIL; 258 enum nss_status status = NSS_STATUS_UNAVAIL;
259 259
260 *errnop = EINVAL; 260 *errnop = EINVAL;
261 *h_errnop = NO_RECOVERY; 261 *h_errnop = NO_RECOVERY;
262 262