[Sound-open-firmware] [[RFC PATCH] 3/3] rimge: initial the char array.

Liam Girdwood liam.r.girdwood at intel.com
Sat Jan 27 17:59:53 CET 2018


On Fri, 2018-01-26 at 16:29 +0800, xionghu.luo at linux.intel.com wrote:
> From: Luo Xionghu <xionghu.luo at intel.com>
> 
> the variable maybe used uninitalied, initialize it to empty.
> If the image->key_name is NULL, restore it to NULL before return.
> 
> Signed-off-by: Luo Xionghu <xionghu.luo at intel.com>
> ---
>  rimage/pkcs1_5.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/rimage/pkcs1_5.c b/rimage/pkcs1_5.c
> index 0c5806b..3e1c454 100644
> --- a/rimage/pkcs1_5.c
> +++ b/rimage/pkcs1_5.c
> @@ -56,7 +56,9 @@ int pkcs_sign(struct image *image, struct
> fw_image_manifest *man,
>  	RSA *priv_rsa = NULL;
>  	EVP_PKEY *privkey;
>  	FILE *fp;
> -	unsigned char digest[SHA256_DIGEST_LENGTH], path[256],
> mod[MAN_RSA_KEY_MODULUS_LEN];
> +	unsigned char path[256] = "";

Btw, we should probably have a macro for file name sizes and path
lengths too.

> +	unsigned char digest[SHA256_DIGEST_LENGTH];
> +	unsigned char mod[MAN_RSA_KEY_MODULUS_LEN];
>  	unsigned int siglen = MAN_RSA_SIGNATURE_LEN;
>  	int ret = -EINVAL, i;
>  
> @@ -80,6 +82,8 @@ int pkcs_sign(struct image *image, struct
> fw_image_manifest *man,
>  	fp = fopen(image->key_name, "r");
>  	if (fp == NULL) {
>  		fprintf(stderr, "error: can't open file %s %d\n",
> path, -errno);
> +		if (!strcmp(path, ""))
> +			image->key_name = NULL;
>  		return -errno;
>  	}
>  	PEM_read_PrivateKey(fp, &privkey, NULL, NULL);
---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.


More information about the Sound-open-firmware mailing list