Révision da79409f
Ajouté par Ermal il y a presque 10 ans
pfPorts/php55-pfSense-module/files/pfSense.c | ||
---|---|---|
743 | 743 |
socklen_t size; |
744 | 744 |
long mask = 0, table = 0, pipe = 0, zone = 0; |
745 | 745 |
char *ip, *mac = NULL, *p; |
746 |
int ip_len, mac_len = 0; |
|
746 |
int ip_len, addrlen, mac_len = 0;
|
|
747 | 747 |
long action = IP_FW_TABLE_XADD; |
748 | 748 |
int err; |
749 | 749 |
|
... | ... | |
770 | 770 |
efree(op3); |
771 | 771 |
RETURN_FALSE; |
772 | 772 |
} |
773 |
addrlen = sizeof(struct in6_addr); |
|
773 | 774 |
} else if (!inet_pton(AF_INET, ip, &xent->k.addr6)) { |
774 | 775 |
efree(op3); |
775 | 776 |
RETURN_FALSE; |
776 | 777 |
} |
777 | 778 |
|
778 |
if (!strchr(ip, ':')) |
|
779 |
if (!strchr(ip, ':')) {
|
|
779 | 780 |
xent->flags = IPFW_TCF_INET; |
781 |
addrlen = sizeof(uint32_t); |
|
782 |
} |
|
780 | 783 |
|
781 | 784 |
if (mask) |
782 | 785 |
xent->masklen = (u_int8_t)mask; |
... | ... | |
796 | 799 |
} |
797 | 800 |
|
798 | 801 |
xent->type = IPFW_TABLE_CIDR; |
802 |
xent->len = offsetof(ipfw_table_xentry, k) + addrlen; |
|
799 | 803 |
err = setsockopt(PFSENSE_G(ipfw), IPPROTO_IP, IP_FW3, op3, size); |
800 | 804 |
if (err < 0 && err != EEXIST) { |
801 | 805 |
efree(op3); |
... | ... | |
864 | 868 |
socklen_t size; |
865 | 869 |
long mask = 0, table = 0, zone = 0; |
866 | 870 |
char *ip, *mac = NULL, *p; |
867 |
int ip_len, mac_len = 0; |
|
871 |
int ip_len, addrlen, mac_len = 0;
|
|
868 | 872 |
long action = IP_FW_TABLE_XADD; |
869 | 873 |
int err; |
870 | 874 |
|
... | ... | |
875 | 879 |
if (action != IP_FW_TABLE_XLISTENTRY) |
876 | 880 |
RETURN_FALSE; |
877 | 881 |
|
878 |
if ((op3 = emalloc(sizeof(*op3) + sizeof(*xent))) == NULL) |
|
882 |
size = sizeof(*op3) + sizeof(*xent); |
|
883 |
|
|
884 |
if ((op3 = (ip_fw3_opheader *)emalloc(size)) == NULL) |
|
879 | 885 |
RETURN_FALSE; |
880 | 886 |
|
881 |
memset(op3, 0, sizeof(*op3));
|
|
887 |
memset(op3, 0, size); |
|
882 | 888 |
op3->ctxid = (uint16_t)zone; |
883 | 889 |
op3->opcode = IP_FW_TABLE_XLISTENTRY; |
884 | 890 |
xent = (ipfw_table_xentry *)(op3 + 1); |
885 |
memset(xent, 0, sizeof(*xent)); |
|
886 | 891 |
xent->tbl = (u_int16_t)table; |
887 | 892 |
|
888 | 893 |
if (strchr(ip, ':')) { |
... | ... | |
890 | 895 |
efree(op3); |
891 | 896 |
RETURN_FALSE; |
892 | 897 |
} |
898 |
addrlen = sizeof(struct in6_addr); |
|
893 | 899 |
} else if (!inet_pton(AF_INET, ip, &xent->k.addr6)) { |
894 | 900 |
efree(op3); |
895 | 901 |
RETURN_FALSE; |
896 | 902 |
} |
897 | 903 |
|
898 |
if (!strchr(ip, ':')) |
|
904 |
if (!strchr(ip, ':')) {
|
|
899 | 905 |
xent->flags = IPFW_TCF_INET; |
906 |
addrlen = sizeof(uint32_t); |
|
907 |
} |
|
900 | 908 |
|
901 | 909 |
if (mask) |
902 | 910 |
xent->masklen = (u_int8_t)mask; |
... | ... | |
910 | 918 |
} |
911 | 919 |
|
912 | 920 |
xent->type = IPFW_TABLE_CIDR; |
913 |
size = sizeof(*op3) + sizeof(*xent);
|
|
921 |
xent->len = offsetof(ipfw_table_xentry, k) + addrlen;
|
|
914 | 922 |
if (getsockopt(PFSENSE_G(ipfw), IPPROTO_IP, IP_FW3, op3, &size) < 0) { |
915 | 923 |
efree(op3); |
916 | 924 |
RETURN_FALSE; |
Formats disponibles : Unified diff
Actually provide the size of the requiest to the kernel so it can process properly the request