Deleted Added
full compact
ip_fw_sockopt.c (290330) ip_fw_sockopt.c (290332)
1/*-
2 * Copyright (c) 2002-2009 Luigi Rizzo, Universita` di Pisa
3 * Copyright (c) 2014 Yandex LLC
4 * Copyright (c) 2014 Alexander V. Chernikov
5 *
6 * Supported by: Valeria Paoli
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2002-2009 Luigi Rizzo, Universita` di Pisa
3 * Copyright (c) 2014 Yandex LLC
4 * Copyright (c) 2014 Alexander V. Chernikov
5 *
6 * Supported by: Valeria Paoli
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/netpfil/ipfw/ip_fw_sockopt.c 290330 2015-11-03 10:21:53Z ae $");
31__FBSDID("$FreeBSD: head/sys/netpfil/ipfw/ip_fw_sockopt.c 290332 2015-11-03 10:29:46Z ae $");
32
33/*
34 * Control socket and rule management routines for ipfw.
35 * Control is currently implemented via IP_FW3 setsockopt() code.
36 */
37
38#include "opt_ipfw.h"
39#include "opt_inet.h"

--- 2111 unchanged lines hidden (view full) ---

2151 IPFW_UH_RUNLOCK(chain);
2152
2153 if (bmask != NULL)
2154 free(bmask, M_TEMP);
2155
2156 return (error);
2157}
2158
32
33/*
34 * Control socket and rule management routines for ipfw.
35 * Control is currently implemented via IP_FW3 setsockopt() code.
36 */
37
38#include "opt_ipfw.h"
39#include "opt_inet.h"

--- 2111 unchanged lines hidden (view full) ---

2151 IPFW_UH_RUNLOCK(chain);
2152
2153 if (bmask != NULL)
2154 free(bmask, M_TEMP);
2155
2156 return (error);
2157}
2158
2159static int
2160check_object_name(ipfw_obj_ntlv *ntlv)
2159int
2160ipfw_check_object_name_generic(const char *name)
2161{
2161{
2162 int error;
2162 int nsize;
2163
2163
2164 switch (ntlv->head.type) {
2165 case IPFW_TLV_TBL_NAME:
2166 error = ipfw_check_table_name(ntlv->name);
2167 break;
2168 default:
2169 error = ENOTSUP;
2170 }
2171
2164 nsize = sizeof(((ipfw_obj_ntlv *)0)->name);
2165 if (strnlen(name, nsize) == nsize)
2166 return (EINVAL);
2167 if (name[0] == '\0')
2168 return (EINVAL);
2172 return (0);
2173}
2174
2175/*
2176 * Creates non-existent objects referenced by rule.
2177 *
2178 * Return 0 on success.
2179 */

--- 298 unchanged lines hidden (view full) ---

2478 * there are no duplicates.
2479 */
2480 idx = -1;
2481 ntlv = (ipfw_obj_ntlv *)(ctlv + 1);
2482 while (count > 0) {
2483 if (ntlv->head.length != sizeof(ipfw_obj_ntlv))
2484 return (EINVAL);
2485
2169 return (0);
2170}
2171
2172/*
2173 * Creates non-existent objects referenced by rule.
2174 *
2175 * Return 0 on success.
2176 */

--- 298 unchanged lines hidden (view full) ---

2475 * there are no duplicates.
2476 */
2477 idx = -1;
2478 ntlv = (ipfw_obj_ntlv *)(ctlv + 1);
2479 while (count > 0) {
2480 if (ntlv->head.length != sizeof(ipfw_obj_ntlv))
2481 return (EINVAL);
2482
2486 error = check_object_name(ntlv);
2483 error = ipfw_check_object_name_generic(ntlv->name);
2487 if (error != 0)
2488 return (error);
2489
2490 if (ntlv->idx <= idx)
2491 return (EINVAL);
2492
2493 idx = ntlv->idx;
2494 count--;

--- 1558 unchanged lines hidden ---
2484 if (error != 0)
2485 return (error);
2486
2487 if (ntlv->idx <= idx)
2488 return (EINVAL);
2489
2490 idx = ntlv->idx;
2491 count--;

--- 1558 unchanged lines hidden ---