|
Lines 268-274
getanswer_r (const querybuf *answer, int
Link Here
|
| 268 |
|
268 |
|
| 269 |
/* Skip the question part. */ |
269 |
/* Skip the question part. */ |
| 270 |
while (question_count-- > 0) |
270 |
while (question_count-- > 0) |
| 271 |
cp += __dn_skipname (cp, end_of_message) + QFIXEDSZ; |
271 |
{ |
|
|
272 |
int n = __dn_skipname (cp, end_of_message); |
| 273 |
if (n < 0 || end_of_message - (cp + n) < QFIXEDSZ) |
| 274 |
{ |
| 275 |
__set_h_errno (NO_RECOVERY); |
| 276 |
return NSS_STATUS_UNAVAIL; |
| 277 |
} |
| 278 |
cp += n + QFIXEDSZ; |
| 279 |
} |
| 272 |
|
280 |
|
| 273 |
alias_pointer = result->n_aliases = &net_data->aliases[0]; |
281 |
alias_pointer = result->n_aliases = &net_data->aliases[0]; |
| 274 |
*alias_pointer = NULL; |
282 |
*alias_pointer = NULL; |
|
Lines 301-364
getanswer_r (const querybuf *answer, int
Link Here
|
| 301 |
return NSS_STATUS_UNAVAIL; |
309 |
return NSS_STATUS_UNAVAIL; |
| 302 |
} |
310 |
} |
| 303 |
cp += n; |
311 |
cp += n; |
| 304 |
*alias_pointer++ = bp; |
312 |
if (alias_pointer + 2 < &net_data->aliases[MAX_NR_ALIASES]) |
| 305 |
n = strlen (bp) + 1; |
313 |
{ |
| 306 |
bp += n; |
314 |
*alias_pointer++ = bp; |
| 307 |
linebuflen -= n; |
315 |
n = strlen (bp) + 1; |
| 308 |
result->n_addrtype = class == C_IN ? AF_INET : AF_UNSPEC; |
316 |
bp += n; |
| 309 |
++have_answer; |
317 |
linebuflen -= n; |
|
|
318 |
result->n_addrtype = class == C_IN ? AF_INET : AF_UNSPEC; |
| 319 |
++have_answer; |
| 320 |
} |
| 310 |
} |
321 |
} |
| 311 |
} |
322 |
} |
| 312 |
|
323 |
|
| 313 |
if (have_answer) |
324 |
if (have_answer) |
| 314 |
{ |
325 |
{ |
| 315 |
char *tmp; |
|
|
| 316 |
int len; |
| 317 |
char *in, *cp, *rp, *wp; |
| 318 |
int cnt, first_flag; |
| 319 |
|
| 320 |
*alias_pointer = NULL; |
326 |
*alias_pointer = NULL; |
| 321 |
switch (net_i) |
327 |
switch (net_i) |
| 322 |
{ |
328 |
{ |
| 323 |
case BYADDR: |
329 |
case BYADDR: |
| 324 |
result->n_name = result->n_aliases[0]; |
330 |
result->n_name = *result->n_aliases++; |
| 325 |
result->n_net = 0L; |
331 |
result->n_net = 0L; |
| 326 |
break; |
332 |
return NSS_STATUS_SUCCESS; |
| 327 |
case BYNAME: |
|
|
| 328 |
len = strlen (result->n_aliases[0]); |
| 329 |
tmp = (char *) alloca (len + 1); |
| 330 |
tmp[len] = 0; |
| 331 |
wp = &tmp[len - 1]; |
| 332 |
|
| 333 |
rp = in = result->n_aliases[0]; |
| 334 |
result->n_name = ans; |
| 335 |
|
333 |
|
| 336 |
first_flag = 1; |
334 |
case BYNAME: |
| 337 |
for (cnt = 0; cnt < 4; ++cnt) |
335 |
{ |
| 338 |
{ |
336 |
char **ap = result->n_aliases++; |
| 339 |
char *startp; |
337 |
while (*ap != NULL) |
| 340 |
|
338 |
{ |
| 341 |
startp = rp; |
339 |
/* Check each alias name for being of the forms: |
| 342 |
while (*rp != '.') |
340 |
4.3.2.1.in-addr.arpa = net 1.2.3.4 |
| 343 |
++rp; |
341 |
3.2.1.in-addr.arpa = net 0.1.2.3 |
| 344 |
if (rp - startp > 1 || *startp != '0' || !first_flag) |
342 |
2.1.in-addr.arpa = net 0.0.1.2 |
| 345 |
{ |
343 |
1.in-addr.arpa = net 0.0.0.1 |
| 346 |
first_flag = 0; |
344 |
*/ |
| 347 |
if (cnt > 0) |
345 |
uint32_t val = 0; /* Accumulator for n_net value. */ |
| 348 |
*wp-- = '.'; |
346 |
unsigned int shift = 0; /* Which part we are parsing now. */ |
| 349 |
cp = rp; |
347 |
const char *p = *ap; /* Consuming the string. */ |
| 350 |
while (cp > startp) |
348 |
do |
| 351 |
*wp-- = *--cp; |
349 |
{ |
| 352 |
} |
350 |
/* Match the leading 0 or 0[xX] base indicator. */ |
| 353 |
in = rp + 1; |
351 |
unsigned int base = 10; |
| 354 |
} |
352 |
uint32_t part = 0; /* Accumulates this part's number. */ |
| 355 |
|
353 |
if (*p == '0' && p[1] != '.') |
| 356 |
result->n_net = inet_network (wp); |
354 |
{ |
|
|
355 |
base = 8; |
| 356 |
++p; |
| 357 |
if (*p == 'x' || *p == 'X') |
| 358 |
{ |
| 359 |
base = 16; |
| 360 |
++p; |
| 361 |
if (*p == '.') |
| 362 |
break; /* No digit here. Give up on alias. */ |
| 363 |
} |
| 364 |
if (*p == '\0') |
| 365 |
break; |
| 366 |
} |
| 367 |
|
| 368 |
do |
| 369 |
{ |
| 370 |
if (isdigit (*p) && (*p - '0' < base)) |
| 371 |
part = (part * base) + (*p - '0'); |
| 372 |
else if (base == 16 && isxdigit (*p)) |
| 373 |
part = (part << 4) + 10 + (tolower (*p) - 'a'); |
| 374 |
++p; |
| 375 |
} while (*p != '\0' && *p != '.'); |
| 376 |
|
| 377 |
if (*p != '.') |
| 378 |
break; /* Bad form. Give up on this name. */ |
| 379 |
|
| 380 |
/* Install this as the next more significant byte. */ |
| 381 |
val |= part << shift; |
| 382 |
shift += 8; |
| 383 |
++p; |
| 384 |
|
| 385 |
/* If we are out of digits now, there are two cases: |
| 386 |
1. We are done with digits and now see "in-addr.arpa". |
| 387 |
2. This is not the droid we are looking for. */ |
| 388 |
if (!isdigit (*p) && !strcasecmp (p, "in-addr.arpa")) |
| 389 |
{ |
| 390 |
result->n_net = val; |
| 391 |
return NSS_STATUS_SUCCESS; |
| 392 |
} |
| 393 |
|
| 394 |
/* Keep going when we have seen fewer than 4 parts. */ |
| 395 |
} while (shift < 32); |
| 396 |
} |
| 397 |
} |
| 357 |
break; |
398 |
break; |
| 358 |
} |
399 |
} |
| 359 |
|
|
|
| 360 |
++result->n_aliases; |
| 361 |
return NSS_STATUS_SUCCESS; |
| 362 |
} |
400 |
} |
| 363 |
|
401 |
|
| 364 |
__set_h_errno (TRY_AGAIN); |
402 |
__set_h_errno (TRY_AGAIN); |