| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * NetLabel Kernel API |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 6 | 7 | * as CIPSO and RIPSO. |
|---|
| 7 | 8 | * |
|---|
| 8 | 9 | * Author: Paul Moore <paul@paul-moore.com> |
|---|
| 9 | | - * |
|---|
| 10 | 10 | */ |
|---|
| 11 | 11 | |
|---|
| 12 | 12 | /* |
|---|
| 13 | 13 | * (c) Copyright Hewlett-Packard Development Company, L.P., 2006, 2008 |
|---|
| 14 | | - * |
|---|
| 15 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 16 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 17 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 18 | | - * (at your option) any later version. |
|---|
| 19 | | - * |
|---|
| 20 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 21 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 22 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See |
|---|
| 23 | | - * the GNU General Public License for more details. |
|---|
| 24 | | - * |
|---|
| 25 | | - * You should have received a copy of the GNU General Public License |
|---|
| 26 | | - * along with this program; if not, see <http://www.gnu.org/licenses/>. |
|---|
| 27 | | - * |
|---|
| 28 | 14 | */ |
|---|
| 29 | 15 | |
|---|
| 30 | 16 | #include <linux/init.h> |
|---|
| .. | .. |
|---|
| 621 | 607 | */ |
|---|
| 622 | 608 | int netlbl_catmap_walk(struct netlbl_lsm_catmap *catmap, u32 offset) |
|---|
| 623 | 609 | { |
|---|
| 624 | | - struct netlbl_lsm_catmap *iter = catmap; |
|---|
| 610 | + struct netlbl_lsm_catmap *iter; |
|---|
| 625 | 611 | u32 idx; |
|---|
| 626 | 612 | u32 bit; |
|---|
| 627 | 613 | NETLBL_CATMAP_MAPTYPE bitmap; |
|---|
| .. | .. |
|---|
| 871 | 857 | |
|---|
| 872 | 858 | offset -= iter->startbit; |
|---|
| 873 | 859 | idx = offset / NETLBL_CATMAP_MAPSIZE; |
|---|
| 874 | | - iter->bitmap[idx] |= bitmap << (offset % NETLBL_CATMAP_MAPSIZE); |
|---|
| 860 | + iter->bitmap[idx] |= (NETLBL_CATMAP_MAPTYPE)bitmap |
|---|
| 861 | + << (offset % NETLBL_CATMAP_MAPSIZE); |
|---|
| 875 | 862 | |
|---|
| 876 | 863 | return 0; |
|---|
| 877 | 864 | } |
|---|
| .. | .. |
|---|
| 899 | 886 | unsigned char bitmask; |
|---|
| 900 | 887 | unsigned char byte; |
|---|
| 901 | 888 | |
|---|
| 889 | + if (offset >= bitmap_len) |
|---|
| 890 | + return -1; |
|---|
| 902 | 891 | byte_offset = offset / 8; |
|---|
| 903 | 892 | byte = bitmap[byte_offset]; |
|---|
| 904 | 893 | bit_spot = offset; |
|---|