Commit 82a50a61 authored by Mark Andrews's avatar Mark Andrews
Browse files

4474. [bug] win32: call WSAStartup in fromtext_in_wks so that

                        getprotobyname and getservbyname work.  [RT #43197]
parent 2f1c460b
4474. [bug] win32: call WSAStartup in fromtext_in_wks so that
getprotobyname and getservbyname work. [RT #43197]
4473. [bug] Only call fsync / _commit on regular files. [RT #43196]
4472. [bug] Named could fail to find the correct NSEC3 records when
......
......@@ -17,6 +17,7 @@ sub.empty TXT sub.empty
sub NS ns.sub
ns.sub A 1.2.3.4
ns.sub AAAA 2002::1.2.3.4
ns.sub WKS 1.2.3.4 udp domain
other.sub TXT other.sub
secure NS secure
secure DS 1312 50 100 96EEB2FFD9B00CD4694E78278B5EFDAB0A80446567B69F634DA078F0
......
......@@ -58,6 +58,19 @@
} \
} while (0)
#define CHECK(op) \
do { result = (op); \
if (result != ISC_R_SUCCESS) goto cleanup; \
} while (0)
#define CHECKTOK(op) \
do { result = (op); \
if (result != ISC_R_SUCCESS) { \
isc_lex_ungettoken(lexer, &token); \
goto cleanup; \
} \
} while (0)
#define DNS_AS_STR(t) ((t).value.as_textregion.base)
#define ARGS_FROMTEXT int rdclass, dns_rdatatype_t type, \
......
......@@ -52,6 +52,12 @@ mygetservbyname(const char *name, const char *proto, long *port) {
return (ISC_TF(se != NULL));
}
#ifdef _WIN32
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#endif
static inline isc_result_t
fromtext_in_wks(ARGS_FROMTEXT) {
static isc_once_t once = ISC_ONCE_INIT;
......@@ -67,6 +73,7 @@ fromtext_in_wks(ARGS_FROMTEXT) {
unsigned int n;
char service[32];
int i;
isc_result_t result;
REQUIRE(type == dns_rdatatype_wks);
REQUIRE(rdclass == dns_rdataclass_in);
......@@ -78,15 +85,29 @@ fromtext_in_wks(ARGS_FROMTEXT) {
RUNTIME_CHECK(isc_once_do(&once, init_lock) == ISC_R_SUCCESS);
#ifdef _WIN32
{
WORD wVersionRequested;
WSADATA wsaData;
int err;
wVersionRequested = MAKEWORD(2, 0);
err = WSAStartup(wVersionRequested, &wsaData );
if (err != 0)
return (ISC_R_FAILURE);
}
#endif
/*
* IPv4 dotted quad.
*/
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
CHECK(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
ISC_FALSE));
isc_buffer_availableregion(target, &region);
if (getquad(DNS_AS_STR(token), &addr, lexer, callbacks) != 1)
RETTOK(DNS_R_BADDOTTEDQUAD);
CHECKTOK(DNS_R_BADDOTTEDQUAD);
if (region.length < 4)
return (ISC_R_NOSPACE);
memmove(region.base, &addr, 4);
......@@ -95,28 +116,28 @@ fromtext_in_wks(ARGS_FROMTEXT) {
/*
* Protocol.
*/
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
CHECK(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
ISC_FALSE));
proto = strtol(DNS_AS_STR(token), &e, 10);
if (*e == 0)
;
else if (!mygetprotobyname(DNS_AS_STR(token), &proto))
RETTOK(DNS_R_UNKNOWNPROTO);
CHECKTOK(DNS_R_UNKNOWNPROTO);
if (proto < 0 || proto > 0xff)
RETTOK(ISC_R_RANGE);
CHECKTOK(ISC_R_RANGE);
if (proto == IPPROTO_TCP)
ps = "tcp";
else if (proto == IPPROTO_UDP)
ps = "udp";
RETERR(uint8_tobuffer(proto, target));
CHECK(uint8_tobuffer(proto, target));
memset(bm, 0, sizeof(bm));
do {
RETERR(isc_lex_getmastertoken(lexer, &token,
CHECK(isc_lex_getmastertoken(lexer, &token,
isc_tokentype_string, ISC_TRUE));
if (token.type != isc_tokentype_string)
break;
......@@ -136,9 +157,9 @@ fromtext_in_wks(ARGS_FROMTEXT) {
;
else if (!mygetservbyname(service, ps, &port) &&
!mygetservbyname(DNS_AS_STR(token), ps, &port))
RETTOK(DNS_R_UNKNOWNSERVICE);
CHECKTOK(DNS_R_UNKNOWNSERVICE);
if (port < 0 || port > 0xffff)
RETTOK(ISC_R_RANGE);
CHECKTOK(ISC_R_RANGE);
if (port > maxport)
maxport = port;
bm[port / 8] |= (0x80 >> (port % 8));
......@@ -150,7 +171,14 @@ fromtext_in_wks(ARGS_FROMTEXT) {
isc_lex_ungettoken(lexer, &token);
n = (maxport + 8) / 8;
return (mem_tobuffer(target, bm, n));
result = mem_tobuffer(target, bm, n);
cleanup:
#ifdef _WIN32
WSACleanup();
#endif
return (result);
}
static inline isc_result_t
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment