apparmor: fix unsigned len comparison with less than zero
The sanity check in macro update_for_len checks to see if len
is less than zero, however, len is a size_t so it can never be
less than zero, so this sanity check is a no-op. Fix this by
making len a ssize_t so the comparison will work and add ulen
that is a size_t copy of len so that the min() macro won't
throw warnings about comparing different types.
Addresses-Coverity: ("Macro compares unsigned to 0")
Fixes: f1bd904175
("apparmor: add the base fns() for domain labels")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
parent
136db99485
commit
00e0590dba
|
@ -1462,11 +1462,13 @@ static inline bool use_label_hname(struct aa_ns *ns, struct aa_label *label,
|
||||||
/* helper macro for snprint routines */
|
/* helper macro for snprint routines */
|
||||||
#define update_for_len(total, len, size, str) \
|
#define update_for_len(total, len, size, str) \
|
||||||
do { \
|
do { \
|
||||||
|
size_t ulen = len; \
|
||||||
|
\
|
||||||
AA_BUG(len < 0); \
|
AA_BUG(len < 0); \
|
||||||
total += len; \
|
total += ulen; \
|
||||||
len = min(len, size); \
|
ulen = min(ulen, size); \
|
||||||
size -= len; \
|
size -= ulen; \
|
||||||
str += len; \
|
str += ulen; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1601,7 +1603,7 @@ int aa_label_snxprint(char *str, size_t size, struct aa_ns *ns,
|
||||||
struct aa_ns *prev_ns = NULL;
|
struct aa_ns *prev_ns = NULL;
|
||||||
struct label_it i;
|
struct label_it i;
|
||||||
int count = 0, total = 0;
|
int count = 0, total = 0;
|
||||||
size_t len;
|
ssize_t len;
|
||||||
|
|
||||||
AA_BUG(!str && size != 0);
|
AA_BUG(!str && size != 0);
|
||||||
AA_BUG(!label);
|
AA_BUG(!label);
|
||||||
|
|
Loading…
Reference in New Issue