From f1c8ff1386625f9f7cfcbe386508ff7a6df868f4 Mon Sep 17 00:00:00 2001 From: SangYoun Kwak Date: Tue, 22 Mar 2022 11:40:21 +0900 Subject: Fix string length check and log printing Change-Id: I91a259ef431a8378a177dc2ca9b1114bb5b9cfd9 Signed-off-by: SangYoun Kwak --- ss_engine/SS_FSUpdate.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ss_engine/SS_FSUpdate.c b/ss_engine/SS_FSUpdate.c index 8cc8250..1126859 100755 --- a/ss_engine/SS_FSUpdate.c +++ b/ss_engine/SS_FSUpdate.c @@ -134,12 +134,12 @@ long SS_recursive_folder_creater(const char *path, const mode_t mode) { int mkd_res = mkdir(temppath, mode); if(mkd_res != 0 && errno != EEXIST) { - LOGL(LOG_SSENGINE,"cannot create dir %s\n system error: %d error: %s\n", temppath, errno, strerror(errno)); + LOGL(LOG_SSENGINE,"cannot create dir %s\n system error: %d error: %m\n", temppath, errno); return -E_SS_CANNOT_CREATE_DIRECTORY; } - if(path_token_len < (MAX_PATH-1)) { - strcat(temppath, "/"); + if(temppath_current_len < (MAX_PATH-1)) { + strncat(temppath, "/", 2); } } return 0; -- cgit v1.2.3 From b25d02d618797b5fb2fbe61a188d6a28dc720bf8 Mon Sep 17 00:00:00 2001 From: SangYoun Kwak Date: Tue, 22 Mar 2022 13:58:06 +0900 Subject: Fix buffer copy and concat size Change-Id: Ia13008324e4f1dececb89efa332378faf33850be Signed-off-by: SangYoun Kwak --- ss_engine/SS_FSUpdate.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ss_engine/SS_FSUpdate.c b/ss_engine/SS_FSUpdate.c index 1126859..8f382fd 100755 --- a/ss_engine/SS_FSUpdate.c +++ b/ss_engine/SS_FSUpdate.c @@ -114,7 +114,7 @@ long SS_recursive_folder_creater(const char *path, const mode_t mode) { char input_path[MAX_PATH] = {'\0'}; char temppath[MAX_PATH] = {'\0'}; - strncpy(input_path, path, MAX_PATH); + strncpy(input_path, path, MAX_PATH - 1); if (input_path[0] == '/') { temppath[0] = '/'; @@ -138,8 +138,8 @@ long SS_recursive_folder_creater(const char *path, const mode_t mode) { return -E_SS_CANNOT_CREATE_DIRECTORY; } - if(temppath_current_len < (MAX_PATH-1)) { - strncat(temppath, "/", 2); + if(temppath_current_len < (MAX_PATH - 1)) { + strncat(temppath, "/", 1); } } return 0; -- cgit v1.2.3 From c8cd987776603aa66e52823830eba423619f2544 Mon Sep 17 00:00:00 2001 From: Mateusz Moscicki Date: Thu, 9 Jun 2022 17:31:17 +0200 Subject: Rename update types and remove LZMA DELTA support Change-Id: Icf0c5c6c93c6328f303daacaeec49f7c8a5f40af --- ss_engine/SS_PatchDelta.c | 10 +--------- ss_engine/SS_UPI.c | 11 ++++------- ss_engine/ua_types.h | 11 ++++++++--- 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/ss_engine/SS_PatchDelta.c b/ss_engine/SS_PatchDelta.c index 9f2d94c..dd292ee 100755 --- a/ss_engine/SS_PatchDelta.c +++ b/ss_engine/SS_PatchDelta.c @@ -940,15 +940,7 @@ int SS_UpdateDeltaIMG(ua_dataSS_t * ua_dataSS, int (*write_to_blkdev) (char *, i } //Considering EMMC partition by default - if (ua_dataSS->update_cfg->update_type == DELTA_IMG) { - blk_cnt = ((ua_dataSS->update_cfg->target_img_size - 1) / SECTOR_SIZE) + 1; - result = write_to_blkdev((char *)ua_dataSS->parti_info->ua_blk_name, blk_start, blk_cnt, (char *)msi.buffer); - if (result != S_SS_SUCCESS) { - LOGE("write of patched data to %s failed\n", ua_dataSS->parti_info->ua_blk_name); // All returns should go to CLEAN UP. - SS_SetUpgradeState(E_SS_IMGFLASHWRITEFAIL); - goto Cleanup; - } - } else if (ua_dataSS->update_cfg->update_type == EXTRA && ua_dataSS->update_data->ua_temp_path) { + if (ua_dataSS->update_cfg->update_type == EXTRA && ua_dataSS->update_data->ua_temp_path) { fd = open(ua_dataSS->update_data->ua_temp_path, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU); if (fd < 0) { strerror_r(errno, buf, sizeof(buf)); diff --git a/ss_engine/SS_UPI.c b/ss_engine/SS_UPI.c index 4c6b19c..a7a4cac 100755 --- a/ss_engine/SS_UPI.c +++ b/ss_engine/SS_UPI.c @@ -2228,7 +2228,7 @@ int SS_IMGVerfiyPartition(ua_dataSS_t * ua_dataSS, const char *src_blk_name, boo } /* - * If ab_update is set it means it is a DELTA_IMG_AB update, where the patch + * If ab_update is set it means it is a DELTA_IMAGE update, where the patch * is applied to data directly read from a partition in the previous slot */ SS_CalculateFileSha(src_blk_name, ua_dataSS->update_cfg->soure_img_size, calculated_sha1); @@ -2311,10 +2311,9 @@ int SS_IMGUpdatemain(ua_dataSS_t * ua_dataSS, int update_type) //SS_FSUpdatePar if (ua_dataSS->ui_progress) ua_dataSS->ui_progress(ua_dataSS, 40); - if (update_type == FULL_IMG && ua_dataSS->update_data->ua_temp_path) + if (update_type == FULL_IMAGE && ua_dataSS->update_data->ua_temp_path) ulResult = SS_MoveFile(SS_PATCHFILE_SOURCE, ua_dataSS->update_data->ua_temp_path); - else if ((ua_dataSS->update_cfg->update_type == DELTA_IMG && ua_dataSS->write_data_to_blkdev) - || ua_dataSS->update_cfg->update_type == EXTRA || ua_dataSS->update_cfg->update_type == DELTA_IMG_AB) { + else if (ua_dataSS->update_cfg->update_type == EXTRA || ua_dataSS->update_cfg->update_type == DELTA_IMAGE) { FILE *fp = NULL; char buf[14] = { 0, }; //to store zImage-delta magic keyword @@ -2332,12 +2331,10 @@ int SS_IMGUpdatemain(ua_dataSS_t * ua_dataSS, int update_type) //SS_FSUpdatePar LOGL(LOG_SSENGINE, "short read of \"%s\" (%ld bytes of %ld)\n", SS_PATCHFILE_SOURCE, (long)bytes_read, (long)13); fclose(fp); - if (update_type == DELTA_IMG_AB) + if (update_type == DELTA_IMAGE) ulResult = SS_UpdateDeltaIMGAB(ua_dataSS); else if (strncmp(buf, SS_KERNEL_MAGIC, sizeof(buf) / sizeof(char)) == 0) ulResult = SS_UpdateDeltaKernel(ua_dataSS, ua_dataSS->write_data_to_blkdev); - else - ulResult = SS_UpdateDeltaIMG(ua_dataSS, ua_dataSS->write_data_to_blkdev); } else { LOGE("Update type is INVALID - Exit \n"); ulResult = E_SS_FAILURE; diff --git a/ss_engine/ua_types.h b/ss_engine/ua_types.h index 859f49d..cb53ca7 100755 --- a/ss_engine/ua_types.h +++ b/ss_engine/ua_types.h @@ -34,13 +34,17 @@ #define UI_OP_UPDATE 3 typedef enum { - FULL_IMG, - DELTA_IMG, - DELTA_IMG_AB, + FULL_IMAGE, + DELTA_IMAGE, DELTA_FS, EXTRA } UA_DATA_FORMAT; +typedef enum { + BEFORE_BOOT_FOTA, + AT_BOOT_FOTA +} UPDATE_WHEN; + typedef enum { UA_MODE_SCOUT_UPDATE, UA_MODE_SCOUT, @@ -62,6 +66,7 @@ typedef struct _ua_update_data_t { typedef struct _ua_update_cfg_t { unsigned int update_type; + unsigned int update_when; int skip_verify; int skip_update; int soure_img_size; //TOTA -- cgit v1.2.3