[Sound-open-firmware] [PATCH v2 3/3] rimge: initial the char array.
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.
--- v2: if path is modified in the function, strcmp returns not 0.
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..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);
There is a typo in the patch name. rimge == > rimage.
-----Original Message----- From: sound-open-firmware-bounces@alsa-project.org [mailto:sound-open- firmware-bounces@alsa-project.org] On Behalf Of xionghu.luo@linux.intel.com Sent: Friday, January 26, 2018 16:36 To: sound-open-firmware@alsa-project.org Cc: Luo, Xionghu xionghu.luo@intel.com; xionghu.luo@linux.intel.com Subject: [Sound-open-firmware] [PATCH v2 3/3] rimge: initial the char array.
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.
v2: if path is modified in the function, strcmp returns not 0.
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..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, ""))
return -errno; } PEM_read_PrivateKey(fp, &privkey, NULL, NULL);image->key_name = NULL;
-- 2.11.0
Sound-open-firmware mailing list Sound-open-firmware@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/sound-open-firmware
participants (2)
-
Pan, Xiuli
-
xionghu.luoï¼ linux.intel.com