Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Humblet <phumblet@phumblet.no-ip.org>2010-09-22 01:41:31 +0400
committerPierre Humblet <phumblet@phumblet.no-ip.org>2010-09-22 01:41:31 +0400
commit5c22068f7f118a76430365d89433ab8bd392343d (patch)
tree64bafc56c43f6792ac0909c5fe0c3f87fa3d8428 /winsup/cygwin/libc
parentb53c1929e5f62d1a42c31145f9010e7adfe34b09 (diff)
2010-09-21 Pierre Humblet <Pierre.Humblet@ieee.org>
* libc/minires.c (res_nsend): Use the Windows resolver if appropriate. (dn_expand): Only set errno in case of error. Delete old comments. (dn_skipname): Fix typo in comment.
Diffstat (limited to 'winsup/cygwin/libc')
-rw-r--r--winsup/cygwin/libc/minires.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/winsup/cygwin/libc/minires.c b/winsup/cygwin/libc/minires.c
index c401e7c60..a3d06bff4 100644
--- a/winsup/cygwin/libc/minires.c
+++ b/winsup/cygwin/libc/minires.c
@@ -437,6 +437,26 @@ int res_nsend( res_state statp, const unsigned char * MsgPtr,
if (((statp->options & RES_INIT) == 0) && (res_ninit(statp) != 0))
return -1;
+ /* If a hook exists to a native implementation, use it */
+ if (statp->os_query) {
+ int len;
+ short int Class, Type;
+ unsigned char DomName[MAXDNAME];
+ unsigned char * ptr = MsgPtr + HFIXEDSZ;
+ len = dn_expand(MsgPtr, MsgPtr + MsgLength, ptr, DomName, sizeof(DomName));
+ if (len > 0) {
+ ptr += len;
+ GETSHORT(Type, ptr);
+ GETSHORT(Class, ptr);
+ return ((os_query_t *) statp->os_query)(statp, DomName, Class, Type, AnsPtr, AnsLength);
+ }
+ else {
+ /* dn_expand sets errno */
+ statp->res_h_errno = NETDB_INTERNAL;
+ return -1;
+ }
+ }
+
/* Close the socket if it had been opened before a fork.
Reuse of pid's cannot hurt */
if ((statp->sockfd != -1) && (statp->mypid != getpid())) {
@@ -808,9 +828,7 @@ int dn_expand(const unsigned char *msg, const unsigned char *eomorig,
{
unsigned int len, complen = 0;
const unsigned char *comp_dn_orig = comp_dn;
-/* char * exp_start = exp_dn; */
- errno = EINVAL;
if (comp_dn >= eomorig)
goto expand_fail;
if ((len = *comp_dn++) == 0) /* Weird case */
@@ -843,7 +861,7 @@ int dn_expand(const unsigned char *msg, const unsigned char *eomorig,
return complen;
expand_fail:
-/* fprintf(stderr, "dn_expand fails\n"); */
+ errno = EINVAL;
return -1;
}
@@ -962,7 +980,7 @@ int dn_skipname(const unsigned char *comp_dn, const unsigned char *eom)
/*****************************************************************
* dn_length1 For internal use
- Return length of uncompressesed name incl final 0.
+ Return length of uncompressed name incl final 0.
*****************************************************************/
int dn_length1(const unsigned char *msg, const unsigned char *eomorig,