[Sound-open-firmware] fix rimage coding grammer issues.
From: Luo Xionghu xionghu.luo@intel.com
this patchset fixes the missing logic checks in rimage.
TODO: is tested on hardware needed? Luo Xionghu (3): rimage: don't add date to css if date is NULL. rimage: add return for non-void function. rimge: initial the char array.
rimage/css.c | 3 +++ rimage/pkcs1_5.c | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-)
From: Luo Xionghu xionghu.luo@intel.com
Avoid NULL dereference if function localtime return invalid value.
Signed-off-by: Luo Xionghu xionghu.luo@intel.com --- rimage/css.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/rimage/css.c b/rimage/css.c index f662f0b..064a75a 100644 --- a/rimage/css.c +++ b/rimage/css.c @@ -33,6 +33,9 @@ void ri_css_hdr_create(struct image *image) /* get local time and date */ gettimeofday(&tv, NULL); date = localtime(&tv.tv_sec); + if (date == NULL) + return; + date->tm_year += 1900; fprintf(stdout, " css: set build date to %d:%2.2d:%2.2d\n", date->tm_year, date->tm_mon, date->tm_mday);
On Fri, 2018-01-26 at 16:29 +0800, xionghu.luo@linux.intel.com wrote:
From: Luo Xionghu xionghu.luo@intel.com
Avoid NULL dereference if function localtime return invalid value.
Signed-off-by: Luo Xionghu xionghu.luo@intel.com
rimage/css.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/rimage/css.c b/rimage/css.c index f662f0b..064a75a 100644 --- a/rimage/css.c +++ b/rimage/css.c @@ -33,6 +33,9 @@ void ri_css_hdr_create(struct image *image) /* get local time and date */ gettimeofday(&tv, NULL); date = localtime(&tv.tv_sec);
- if (date == NULL)
Can we print an error here.
return;
- date->tm_year += 1900; fprintf(stdout, " css: set build date to %d:%2.2d:%2.2d\n", date->tm_year, date->tm_mon, date->tm_mday);
From: Luo Xionghu xionghu.luo@intel.com
Signed-off-by: Luo Xionghu xionghu.luo@intel.com --- rimage/pkcs1_5.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/rimage/pkcs1_5.c b/rimage/pkcs1_5.c index 7783ac4..0c5806b 100644 --- a/rimage/pkcs1_5.c +++ b/rimage/pkcs1_5.c @@ -137,4 +137,5 @@ int ri_manifest_sign(struct image *image) MAN_RSA_SIGNATURE_LEN), (void *)man + MAN_SIG_PKG_OFFSET, (man->css.size - man->css.header_len) * sizeof(uint32_t)); + return 0; }
On Fri, 2018-01-26 at 16:29 +0800, xionghu.luo@linux.intel.com wrote:
From: Luo Xionghu xionghu.luo@intel.com
Signed-off-by: Luo Xionghu xionghu.luo@intel.com
rimage/pkcs1_5.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/rimage/pkcs1_5.c b/rimage/pkcs1_5.c index 7783ac4..0c5806b 100644 --- a/rimage/pkcs1_5.c +++ b/rimage/pkcs1_5.c @@ -137,4 +137,5 @@ int ri_manifest_sign(struct image *image) MAN_RSA_SIGNATURE_LEN), (void *)man + MAN_SIG_PKG_OFFSET, (man->css.size - man->css.header_len) * sizeof(uint32_t));
- return 0;
}
applied.
Thanks
Liam
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);
On Fri, 2018-01-26 at 16:29 +0800, xionghu.luo@linux.intel.com wrote:
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] = "";
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, ""))
return -errno; } PEM_read_PrivateKey(fp, &privkey, NULL, NULL);image->key_name = 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.
Xionghu,
Yes, you are expected to follow our development rule and add statement "Tested on xxx platform + xxx codec, SOF repo:commit id, SOF Tool repo: commit id, https://github.com/plbossart/sound/tree/topic/sof-v4.14:commit id" into your patch submission, with "---".
Thanks, Jocelyn
-----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 4:30 PM To: sound-open-firmware@alsa-project.org Cc: Luo, Xionghu xionghu.luo@intel.com; xionghu.luo@linux.intel.com Subject: [Sound-open-firmware] fix rimage coding grammer issues.
From: Luo Xionghu xionghu.luo@intel.com
this patchset fixes the missing logic checks in rimage.
TODO: is tested on hardware needed? Luo Xionghu (3): rimage: don't add date to css if date is NULL. rimage: add return for non-void function. rimge: initial the char array.
rimage/css.c | 3 +++ rimage/pkcs1_5.c | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-)
participants (4)
-
Li, Jocelyn
-
Liam Girdwood
-
Liam Girdwood
-
xionghu.luo@linux.intel.com