diff mbox series

core: do install artifact if final or temp locations are empty

Message ID 20170928160705.23825-1-christian.storm@siemens.com
State Accepted
Headers show
Series core: do install artifact if final or temp locations are empty | expand

Commit Message

Storm, Christian Sept. 28, 2017, 4:07 p.m. UTC
Commit d7b7da4 "core: don't unlink if final equals temp location"
prevents artifact deletion if the temporary location of the artifact
happens to be identical to the final location.

However, img->path and img->extract_file are not always non-empty,
e.g., for an artifact of type "bootloader" installed from a local
source installed via swupdate -i:

software =
{
    version = "0.0.1";
    images: (
        {
            filename = "bootloader.cfg";
            type = "bootloader";

        });
}

Hence, add a check for this condition.

Signed-off-by: Christian Storm <christian.storm@siemens.com>
---
 corelib/installer.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Stefano Babic Sept. 29, 2017, 10:37 a.m. UTC | #1
On 28/09/2017 18:07, Christian Storm wrote:
> Commit d7b7da4 "core: don't unlink if final equals temp location"
> prevents artifact deletion if the temporary location of the artifact
> happens to be identical to the final location.
> 
> However, img->path and img->extract_file are not always non-empty,
> e.g., for an artifact of type "bootloader" installed from a local
> source installed via swupdate -i:
> 
> software =
> {
>     version = "0.0.1";
>     images: (
>         {
>             filename = "bootloader.cfg";
>             type = "bootloader";
> 
>         });
> }
> 
> Hence, add a check for this condition.
> 
> Signed-off-by: Christian Storm <christian.storm@siemens.com>
> ---
>  corelib/installer.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/corelib/installer.c b/corelib/installer.c
> index 6c6271c..a097dfd 100644
> --- a/corelib/installer.c
> +++ b/corelib/installer.c
> @@ -326,7 +326,9 @@ int install_images(struct swupdate_cfg *sw, int fdsw, int fromfile)
>  				continue;
>  		}
>  
> -		if (strncmp(img->path, img->extract_file, sizeof(img->path)) == 0) {
> +		if ((strlen(img->path) > 0) &&
> +			(strlen(img->extract_file) > 0) &&
> +			(strncmp(img->path, img->extract_file, sizeof(img->path)) == 0)){
>  			struct img_type *tmpimg;
>  			WARN("Temporary and final location for %s is identical, skip "
>  			     "processing.", img->path);
> 

Acked-by: Stefano Babic <sbabic@denx.de>

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/corelib/installer.c b/corelib/installer.c
index 6c6271c..a097dfd 100644
--- a/corelib/installer.c
+++ b/corelib/installer.c
@@ -326,7 +326,9 @@  int install_images(struct swupdate_cfg *sw, int fdsw, int fromfile)
 				continue;
 		}
 
-		if (strncmp(img->path, img->extract_file, sizeof(img->path)) == 0) {
+		if ((strlen(img->path) > 0) &&
+			(strlen(img->extract_file) > 0) &&
+			(strncmp(img->path, img->extract_file, sizeof(img->path)) == 0)){
 			struct img_type *tmpimg;
 			WARN("Temporary and final location for %s is identical, skip "
 			     "processing.", img->path);