public inbox for linux-integrity@vger.kernel.org
 help / color / mirror / Atom feed
From: Lakshmi Ramasubramanian <nramas@linux.microsoft.com>
To: zohar@linux.ibm.com, pvorel@suse.cz
Cc: linux-integrity@vger.kernel.org
Subject: Re: [ima-evm-utils][PATCH] file2bin: Pass the right values to size and count parameters for fread()
Date: Mon, 19 Oct 2020 13:08:50 -0700	[thread overview]
Message-ID: <f5a142d8-0d98-7697-6ed8-f713d09715da@linux.microsoft.com> (raw)
In-Reply-To: <20201019200526.12678-1-nramas@linux.microsoft.com>

On 10/19/20 1:05 PM, Lakshmi Ramasubramanian wrote:
> The 2nd parameter to fread() namely "size" specifies the size, in
> bytes of each element to be read, and the 3rd parameter namely "count"
> specifies the number of elements, each one with a size of "size" bytes.
> 
>   size_t fread ( void * ptr, size_t size, size_t count, FILE * stream );
> 
> But in the function file2bin() the values passed to "size" and "count"
> are reversed causing the function to return an error eventhough the file
> was sucdessfully read.
> 
> Pass the right values to "size" and "count" parameters for fread() in
> the function file2bin().
> 
> Signed-off-by: Lakshmi Ramasubramanian <nramas@linux.microsoft.com>
> ---
>   src/evmctl.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/evmctl.c b/src/evmctl.c
> index 7ad1150..d49988e 100644
> --- a/src/evmctl.c
> +++ b/src/evmctl.c
> @@ -221,7 +221,8 @@ static unsigned char *file2bin(const char *file, const char *ext, int *size)
>   		fclose(fp);
>   		return NULL;
>   	}
> -	if (fread(data, len, 1, fp) != len) {
> +
> +	if (fread(data, 1, len, fp) != len) {
>   		log_err("Failed to fread %zu bytes: %s\n", len, name);
>   		fclose(fp);
>   		free(data);
> 

The above patch is for ima-evm-utils. Missed adding "[ima-evm-utils]" in 
the subject.

thanks,
  -lakshmi


  reply	other threads:[~2020-10-19 20:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-19 20:05 [PATCH] file2bin: Pass the right values to size and count parameters for fread() Lakshmi Ramasubramanian
2020-10-19 20:08 ` Lakshmi Ramasubramanian [this message]
2020-10-19 20:23 ` Petr Vorel
2020-10-19 22:12 ` Mimi Zohar
2020-10-19 22:22   ` Lakshmi Ramasubramanian
2020-10-19 22:30     ` Mimi Zohar
2020-10-19 22:59       ` Lakshmi Ramasubramanian
2020-10-20  6:53     ` Petr Vorel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f5a142d8-0d98-7697-6ed8-f713d09715da@linux.microsoft.com \
    --to=nramas@linux.microsoft.com \
    --cc=linux-integrity@vger.kernel.org \
    --cc=pvorel@suse.cz \
    --cc=zohar@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox