mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-02 07:35:26 +00:00
If isc_socket_bind tries to bind to a socket with a different address
family than the address specified, return a meaningful error.
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: result.h,v 1.47 2000/08/01 01:30:40 tale Exp $ */
|
||||
/* $Id: result.h,v 1.48 2000/08/10 23:11:12 bwelling Exp $ */
|
||||
|
||||
#ifndef ISC_RESULT_H
|
||||
#define ISC_RESULT_H 1
|
||||
@@ -70,11 +70,12 @@
|
||||
#define ISC_R_NOTFILE 44 /* not a file */
|
||||
#define ISC_R_NOTDIRECTORY 45 /* not a directory */
|
||||
#define ISC_R_QUEUEFULL 46 /* queue is full */
|
||||
#define ISC_R_FAMILY 47 /* address family mismatch */
|
||||
|
||||
/*
|
||||
* Not an result code: the number of results.
|
||||
*/
|
||||
#define ISC_R_NRESULTS 47
|
||||
#define ISC_R_NRESULTS 48
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: result.c,v 1.46 2000/08/01 01:29:43 tale Exp $ */
|
||||
/* $Id: result.c,v 1.47 2000/08/10 23:11:09 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -84,7 +84,8 @@ static const char *text[ISC_R_NRESULTS] = {
|
||||
"invalid use of multicast address", /* 43 */
|
||||
"not a file", /* 44 */
|
||||
"not a directory", /* 45 */
|
||||
"queue is full" /* 46 */
|
||||
"queue is full", /* 46 */
|
||||
"address family mismatch" /* 47 */
|
||||
};
|
||||
|
||||
#define ISC_RESULT_RESULTSET 2
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: socket.c,v 1.155 2000/08/10 21:47:46 bwelling Exp $ */
|
||||
/* $Id: socket.c,v 1.156 2000/08/10 23:11:11 bwelling Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -134,6 +134,7 @@ struct isc_socket {
|
||||
ISC_LINK(isc_socket_t) link;
|
||||
unsigned int references;
|
||||
int fd;
|
||||
int pf;
|
||||
isc_result_t recv_result;
|
||||
isc_result_t send_result;
|
||||
|
||||
@@ -1149,6 +1150,7 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
|
||||
if (ret != ISC_R_SUCCESS)
|
||||
return (ret);
|
||||
|
||||
sock->pf = pf;
|
||||
switch (type) {
|
||||
case isc_sockettype_udp:
|
||||
sock->fd = socket(pf, SOCK_DGRAM, IPPROTO_UDP);
|
||||
@@ -2575,6 +2577,10 @@ isc_socket_bind(isc_socket_t *sock, isc_sockaddr_t *sockaddr) {
|
||||
|
||||
INSIST(!sock->bound);
|
||||
|
||||
if (sock->pf != sockaddr->type.sa.sa_family) {
|
||||
UNLOCK(&sock->lock);
|
||||
return(ISC_R_FAMILY);
|
||||
}
|
||||
if (setsockopt(sock->fd, SOL_SOCKET, SO_REUSEADDR, (void *)&on,
|
||||
sizeof on) < 0) {
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__, "setsockopt(%d) failed",
|
||||
|
Reference in New Issue
Block a user