ip_state.c (172776) | ip_state.c (173181) |
---|---|
1/* $FreeBSD: head/sys/contrib/ipfilter/netinet/ip_state.c 172776 2007-10-18 21:52:14Z darrenr $ */ | 1/* $FreeBSD: head/sys/contrib/ipfilter/netinet/ip_state.c 173181 2007-10-30 15:23:27Z darrenr $ */ |
2 3/* 4 * Copyright (C) 1995-2003 by Darren Reed. 5 * 6 * See the IPFILTER.LICENCE file for details on licencing. 7 */ 8#if defined(KERNEL) || defined(_KERNEL) 9# undef KERNEL --- 640 unchanged lines hidden (view full) --- 650 ipstate_t *is, *isn; 651 ipstate_save_t ips; 652 int error; 653 654 error = fr_inobj(data, &ips, IPFOBJ_STATESAVE); 655 if (error != 0) 656 return error; 657 | 2 3/* 4 * Copyright (C) 1995-2003 by Darren Reed. 5 * 6 * See the IPFILTER.LICENCE file for details on licencing. 7 */ 8#if defined(KERNEL) || defined(_KERNEL) 9# undef KERNEL --- 640 unchanged lines hidden (view full) --- 650 ipstate_t *is, *isn; 651 ipstate_save_t ips; 652 int error; 653 654 error = fr_inobj(data, &ips, IPFOBJ_STATESAVE); 655 if (error != 0) 656 return error; 657 |
658 READ_ENTER(&ipf_state); |
|
658 isn = ips.ips_next; 659 if (isn == NULL) { 660 isn = ips_list; 661 if (isn == NULL) { | 659 isn = ips.ips_next; 660 if (isn == NULL) { 661 isn = ips_list; 662 if (isn == NULL) { |
663 RWLOCK_EXIT(&ipf_state); |
|
662 if (ips.ips_next == NULL) 663 return ENOENT; 664 return 0; 665 } 666 } else { 667 /* 668 * Make sure the pointer we're copying from exists in the 669 * current list of entries. Security precaution to prevent 670 * copying of random kernel data. 671 */ 672 for (is = ips_list; is; is = is->is_next) 673 if (is == isn) 674 break; | 664 if (ips.ips_next == NULL) 665 return ENOENT; 666 return 0; 667 } 668 } else { 669 /* 670 * Make sure the pointer we're copying from exists in the 671 * current list of entries. Security precaution to prevent 672 * copying of random kernel data. 673 */ 674 for (is = ips_list; is; is = is->is_next) 675 if (is == isn) 676 break; |
675 if (!is) | 677 if (is == NULL) { 678 RWLOCK_EXIT(&ipf_state); |
676 return ESRCH; | 679 return ESRCH; |
680 } |
|
677 } 678 ips.ips_next = isn->is_next; 679 bcopy((char *)isn, (char *)&ips.ips_is, sizeof(ips.ips_is)); 680 ips.ips_rule = isn->is_rule; 681 if (isn->is_rule != NULL) 682 bcopy((char *)isn->is_rule, (char *)&ips.ips_fr, 683 sizeof(ips.ips_fr)); | 681 } 682 ips.ips_next = isn->is_next; 683 bcopy((char *)isn, (char *)&ips.ips_is, sizeof(ips.ips_is)); 684 ips.ips_rule = isn->is_rule; 685 if (isn->is_rule != NULL) 686 bcopy((char *)isn->is_rule, (char *)&ips.ips_fr, 687 sizeof(ips.ips_fr)); |
688 RWLOCK_EXIT(&ipf_state); |
|
684 error = fr_outobj(data, &ips, IPFOBJ_STATESAVE); 685 return error; 686} 687 688 689/* ------------------------------------------------------------------------ */ 690/* Function: fr_stputent */ 691/* Returns: int - 0 == success, != 0 == failure */ --- 3508 unchanged lines hidden --- | 689 error = fr_outobj(data, &ips, IPFOBJ_STATESAVE); 690 return error; 691} 692 693 694/* ------------------------------------------------------------------------ */ 695/* Function: fr_stputent */ 696/* Returns: int - 0 == success, != 0 == failure */ --- 3508 unchanged lines hidden --- |