diff options
author | Paul Moore <paul.moore@hp.com> | 2006-10-11 19:10:47 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-10-16 02:14:14 -0400 |
commit | 044a68ed8a692f643cf3c0a54c380a922584f34f (patch) | |
tree | 98c195561377cf01e1411feb0ec859e83cba3ac4 | |
parent | 1a620698c29b5e18150ec04ace0609fb07d08d3e (diff) |
NetLabel: only deref the CIPSOv4 standard map fields when using standard mapping
Fix several places in the CIPSO code where it was dereferencing fields which
did not have valid pointers by moving those pointer dereferences into code
blocks where the pointers are valid.
Signed-off-by: Paul Moore <paul.moore@hp.com>
Signed-off-by: James Morris <jmorris@namei.org>
-rw-r--r-- | net/ipv4/cipso_ipv4.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c index bde8ccaa1531..d19c9ac7727e 100644 --- a/net/ipv4/cipso_ipv4.c +++ b/net/ipv4/cipso_ipv4.c | |||
@@ -773,13 +773,15 @@ static int cipso_v4_map_cat_rbm_valid(const struct cipso_v4_doi *doi_def, | |||
773 | { | 773 | { |
774 | int cat = -1; | 774 | int cat = -1; |
775 | u32 bitmap_len_bits = bitmap_len * 8; | 775 | u32 bitmap_len_bits = bitmap_len * 8; |
776 | u32 cipso_cat_size = doi_def->map.std->cat.cipso_size; | 776 | u32 cipso_cat_size; |
777 | u32 *cipso_array = doi_def->map.std->cat.cipso; | 777 | u32 *cipso_array; |
778 | 778 | ||
779 | switch (doi_def->type) { | 779 | switch (doi_def->type) { |
780 | case CIPSO_V4_MAP_PASS: | 780 | case CIPSO_V4_MAP_PASS: |
781 | return 0; | 781 | return 0; |
782 | case CIPSO_V4_MAP_STD: | 782 | case CIPSO_V4_MAP_STD: |
783 | cipso_cat_size = doi_def->map.std->cat.cipso_size; | ||
784 | cipso_array = doi_def->map.std->cat.cipso; | ||
783 | for (;;) { | 785 | for (;;) { |
784 | cat = cipso_v4_bitmap_walk(bitmap, | 786 | cat = cipso_v4_bitmap_walk(bitmap, |
785 | bitmap_len_bits, | 787 | bitmap_len_bits, |
@@ -825,8 +827,8 @@ static int cipso_v4_map_cat_rbm_hton(const struct cipso_v4_doi *doi_def, | |||
825 | u32 net_spot_max = 0; | 827 | u32 net_spot_max = 0; |
826 | u32 host_clen_bits = host_cat_len * 8; | 828 | u32 host_clen_bits = host_cat_len * 8; |
827 | u32 net_clen_bits = net_cat_len * 8; | 829 | u32 net_clen_bits = net_cat_len * 8; |
828 | u32 host_cat_size = doi_def->map.std->cat.local_size; | 830 | u32 host_cat_size; |
829 | u32 *host_cat_array = doi_def->map.std->cat.local; | 831 | u32 *host_cat_array; |
830 | 832 | ||
831 | switch (doi_def->type) { | 833 | switch (doi_def->type) { |
832 | case CIPSO_V4_MAP_PASS: | 834 | case CIPSO_V4_MAP_PASS: |
@@ -838,6 +840,8 @@ static int cipso_v4_map_cat_rbm_hton(const struct cipso_v4_doi *doi_def, | |||
838 | memcpy(net_cat, host_cat, net_spot_max); | 840 | memcpy(net_cat, host_cat, net_spot_max); |
839 | return net_spot_max; | 841 | return net_spot_max; |
840 | case CIPSO_V4_MAP_STD: | 842 | case CIPSO_V4_MAP_STD: |
843 | host_cat_size = doi_def->map.std->cat.local_size; | ||
844 | host_cat_array = doi_def->map.std->cat.local; | ||
841 | for (;;) { | 845 | for (;;) { |
842 | host_spot = cipso_v4_bitmap_walk(host_cat, | 846 | host_spot = cipso_v4_bitmap_walk(host_cat, |
843 | host_clen_bits, | 847 | host_clen_bits, |
@@ -893,8 +897,8 @@ static int cipso_v4_map_cat_rbm_ntoh(const struct cipso_v4_doi *doi_def, | |||
893 | int net_spot = -1; | 897 | int net_spot = -1; |
894 | u32 net_clen_bits = net_cat_len * 8; | 898 | u32 net_clen_bits = net_cat_len * 8; |
895 | u32 host_clen_bits = host_cat_len * 8; | 899 | u32 host_clen_bits = host_cat_len * 8; |
896 | u32 net_cat_size = doi_def->map.std->cat.cipso_size; | 900 | u32 net_cat_size; |
897 | u32 *net_cat_array = doi_def->map.std->cat.cipso; | 901 | u32 *net_cat_array; |
898 | 902 | ||
899 | switch (doi_def->type) { | 903 | switch (doi_def->type) { |
900 | case CIPSO_V4_MAP_PASS: | 904 | case CIPSO_V4_MAP_PASS: |
@@ -903,6 +907,8 @@ static int cipso_v4_map_cat_rbm_ntoh(const struct cipso_v4_doi *doi_def, | |||
903 | memcpy(host_cat, net_cat, net_cat_len); | 907 | memcpy(host_cat, net_cat, net_cat_len); |
904 | return net_cat_len; | 908 | return net_cat_len; |
905 | case CIPSO_V4_MAP_STD: | 909 | case CIPSO_V4_MAP_STD: |
910 | net_cat_size = doi_def->map.std->cat.cipso_size; | ||
911 | net_cat_array = doi_def->map.std->cat.cipso; | ||
906 | for (;;) { | 912 | for (;;) { |
907 | net_spot = cipso_v4_bitmap_walk(net_cat, | 913 | net_spot = cipso_v4_bitmap_walk(net_cat, |
908 | net_clen_bits, | 914 | net_clen_bits, |