From 56cfafc28c7a16dbd4930ceeaaf6d5d256a40596 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Thu, 8 May 2014 12:13:18 +0100 Subject: [PATCH] parser: fix binary load of multiple profiles in a single file --- parser/parser_interface.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) Index: apparmor/parser/parser_interface.c =================================================================== --- apparmor.orig/parser/parser_interface.c 2014-05-08 12:29:39.084722913 +0100 +++ apparmor/parser/parser_interface.c 2014-05-08 12:29:39.080722909 +0100 @@ -637,9 +637,8 @@ int sd_load_buffer(int option, char *buffer, int size) { int fd = -1; - int error = -ENOMEM, wsize, bsize; + int error = -ENOMEM, wsize; char *filename = NULL; - char *b; switch (option) { case OPTION_ADD: @@ -666,16 +665,13 @@ } error = 0; - for (b = buffer; b ; b = next_profile_buffer(b + sizeof(header_version), bsize)) { - bsize = size - (b - buffer); - if (kernel_load) { - wsize = write(fd, b, bsize); - if (wsize < 0) { - error = -errno; - } else if (wsize < bsize) { - PERROR(_("%s: Unable to write entire profile entry\n"), - progname); - } + if (kernel_load) { + wsize = write(fd, buffer, size); + if (wsize < 0) { + error = -errno; + } else if (wsize < size) { + PERROR(_("%s: Unable to write entire profile entry\n"), + progname); } } if (kernel_load) close(fd);