mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-01 06:55:30 +00:00
[master] fix dyndb issues; isc_errno_toresult()
4445. [cleanup] isc_errno_toresult() can now be used to call the formerly private function isc__errno2result(). [RT #43050] 4444. [bug] Fixed some issues related to dyndb: A bug caused braces to be omitted when passing configuration text from named.conf to a dyndb driver, and there was a use-after-free in the sample dyndb driver. [RT #43050] Patch for dyndb driver submitted by Petr Spacek at Red Hat.
This commit is contained in:
9
CHANGES
9
CHANGES
@@ -1,3 +1,12 @@
|
|||||||
|
4445. [cleanup] isc_errno_toresult() can now be used to call the
|
||||||
|
formerly private function isc__errno2result().
|
||||||
|
[RT #43050]
|
||||||
|
|
||||||
|
4444. [bug] Fixed some issues related to dyndb: A bug caused
|
||||||
|
braces to be omitted when passing configuration text
|
||||||
|
from named.conf to a dyndb driver, and there was a
|
||||||
|
use-after-free in the sample dyndb driver. [RT #43050]
|
||||||
|
|
||||||
4443. [func] Set TCP_MAXSEG in addition to IPV6_USE_MIN_MTU on
|
4443. [func] Set TCP_MAXSEG in addition to IPV6_USE_MIN_MTU on
|
||||||
TCP sockets. [RT #42864]
|
TCP sockets. [RT #42864]
|
||||||
|
|
||||||
|
@@ -145,3 +145,12 @@ key "mykey" {
|
|||||||
algorithm "hmac-md5";
|
algorithm "hmac-md5";
|
||||||
secret "qwertyuiopasdfgh";
|
secret "qwertyuiopasdfgh";
|
||||||
};
|
};
|
||||||
|
dyndb "name" "library.so" {
|
||||||
|
this;
|
||||||
|
\};
|
||||||
|
is a {
|
||||||
|
"test" { \{ of; the; };
|
||||||
|
} bracketed;
|
||||||
|
"text \"";
|
||||||
|
system;
|
||||||
|
};
|
||||||
|
@@ -82,9 +82,14 @@ new_sample_instance(isc_mem_t *mctx, const char *db_name,
|
|||||||
|
|
||||||
CHECKED_MEM_GET_PTR(mctx, inst);
|
CHECKED_MEM_GET_PTR(mctx, inst);
|
||||||
ZERO_PTR(inst);
|
ZERO_PTR(inst);
|
||||||
inst->db_name = db_name; /* const during lifetime of inst */
|
|
||||||
isc_mem_attach(mctx, &inst->mctx);
|
isc_mem_attach(mctx, &inst->mctx);
|
||||||
|
|
||||||
|
inst->db_name = isc_mem_strdup(mctx, db_name);
|
||||||
|
if (inst->db_name == NULL) {
|
||||||
|
result = ISC_R_NOMEMORY;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
dns_fixedname_init(&inst->zone1_fn);
|
dns_fixedname_init(&inst->zone1_fn);
|
||||||
inst->zone1_name = dns_fixedname_name(&inst->zone1_fn);
|
inst->zone1_name = dns_fixedname_name(&inst->zone1_fn);
|
||||||
|
|
||||||
@@ -137,6 +142,8 @@ destroy_sample_instance(sample_instance_t **instp) {
|
|||||||
if (inst == NULL)
|
if (inst == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (inst->db_name != NULL)
|
||||||
|
isc_mem_free(inst->mctx, inst->db_name);
|
||||||
if (inst->zone1 != NULL)
|
if (inst->zone1 != NULL)
|
||||||
dns_zone_detach(&inst->zone1);
|
dns_zone_detach(&inst->zone1);
|
||||||
if (inst->zone2 != NULL)
|
if (inst->zone2 != NULL)
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
struct sample_instance {
|
struct sample_instance {
|
||||||
isc_mem_t *mctx;
|
isc_mem_t *mctx;
|
||||||
const char *db_name;
|
char *db_name;
|
||||||
dns_dbimplementation_t *db_imp;
|
dns_dbimplementation_t *db_imp;
|
||||||
|
|
||||||
/* These are needed for zone creation. */
|
/* These are needed for zone creation. */
|
||||||
|
@@ -26,7 +26,7 @@ CWARNINGS =
|
|||||||
|
|
||||||
# Alphabetically
|
# Alphabetically
|
||||||
UNIXOBJS = @ISC_ISCIPV6_O@ @ISC_ISCPK11_API_O@ \
|
UNIXOBJS = @ISC_ISCIPV6_O@ @ISC_ISCPK11_API_O@ \
|
||||||
unix/app.@O@ unix/dir.@O@ unix/entropy.@O@ \
|
unix/app.@O@ unix/dir.@O@ unix/entropy.@O@ unix/errno.@O@ \
|
||||||
unix/errno2result.@O@ unix/file.@O@ unix/fsaccess.@O@ \
|
unix/errno2result.@O@ unix/file.@O@ unix/fsaccess.@O@ \
|
||||||
unix/interfaceiter.@O@ unix/keyboard.@O@ unix/meminfo.@O@ \
|
unix/interfaceiter.@O@ unix/keyboard.@O@ unix/meminfo.@O@ \
|
||||||
unix/net.@O@ unix/os.@O@ unix/resource.@O@ unix/socket.@O@ \
|
unix/net.@O@ unix/os.@O@ unix/resource.@O@ unix/socket.@O@ \
|
||||||
@@ -39,8 +39,9 @@ THREADOPTOBJS = @ISC_THREAD_DIR@/condition.@O@ @ISC_THREAD_DIR@/mutex.@O@
|
|||||||
|
|
||||||
THREADOBJS = @THREADOPTOBJS@ @ISC_THREAD_DIR@/thread.@O@
|
THREADOBJS = @THREADOPTOBJS@ @ISC_THREAD_DIR@/thread.@O@
|
||||||
|
|
||||||
WIN32OBJS = win32/condition.@O@ win32/dir.@O@ win32/file.@O@ \
|
WIN32OBJS = win32/condition.@O@ win32/dir.@O@ win32/errno.@O@ \
|
||||||
win32/fsaccess.@O@ win32/meminfo.@O@ win32/once.@O@ \
|
win32/file.@O@ win32/fsaccess.@O@ \
|
||||||
|
win32/meminfo.@O@ win32/once.@O@ \
|
||||||
win32/stdtime.@O@ win32/thread.@O@ win32/time.@O@
|
win32/stdtime.@O@ win32/thread.@O@ win32/time.@O@
|
||||||
|
|
||||||
# Alphabetically
|
# Alphabetically
|
||||||
|
25
lib/isc/include/isc/errno.h
Normal file
25
lib/isc/include/isc/errno.h
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ISC_ERRNO_H
|
||||||
|
#define ISC_ERRNO_H 1
|
||||||
|
|
||||||
|
/*! \file isc/file.h */
|
||||||
|
|
||||||
|
#include <isc/types.h>
|
||||||
|
|
||||||
|
ISC_LANG_BEGINDECLS
|
||||||
|
|
||||||
|
isc_result_t
|
||||||
|
isc_errno_toresult(int err);
|
||||||
|
/*!<
|
||||||
|
* \brief Convert a POSIX errno value to an ISC result code.
|
||||||
|
*/
|
||||||
|
ISC_LANG_ENDDECLS
|
||||||
|
|
||||||
|
#endif /* ISC_ERRNO_H */
|
@@ -806,48 +806,46 @@ isc_lex_gettoken(isc_lex_t *lex, unsigned int options, isc_token_t *tokenp) {
|
|||||||
if (c == '{') {
|
if (c == '{') {
|
||||||
if (escaped) {
|
if (escaped) {
|
||||||
escaped = ISC_FALSE;
|
escaped = ISC_FALSE;
|
||||||
INSIST(prev != NULL);
|
|
||||||
*prev = '{';
|
|
||||||
} else {
|
} else {
|
||||||
lex->brace_count++;
|
lex->brace_count++;
|
||||||
}
|
}
|
||||||
} else if (c == '}') {
|
} else if (c == '}') {
|
||||||
if (escaped) {
|
if (escaped) {
|
||||||
escaped = ISC_FALSE;
|
escaped = ISC_FALSE;
|
||||||
INSIST(prev != NULL);
|
} else {
|
||||||
*prev = '}';
|
INSIST(lex->brace_count > 0);
|
||||||
break;
|
lex->brace_count--;
|
||||||
}
|
}
|
||||||
|
|
||||||
INSIST(lex->brace_count > 0);
|
if (lex->brace_count == 0) {
|
||||||
lex->brace_count--;
|
tokenp->type = isc_tokentype_btext;
|
||||||
if (lex->brace_count > 0)
|
tokenp->value.as_textregion.base =
|
||||||
|
lex->data;
|
||||||
|
tokenp->value.as_textregion.length =
|
||||||
|
(unsigned int) (lex->max_token -
|
||||||
|
remaining);
|
||||||
|
no_comments = ISC_FALSE;
|
||||||
|
done = ISC_TRUE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
tokenp->type = isc_tokentype_btext;
|
|
||||||
tokenp->value.as_textregion.base = lex->data;
|
|
||||||
tokenp->value.as_textregion.length =
|
|
||||||
(unsigned int) (lex->max_token -
|
|
||||||
remaining);
|
|
||||||
no_comments = ISC_FALSE;
|
|
||||||
done = ISC_TRUE;
|
|
||||||
} else {
|
|
||||||
if (c == '\\' && !escaped)
|
|
||||||
escaped = ISC_TRUE;
|
|
||||||
else
|
|
||||||
escaped = ISC_FALSE;
|
|
||||||
if (remaining == 0U) {
|
|
||||||
result = grow_data(lex, &remaining,
|
|
||||||
&curr, &prev);
|
|
||||||
if (result != ISC_R_SUCCESS)
|
|
||||||
goto done;
|
|
||||||
}
|
}
|
||||||
INSIST(remaining > 0U);
|
|
||||||
prev = curr;
|
|
||||||
*curr++ = c;
|
|
||||||
*curr = '\0';
|
|
||||||
remaining--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (c == '\\' && !escaped)
|
||||||
|
escaped = ISC_TRUE;
|
||||||
|
else
|
||||||
|
escaped = ISC_FALSE;
|
||||||
|
|
||||||
|
if (remaining == 0U) {
|
||||||
|
result = grow_data(lex, &remaining,
|
||||||
|
&curr, &prev);
|
||||||
|
if (result != ISC_R_SUCCESS)
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
INSIST(remaining > 0U);
|
||||||
|
prev = curr;
|
||||||
|
*curr++ = c;
|
||||||
|
*curr = '\0';
|
||||||
|
remaining--;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
FATAL_ERROR(__FILE__, __LINE__,
|
FATAL_ERROR(__FILE__, __LINE__,
|
||||||
|
@@ -4,8 +4,6 @@
|
|||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
# $Id$
|
|
||||||
|
|
||||||
srcdir = @srcdir@
|
srcdir = @srcdir@
|
||||||
VPATH = @srcdir@
|
VPATH = @srcdir@
|
||||||
top_srcdir = @top_srcdir@
|
top_srcdir = @top_srcdir@
|
||||||
@@ -33,7 +31,7 @@ SRCS = isctest.c taskpool_test.c socket_test.c hash_test.c \
|
|||||||
parse_test.c pool_test.c print_test.c regex_test.c \
|
parse_test.c pool_test.c print_test.c regex_test.c \
|
||||||
socket_test.c safe_test.c time_test.c aes_test.c \
|
socket_test.c safe_test.c time_test.c aes_test.c \
|
||||||
file_test.c buffer_test.c counter_test.c mem_test.c \
|
file_test.c buffer_test.c counter_test.c mem_test.c \
|
||||||
result_test.c ht_test.c
|
result_test.c ht_test.c errno_test.c
|
||||||
|
|
||||||
SUBDIRS =
|
SUBDIRS =
|
||||||
TARGETS = taskpool_test@EXEEXT@ socket_test@EXEEXT@ hash_test@EXEEXT@ \
|
TARGETS = taskpool_test@EXEEXT@ socket_test@EXEEXT@ hash_test@EXEEXT@ \
|
||||||
@@ -43,7 +41,8 @@ TARGETS = taskpool_test@EXEEXT@ socket_test@EXEEXT@ hash_test@EXEEXT@ \
|
|||||||
print_test@EXEEXT@ regex_test@EXEEXT@ socket_test@EXEEXT@ \
|
print_test@EXEEXT@ regex_test@EXEEXT@ socket_test@EXEEXT@ \
|
||||||
safe_test@EXEEXT@ time_test@EXEEXT@ aes_test@EXEEXT@ \
|
safe_test@EXEEXT@ time_test@EXEEXT@ aes_test@EXEEXT@ \
|
||||||
file_test@EXEEXT@ buffer_test@EXEEXT@ counter_test@EXEEXT@ \
|
file_test@EXEEXT@ buffer_test@EXEEXT@ counter_test@EXEEXT@ \
|
||||||
mem_test@EXEEXT@ result_test@EXEEXT@ ht_test@EXEEXT@
|
mem_test@EXEEXT@ result_test@EXEEXT@ ht_test@EXEEXT@ \
|
||||||
|
errno_test@EXEEXT@
|
||||||
|
|
||||||
@BIND9_MAKE_RULES@
|
@BIND9_MAKE_RULES@
|
||||||
|
|
||||||
@@ -140,6 +139,10 @@ ht_test@EXEEXT@: ht_test.@O@ ${ISCDEPLIBS}
|
|||||||
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
|
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
|
||||||
ht_test.@O@ ${ISCLIBS} ${LIBS}
|
ht_test.@O@ ${ISCLIBS} ${LIBS}
|
||||||
|
|
||||||
|
errno_test@EXEEXT@: errno_test.@O@ ${ISCDEPLIBS}
|
||||||
|
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
|
||||||
|
errno_test.@O@ ${ISCLIBS} ${LIBS}
|
||||||
|
|
||||||
unit::
|
unit::
|
||||||
sh ${top_srcdir}/unit/unittest.sh
|
sh ${top_srcdir}/unit/unittest.sh
|
||||||
|
|
||||||
|
102
lib/isc/tests/errno_test.c
Normal file
102
lib/isc/tests/errno_test.c
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/errno.h>
|
||||||
|
|
||||||
|
#include <atf-c.h>
|
||||||
|
|
||||||
|
#include <isc/errno.h>
|
||||||
|
#include <isc/result.h>
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int err;
|
||||||
|
isc_result_t result;
|
||||||
|
} testpair_t;
|
||||||
|
|
||||||
|
testpair_t testpair[] = {
|
||||||
|
{ EPERM, ISC_R_NOPERM },
|
||||||
|
{ ENOENT, ISC_R_FILENOTFOUND },
|
||||||
|
{ EIO, ISC_R_IOERROR },
|
||||||
|
{ EBADF, ISC_R_INVALIDFILE },
|
||||||
|
{ ENOMEM, ISC_R_NOMEMORY },
|
||||||
|
{ EACCES, ISC_R_NOPERM },
|
||||||
|
{ EEXIST, ISC_R_FILEEXISTS },
|
||||||
|
{ ENOTDIR, ISC_R_INVALIDFILE },
|
||||||
|
{ EINVAL, ISC_R_INVALIDFILE },
|
||||||
|
{ ENFILE, ISC_R_TOOMANYOPENFILES },
|
||||||
|
{ EMFILE, ISC_R_TOOMANYOPENFILES },
|
||||||
|
{ EPIPE, ISC_R_CONNECTIONRESET },
|
||||||
|
{ ENAMETOOLONG, ISC_R_INVALIDFILE },
|
||||||
|
{ ELOOP, ISC_R_INVALIDFILE },
|
||||||
|
#ifdef EOVERFLOW
|
||||||
|
{ EOVERFLOW, ISC_R_RANGE },
|
||||||
|
#endif
|
||||||
|
#ifdef EAFNOSUPPORT
|
||||||
|
{ EAFNOSUPPORT, ISC_R_FAMILYNOSUPPORT },
|
||||||
|
#endif
|
||||||
|
#ifdef EADDRINUSE
|
||||||
|
{ EADDRINUSE, ISC_R_ADDRINUSE },
|
||||||
|
#endif
|
||||||
|
{ EADDRNOTAVAIL, ISC_R_ADDRNOTAVAIL },
|
||||||
|
#ifdef ENETDOWN
|
||||||
|
{ ENETDOWN, ISC_R_NETDOWN },
|
||||||
|
#endif
|
||||||
|
#ifdef ENETUNREACH
|
||||||
|
{ ENETUNREACH, ISC_R_NETUNREACH },
|
||||||
|
#endif
|
||||||
|
#ifdef ECONNABORTED
|
||||||
|
{ ECONNABORTED, ISC_R_CONNECTIONRESET },
|
||||||
|
#endif
|
||||||
|
#ifdef ECONNRESET
|
||||||
|
{ ECONNRESET, ISC_R_CONNECTIONRESET },
|
||||||
|
#endif
|
||||||
|
#ifdef ENOBUFS
|
||||||
|
{ ENOBUFS, ISC_R_NORESOURCES },
|
||||||
|
#endif
|
||||||
|
#ifdef ENOTCONN
|
||||||
|
{ ENOTCONN, ISC_R_NOTCONNECTED },
|
||||||
|
#endif
|
||||||
|
#ifdef ETIMEDOUT
|
||||||
|
{ ETIMEDOUT, ISC_R_TIMEDOUT },
|
||||||
|
#endif
|
||||||
|
{ ECONNREFUSED, ISC_R_CONNREFUSED },
|
||||||
|
#ifdef EHOSTDOWN
|
||||||
|
{ EHOSTDOWN, ISC_R_HOSTDOWN },
|
||||||
|
#endif
|
||||||
|
#ifdef EHOSTUNREACH
|
||||||
|
{ EHOSTUNREACH, ISC_R_HOSTUNREACH },
|
||||||
|
#endif
|
||||||
|
{ 0, ISC_R_UNEXPECTED }
|
||||||
|
};
|
||||||
|
|
||||||
|
ATF_TC(isc_errno_toresult);
|
||||||
|
ATF_TC_HEAD(isc_errno_toresult, tc) {
|
||||||
|
atf_tc_set_md_var(tc, "descr", "convert errno to ISC result");
|
||||||
|
}
|
||||||
|
ATF_TC_BODY(isc_errno_toresult, tc) {
|
||||||
|
isc_result_t result, expect;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < sizeof(testpair)/sizeof(testpair[0]); i++) {
|
||||||
|
result = isc_errno_toresult(testpair[i].err);
|
||||||
|
expect = testpair[i].result;
|
||||||
|
ATF_CHECK(result == expect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Main
|
||||||
|
*/
|
||||||
|
ATF_TP_ADD_TCS(tp) {
|
||||||
|
ATF_TP_ADD_TC(tp, isc_errno_toresult);
|
||||||
|
return (atf_no_error());
|
||||||
|
}
|
||||||
|
|
@@ -4,8 +4,6 @@
|
|||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
# $Id: Makefile.in,v 1.44 2009/12/05 23:31:41 each Exp $
|
|
||||||
|
|
||||||
srcdir = @srcdir@
|
srcdir = @srcdir@
|
||||||
VPATH = @srcdir@
|
VPATH = @srcdir@
|
||||||
top_srcdir = @top_srcdir@
|
top_srcdir = @top_srcdir@
|
||||||
@@ -21,15 +19,16 @@ CWARNINGS =
|
|||||||
|
|
||||||
# Alphabetically
|
# Alphabetically
|
||||||
OBJS = @ISC_IPV6_O@ @ISC_PK11_API_O@ \
|
OBJS = @ISC_IPV6_O@ @ISC_PK11_API_O@ \
|
||||||
app.@O@ dir.@O@ entropy.@O@ errno2result.@O@ file.@O@ \
|
app.@O@ dir.@O@ entropy.@O@ errno.@O@ errno2result.@O@ \
|
||||||
fsaccess.@O@ interfaceiter.@O@ keyboard.@O@ meminfo.@O@ \
|
file.@O@ fsaccess.@O@ interfaceiter.@O@ \
|
||||||
|
keyboard.@O@ meminfo.@O@ \
|
||||||
net.@O@ os.@O@ resource.@O@ socket.@O@ stdio.@O@ stdtime.@O@ \
|
net.@O@ os.@O@ resource.@O@ socket.@O@ stdio.@O@ stdtime.@O@ \
|
||||||
strerror.@O@ syslog.@O@ time.@O@
|
strerror.@O@ syslog.@O@ time.@O@
|
||||||
|
|
||||||
# Alphabetically
|
# Alphabetically
|
||||||
SRCS = @ISC_IPV6_C@ @ISC_PK11_API_C@ \
|
SRCS = @ISC_IPV6_C@ @ISC_PK11_API_C@ \
|
||||||
app.c dir.c entropy.c errno2result.c file.c \
|
app.c dir.c entropy.c errno.c errno2result.c \
|
||||||
fsaccess.c interfaceiter.c keyboard.c meminfo.c \
|
file.c fsaccess.c interfaceiter.c keyboard.c meminfo.c \
|
||||||
net.c os.c resource.c socket.c stdio.c stdtime.c \
|
net.c os.c resource.c socket.c stdio.c stdtime.c \
|
||||||
strerror.c syslog.c time.c
|
strerror.c syslog.c time.c
|
||||||
|
|
||||||
|
21
lib/isc/unix/errno.c
Normal file
21
lib/isc/unix/errno.c
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \file */
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include <isc/errno.h>
|
||||||
|
#include <isc/util.h>
|
||||||
|
|
||||||
|
#include "errno2result.h"
|
||||||
|
|
||||||
|
isc_result_t
|
||||||
|
isc_errno_toresult(int err) {
|
||||||
|
return (isc___errno2result(err, ISC_FALSE, 0, 0));
|
||||||
|
}
|
@@ -25,7 +25,9 @@
|
|||||||
* not already there.
|
* not already there.
|
||||||
*/
|
*/
|
||||||
isc_result_t
|
isc_result_t
|
||||||
isc___errno2result(int posixerrno, const char *file, unsigned int line) {
|
isc___errno2result(int posixerrno, isc_boolean_t dolog,
|
||||||
|
const char *file, unsigned int line)
|
||||||
|
{
|
||||||
char strbuf[ISC_STRERRORSIZE];
|
char strbuf[ISC_STRERRORSIZE];
|
||||||
|
|
||||||
switch (posixerrno) {
|
switch (posixerrno) {
|
||||||
@@ -102,10 +104,12 @@ isc___errno2result(int posixerrno, const char *file, unsigned int line) {
|
|||||||
case ECONNREFUSED:
|
case ECONNREFUSED:
|
||||||
return (ISC_R_CONNREFUSED);
|
return (ISC_R_CONNREFUSED);
|
||||||
default:
|
default:
|
||||||
isc__strerror(posixerrno, strbuf, sizeof(strbuf));
|
if (dolog) {
|
||||||
UNEXPECTED_ERROR(file, line, "unable to convert errno "
|
isc__strerror(posixerrno, strbuf, sizeof(strbuf));
|
||||||
"to isc_result: %d: %s",
|
UNEXPECTED_ERROR(file, line, "unable to convert errno "
|
||||||
posixerrno, strbuf);
|
"to isc_result: %d: %s",
|
||||||
|
posixerrno, strbuf);
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* XXXDCL would be nice if perhaps this function could
|
* XXXDCL would be nice if perhaps this function could
|
||||||
* return the system's error string, so the caller
|
* return the system's error string, so the caller
|
||||||
|
@@ -6,8 +6,6 @@
|
|||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id$ */
|
|
||||||
|
|
||||||
#ifndef UNIX_ERRNO2RESULT_H
|
#ifndef UNIX_ERRNO2RESULT_H
|
||||||
#define UNIX_ERRNO2RESULT_H 1
|
#define UNIX_ERRNO2RESULT_H 1
|
||||||
|
|
||||||
@@ -22,10 +20,11 @@
|
|||||||
|
|
||||||
ISC_LANG_BEGINDECLS
|
ISC_LANG_BEGINDECLS
|
||||||
|
|
||||||
#define isc__errno2result(x) isc___errno2result(x, __FILE__, __LINE__)
|
#define isc__errno2result(x) isc___errno2result(x, ISC_TRUE, __FILE__, __LINE__)
|
||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
isc___errno2result(int posixerrno, const char *file, unsigned int line);
|
isc___errno2result(int posixerrno, isc_boolean_t dolog,
|
||||||
|
const char *file, unsigned int line);
|
||||||
|
|
||||||
ISC_LANG_ENDDECLS
|
ISC_LANG_ENDDECLS
|
||||||
|
|
||||||
|
@@ -4,8 +4,6 @@
|
|||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
# $Id: Makefile.in,v 1.14 2009/12/05 23:31:41 each Exp $
|
|
||||||
|
|
||||||
srcdir = @srcdir@
|
srcdir = @srcdir@
|
||||||
VPATH = @srcdir@
|
VPATH = @srcdir@
|
||||||
top_srcdir = @top_srcdir@
|
top_srcdir = @top_srcdir@
|
||||||
@@ -18,11 +16,13 @@ CDEFINES =
|
|||||||
CWARNINGS =
|
CWARNINGS =
|
||||||
|
|
||||||
# Alphabetically
|
# Alphabetically
|
||||||
OBJS = condition.@O@ dir.@O@ file.@O@ meminfo.@O@ fsaccess.@O@ \
|
OBJS = condition.@O@ dir.@O@ errno.@O@ file.@O@ \
|
||||||
|
meminfo.@O@ fsaccess.@O@ \
|
||||||
once.@O@ stdtime.@O@ thread.@O@ time.@O@ @ISC_PK11_API_O@
|
once.@O@ stdtime.@O@ thread.@O@ time.@O@ @ISC_PK11_API_O@
|
||||||
|
|
||||||
# Alphabetically
|
# Alphabetically
|
||||||
SRCS = condition.c dir.c file.c meminfo.c once.c fsaccess.c \
|
SRCS = condition.c dir.c errno.c file.c \
|
||||||
|
meminfo.c once.c fsaccess.c \
|
||||||
stdtime.c thread.c time.c @ISC_PK11_API_C@
|
stdtime.c thread.c time.c @ISC_PK11_API_C@
|
||||||
|
|
||||||
SUBDIRS = include
|
SUBDIRS = include
|
||||||
|
18
lib/isc/win32/errno.c
Normal file
18
lib/isc/win32/errno.c
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \file */
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include "errno2result.h"
|
||||||
|
|
||||||
|
isc_result_t
|
||||||
|
isc_errno_toresult(int err) {
|
||||||
|
return (isc__errno2resultx(err, ISC_FALSE, 0, 0));
|
||||||
|
}
|
@@ -23,7 +23,9 @@
|
|||||||
* not already there.
|
* not already there.
|
||||||
*/
|
*/
|
||||||
isc_result_t
|
isc_result_t
|
||||||
isc__errno2resultx(int posixerrno, const char *file, int line) {
|
isc__errno2resultx(int posixerrno, isc_boolean_t dolog,
|
||||||
|
const char *file, int line)
|
||||||
|
{
|
||||||
char strbuf[ISC_STRERRORSIZE];
|
char strbuf[ISC_STRERRORSIZE];
|
||||||
|
|
||||||
switch (posixerrno) {
|
switch (posixerrno) {
|
||||||
@@ -94,9 +96,13 @@ isc__errno2resultx(int posixerrno, const char *file, int line) {
|
|||||||
case WSAENOBUFS:
|
case WSAENOBUFS:
|
||||||
return (ISC_R_NORESOURCES);
|
return (ISC_R_NORESOURCES);
|
||||||
default:
|
default:
|
||||||
isc__strerror(posixerrno, strbuf, sizeof(strbuf));
|
if (dolog) {
|
||||||
UNEXPECTED_ERROR(file, line, "unable to convert errno "
|
isc__strerror(posixerrno, strbuf, sizeof(strbuf));
|
||||||
"to isc_result: %d: %s", posixerrno, strbuf);
|
UNEXPECTED_ERROR(file, line,
|
||||||
|
"unable to convert errno "
|
||||||
|
"to isc_result: %d: %s",
|
||||||
|
posixerrno, strbuf);
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* XXXDCL would be nice if perhaps this function could
|
* XXXDCL would be nice if perhaps this function could
|
||||||
* return the system's error string, so the caller
|
* return the system's error string, so the caller
|
||||||
|
@@ -21,10 +21,11 @@
|
|||||||
ISC_LANG_BEGINDECLS
|
ISC_LANG_BEGINDECLS
|
||||||
|
|
||||||
#define isc__errno2result(posixerrno) \
|
#define isc__errno2result(posixerrno) \
|
||||||
isc__errno2resultx(posixerrno, __FILE__, __LINE__)
|
isc__errno2resultx(posixerrno, ISC_TRUE, __FILE__, __LINE__)
|
||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
isc__errno2resultx(int posixerrno, const char *file, int line);
|
isc__errno2resultx(int posixerrno, isc_boolean_t dolog,
|
||||||
|
const char *file, int line);
|
||||||
|
|
||||||
ISC_LANG_ENDDECLS
|
ISC_LANG_ENDDECLS
|
||||||
|
|
||||||
|
@@ -121,6 +121,10 @@ SOURCE=.\entropy.c
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\errno.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\errno2result.c
|
SOURCE=.\errno2result.c
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
@@ -293,6 +297,10 @@ SOURCE=..\include\isc\entropy.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\include\isc\errno.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\errno2result.h
|
SOURCE=.\errno2result.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
@@ -133,6 +133,7 @@ CLEAN :
|
|||||||
-@erase "$(INTDIR)\dir.obj"
|
-@erase "$(INTDIR)\dir.obj"
|
||||||
-@erase "$(INTDIR)\DLLMain.obj"
|
-@erase "$(INTDIR)\DLLMain.obj"
|
||||||
-@erase "$(INTDIR)\entropy.obj"
|
-@erase "$(INTDIR)\entropy.obj"
|
||||||
|
-@erase "$(INTDIR)\errno.obj"
|
||||||
-@erase "$(INTDIR)\errno2result.obj"
|
-@erase "$(INTDIR)\errno2result.obj"
|
||||||
-@erase "$(INTDIR)\error.obj"
|
-@erase "$(INTDIR)\error.obj"
|
||||||
-@erase "$(INTDIR)\event.obj"
|
-@erase "$(INTDIR)\event.obj"
|
||||||
@@ -236,6 +237,7 @@ LINK32_OBJS= \
|
|||||||
"$(INTDIR)\dir.obj" \
|
"$(INTDIR)\dir.obj" \
|
||||||
"$(INTDIR)\DLLMain.obj" \
|
"$(INTDIR)\DLLMain.obj" \
|
||||||
"$(INTDIR)\entropy.obj" \
|
"$(INTDIR)\entropy.obj" \
|
||||||
|
"$(INTDIR)\errno.obj" \
|
||||||
"$(INTDIR)\errno2result.obj" \
|
"$(INTDIR)\errno2result.obj" \
|
||||||
"$(INTDIR)\file.obj" \
|
"$(INTDIR)\file.obj" \
|
||||||
"$(INTDIR)\fsaccess.obj" \
|
"$(INTDIR)\fsaccess.obj" \
|
||||||
@@ -381,6 +383,8 @@ CLEAN :
|
|||||||
-@erase "$(INTDIR)\DLLMain.sbr"
|
-@erase "$(INTDIR)\DLLMain.sbr"
|
||||||
-@erase "$(INTDIR)\entropy.obj"
|
-@erase "$(INTDIR)\entropy.obj"
|
||||||
-@erase "$(INTDIR)\entropy.sbr"
|
-@erase "$(INTDIR)\entropy.sbr"
|
||||||
|
-@erase "$(INTDIR)\errno.obj"
|
||||||
|
-@erase "$(INTDIR)\errno.sbr"
|
||||||
-@erase "$(INTDIR)\errno2result.obj"
|
-@erase "$(INTDIR)\errno2result.obj"
|
||||||
-@erase "$(INTDIR)\errno2result.sbr"
|
-@erase "$(INTDIR)\errno2result.sbr"
|
||||||
-@erase "$(INTDIR)\error.obj"
|
-@erase "$(INTDIR)\error.obj"
|
||||||
@@ -552,6 +556,7 @@ BSC32_SBRS= \
|
|||||||
"$(INTDIR)\dir.sbr" \
|
"$(INTDIR)\dir.sbr" \
|
||||||
"$(INTDIR)\DLLMain.sbr" \
|
"$(INTDIR)\DLLMain.sbr" \
|
||||||
"$(INTDIR)\entropy.sbr" \
|
"$(INTDIR)\entropy.sbr" \
|
||||||
|
"$(INTDIR)\errno.sbr" \
|
||||||
"$(INTDIR)\errno2result.sbr" \
|
"$(INTDIR)\errno2result.sbr" \
|
||||||
"$(INTDIR)\file.sbr" \
|
"$(INTDIR)\file.sbr" \
|
||||||
"$(INTDIR)\fsaccess.sbr" \
|
"$(INTDIR)\fsaccess.sbr" \
|
||||||
@@ -658,6 +663,7 @@ LINK32_OBJS= \
|
|||||||
"$(INTDIR)\dir.obj" \
|
"$(INTDIR)\dir.obj" \
|
||||||
"$(INTDIR)\DLLMain.obj" \
|
"$(INTDIR)\DLLMain.obj" \
|
||||||
"$(INTDIR)\entropy.obj" \
|
"$(INTDIR)\entropy.obj" \
|
||||||
|
"$(INTDIR)\errno.obj" \
|
||||||
"$(INTDIR)\errno2result.obj" \
|
"$(INTDIR)\errno2result.obj" \
|
||||||
"$(INTDIR)\file.obj" \
|
"$(INTDIR)\file.obj" \
|
||||||
"$(INTDIR)\fsaccess.obj" \
|
"$(INTDIR)\fsaccess.obj" \
|
||||||
@@ -878,6 +884,23 @@ SOURCE=.\entropy.c
|
|||||||
|
|
||||||
!ENDIF
|
!ENDIF
|
||||||
|
|
||||||
|
SOURCE=.\errno.c
|
||||||
|
|
||||||
|
!IF "$(CFG)" == "libisc - @PLATFORM@ Release"
|
||||||
|
|
||||||
|
|
||||||
|
"$(INTDIR)\errno.obj" : $(SOURCE) "$(INTDIR)"
|
||||||
|
|
||||||
|
|
||||||
|
!ELSEIF "$(CFG)" == "libisc - @PLATFORM@ Debug"
|
||||||
|
|
||||||
|
|
||||||
|
"$(INTDIR)\errno.obj" "$(INTDIR)\errno.sbr" : $(SOURCE) "$(INTDIR)"
|
||||||
|
|
||||||
|
|
||||||
|
!ENDIF
|
||||||
|
|
||||||
|
|
||||||
SOURCE=.\errno2result.c
|
SOURCE=.\errno2result.c
|
||||||
|
|
||||||
!IF "$(CFG)" == "libisc - @PLATFORM@ Release"
|
!IF "$(CFG)" == "libisc - @PLATFORM@ Release"
|
||||||
|
@@ -70,6 +70,9 @@
|
|||||||
<ClInclude Include="..\include\isc\entropy.h">
|
<ClInclude Include="..\include\isc\entropy.h">
|
||||||
<Filter>Library Header Files</Filter>
|
<Filter>Library Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\include\isc\errno.h">
|
||||||
|
<Filter>Library Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="..\include\isc\error.h">
|
<ClInclude Include="..\include\isc\error.h">
|
||||||
<Filter>Library Header Files</Filter>
|
<Filter>Library Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@@ -407,6 +410,9 @@
|
|||||||
<ClCompile Include="entropy.c">
|
<ClCompile Include="entropy.c">
|
||||||
<Filter>Win32 Source Files</Filter>
|
<Filter>Win32 Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="errno.c">
|
||||||
|
<Filter>Win32 Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="errno2result.c">
|
<ClCompile Include="errno2result.c">
|
||||||
<Filter>Win32 Source Files</Filter>
|
<Filter>Win32 Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@@ -311,6 +311,7 @@ copy InstallFiles ..\Build\Release\
|
|||||||
<ClInclude Include="..\include\isc\counter.h" />
|
<ClInclude Include="..\include\isc\counter.h" />
|
||||||
<ClInclude Include="..\include\isc\crc64.h" />
|
<ClInclude Include="..\include\isc\crc64.h" />
|
||||||
<ClInclude Include="..\include\isc\entropy.h" />
|
<ClInclude Include="..\include\isc\entropy.h" />
|
||||||
|
<ClInclude Include="..\include\isc\errno.h" />
|
||||||
<ClInclude Include="..\include\isc\error.h" />
|
<ClInclude Include="..\include\isc\error.h" />
|
||||||
<ClInclude Include="..\include\isc\event.h" />
|
<ClInclude Include="..\include\isc\event.h" />
|
||||||
<ClInclude Include="..\include\isc\eventclass.h" />
|
<ClInclude Include="..\include\isc\eventclass.h" />
|
||||||
@@ -495,6 +496,7 @@ copy InstallFiles ..\Build\Release\
|
|||||||
<ClCompile Include="dir.c" />
|
<ClCompile Include="dir.c" />
|
||||||
<ClCompile Include="DLLMain.c" />
|
<ClCompile Include="DLLMain.c" />
|
||||||
<ClCompile Include="entropy.c" />
|
<ClCompile Include="entropy.c" />
|
||||||
|
<ClCompile Include="errno.c" />
|
||||||
<ClCompile Include="errno2result.c" />
|
<ClCompile Include="errno2result.c" />
|
||||||
<ClCompile Include="file.c" />
|
<ClCompile Include="file.c" />
|
||||||
<ClCompile Include="fsaccess.c" />
|
<ClCompile Include="fsaccess.c" />
|
||||||
|
@@ -2522,7 +2522,7 @@ SocketIoThread(LPVOID ThreadContext) {
|
|||||||
* Did the I/O operation complete?
|
* Did the I/O operation complete?
|
||||||
*/
|
*/
|
||||||
errstatus = GetLastError();
|
errstatus = GetLastError();
|
||||||
isc_result = isc__errno2resultx(errstatus, __FILE__, __LINE__);
|
isc_result = isc__errno2result(errstatus);
|
||||||
|
|
||||||
LOCK(&sock->lock);
|
LOCK(&sock->lock);
|
||||||
CONSISTENT(sock);
|
CONSISTENT(sock);
|
||||||
@@ -2574,7 +2574,7 @@ SocketIoThread(LPVOID ThreadContext) {
|
|||||||
goto wait_again;
|
goto wait_again;
|
||||||
} else {
|
} else {
|
||||||
errstatus = GetLastError();
|
errstatus = GetLastError();
|
||||||
isc_result = isc__errno2resultx(errstatus, __FILE__, __LINE__);
|
isc_result = isc__errno2result(errstatus);
|
||||||
socket_log(__LINE__, sock, NULL, EVENT, NULL, 0, 0,
|
socket_log(__LINE__, sock, NULL, EVENT, NULL, 0, 0,
|
||||||
"restart_accept() failed: errstatus=%d isc_result=%d",
|
"restart_accept() failed: errstatus=%d isc_result=%d",
|
||||||
errstatus, isc_result);
|
errstatus, isc_result);
|
||||||
|
Reference in New Issue
Block a user