1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
|
/*
* util/fptr_wlist.c - function pointer whitelists.
*
* Copyright (c) 2007, NLnet Labs. All rights reserved.
*
* This software is open source.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* Neither the name of the NLNET LABS nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \file
*
* This file contains functions that check function pointers.
* The functions contain a whitelist of known good callback values.
* Any other values lead to an error.
*
* Due to the listing nature, this file violates all the modularization
* boundaries in the program.
*/
#include "config.h"
#include "fptr_wlist.h"
#include "svr.h"
#include "probe.h"
#include "mini_event.h"
#include "http.h"
#include "update.h"
#ifdef USE_WINSOCK
#include "winrc/netlist.h"
#include "winrc/win_svc.h"
#endif
int
fptr_whitelist_comm_point(comm_point_callback_t *fptr)
{
if(fptr == &outq_handle_udp) return 1;
else if(fptr == &outq_handle_tcp) return 1;
return 0;
}
int
fptr_whitelist_comm_point_raw(comm_point_callback_t *fptr)
{
if(fptr == &handle_ssl_accept) return 1;
else if(fptr == &http_get_callback) return 1;
else if(fptr == &control_callback) return 1;
return 0;
}
int
fptr_whitelist_comm_timer(void (*fptr)(void*))
{
if(fptr == &outq_timeout) return 1;
else if(fptr == &svr_retry_callback) return 1;
else if(fptr == &http_get_timeout_handler) return 1;
else if(fptr == &selfupdate_timeout) return 1;
else if(fptr == &svr_tcp_callback) return 1;
#ifdef USE_WINSOCK
else if(fptr == &wsvc_cron_cb) return 1;
#endif
return 0;
}
int
fptr_whitelist_comm_signal(void (*fptr)(int, void*))
{
(void)fptr;
return 0;
}
int
fptr_whitelist_event(void (*fptr)(int, short, void *))
{
if(fptr == &comm_point_udp_callback) return 1;
else if(fptr == &comm_point_udp_ancil_callback) return 1;
else if(fptr == &comm_point_tcp_accept_callback) return 1;
else if(fptr == &comm_point_tcp_handle_callback) return 1;
else if(fptr == &comm_timer_callback) return 1;
else if(fptr == &comm_signal_callback) return 1;
else if(fptr == &comm_point_local_handle_callback) return 1;
else if(fptr == &comm_point_raw_handle_callback) return 1;
#ifdef USE_WINSOCK
else if(fptr == &netlist_change_cb) return 1;
else if(fptr == &worker_win_stop_cb) return 1;
#endif
return 0;
}
int
fptr_whitelist_rbtree_cmp(int (*fptr) (const void *, const void *))
{
if(fptr == &mini_ev_cmp) return 1;
return 0;
}
#ifdef USE_WINSOCK
int fptr_whitelist_enum_reg(void (*fptr) (HKEY, void *))
{
if(fptr == &enum_reg_set_nameserver) return 1;
return 0;
}
#endif /* USE_WINSOCK */
|