From: Luo Xionghu xionghu.luo@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@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] = ""; + 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);