[apparmor] [PATCH 2/2] libapparmor: Be consistent with the type used for buffer sizes
Tyler Hicks
tyhicks at canonical.com
Fri Sep 30 00:32:31 UTC 2016
The features_struct.size variable is used to hold a buffer size and it
is also passed in as the size parameter to read(). It should be a size_t
instead of an int.
This patch also changes the size parameter of load_features_dir() to a
size_t to match the same parameter of load_features_file() as well as
the features_struct.size change described above.
Signed-off-by: Tyler Hicks <tyhicks at canonical.com>
---
libraries/libapparmor/src/features.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/libraries/libapparmor/src/features.c b/libraries/libapparmor/src/features.c
index 088c4ea..dd38627 100644
--- a/libraries/libapparmor/src/features.c
+++ b/libraries/libapparmor/src/features.c
@@ -42,7 +42,7 @@ struct aa_features {
struct features_struct {
char *buffer;
- int size;
+ size_t size;
char *pos;
};
@@ -54,7 +54,8 @@ struct component {
static int features_snprintf(struct features_struct *fst, const char *fmt, ...)
{
va_list args;
- int i, remaining = fst->size - (fst->pos - fst->buffer);
+ int i;
+ size_t remaining = fst->size - (fst->pos - fst->buffer);
if (remaining < 0) {
errno = EINVAL;
@@ -157,7 +158,7 @@ static int features_dir_cb(int dirfd, const char *name, struct stat *st,
if (S_ISREG(st->st_mode)) {
ssize_t len;
- int remaining = fst->size - (fst->pos - fst->buffer);
+ size_t remaining = fst->size - (fst->pos - fst->buffer);
len = load_features_file(dirfd, name, fst->pos, remaining);
if (len < 0)
@@ -176,7 +177,7 @@ static int features_dir_cb(int dirfd, const char *name, struct stat *st,
}
static ssize_t load_features_dir(int dirfd, const char *path,
- char *buffer, int size)
+ char *buffer, size_t size)
{
struct features_struct fst = { buffer, size, buffer };
--
2.9.3
More information about the AppArmor
mailing list