[Sound-open-firmware] [PATCH v2 3/3] rimge: initial the char array.
xionghu.luo at linux.intel.com
xionghu.luo at linux.intel.com
Fri Jan 26 09:36:04 CET 2018
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.
---
v2: if path is modified in the function, strcmp returns not 0.
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..feffb7b 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);
--
2.11.0
More information about the Sound-open-firmware
mailing list