diff options
author | Jeon Sang-Heon <sh95.jeon@samsung.com> | 2020-02-12 14:40:46 +0900 |
---|---|---|
committer | Jeon Sang-Heon <sh95.jeon@samsung.com> | 2020-02-12 14:57:15 +0900 |
commit | 5a78eb49dacb58f0de8a0ebef4eed64665bf2268 (patch) | |
tree | 85d5dfaa87309a8651f828d813868ce9ed887c62 | |
parent | 604aa0f624635cad5019dea6c9fd393dc1d9aaf7 (diff) | |
download | libtota-5a78eb49dacb58f0de8a0ebef4eed64665bf2268.tar.gz libtota-5a78eb49dacb58f0de8a0ebef4eed64665bf2268.tar.bz2 libtota-5a78eb49dacb58f0de8a0ebef4eed64665bf2268.zip |
Fix coverity issuesubmit/tizen/20200212.070853accepted/tizen/unified/20200212.125721
- initialize file.data with NULL
- make item_data and buf to null terminated
- initialize sha1_ctx_t message buffer with NULL
Change-Id: I885f12079525f6745f1ab1a78051790c90f5007d
Signed-off-by: Jeon Sang-Heon <sh95.jeon@samsung.com>
-rwxr-xr-x | ss_engine/SS_PatchDelta.c | 4 | ||||
-rwxr-xr-x | ss_engine/SS_UPI.c | 3 | ||||
-rwxr-xr-x | ss_engine/sha1.c | 5 |
3 files changed, 11 insertions, 1 deletions
diff --git a/ss_engine/SS_PatchDelta.c b/ss_engine/SS_PatchDelta.c index a65ae7c..9b4c7db 100755 --- a/ss_engine/SS_PatchDelta.c +++ b/ss_engine/SS_PatchDelta.c @@ -639,7 +639,7 @@ int SS_UpdateDeltaKernel(ua_dataSS_t * ua_dataSS, int (*write_to_blkdev) (char * goto Cleanup; } //read kernel delta header for delta names and size - buf = SS_Malloc(SS_KERNEL_DELTA_HEADER); + buf = SS_Malloc(SS_KERNEL_DELTA_HEADER + 1); if (!buf) {//wgid: 13099 LOGE("Failed to allocate memory\n"); result = E_SS_MALLOC_ERROR; @@ -648,6 +648,8 @@ int SS_UpdateDeltaKernel(ua_dataSS_t * ua_dataSS, int (*write_to_blkdev) (char * ssize_t bytes_read = fread(buf, 1, SS_KERNEL_DELTA_HEADER, fp); if (bytes_read != SS_KERNEL_DELTA_HEADER) LOGL(LOG_SSENGINE, "short read of \"%s\" (%ld bytes of %ld)\n", SS_PATCHFILE_SOURCE, (long)bytes_read, (long)SS_KERNEL_DELTA_HEADER); + buf[bytes_read] = '\0'; + magic = strtok_r(buf, ":", &saveptr); LOGL(LOG_SSENGINE, "magic: %s\n", magic); tok_buf = strtok_r(NULL, ":", &saveptr); diff --git a/ss_engine/SS_UPI.c b/ss_engine/SS_UPI.c index 935906e..9c51ed3 100755 --- a/ss_engine/SS_UPI.c +++ b/ss_engine/SS_UPI.c @@ -315,6 +315,7 @@ int SS_verify_DELTA_image(char *filename) long int udelta_size = 0; int ulResult = S_SS_SUCCESS; + file.data = NULL; if (stat(filename, &file.st) != 0) { strerror_r(errno, buf, sizeof(buf)); LOGE("failed to stat \"%s\": %s\n", filename, buf); @@ -1348,6 +1349,8 @@ int SS_FSSetAttributes(ua_dataSS_t * ua_dataSS) } return E_SS_FAILURE; } + item_data[read_data] = '\0'; + pline = strtok_r(item_data, "\n", &psaveptr); if (pline == NULL) { LOGL(LOG_SSENGINE, "No Attributes to SET as no lines in file\n"); diff --git a/ss_engine/sha1.c b/ss_engine/sha1.c index 91ef661..54d75a2 100755 --- a/ss_engine/sha1.c +++ b/ss_engine/sha1.c @@ -183,6 +183,7 @@ sha1_core(const uint32_t M[16], uint32_t hash_value[5]) { void sha1_init(sha1_ctx_t *ctx) { + int i; /* initialize state vector */ ctx->H[0] = 0x67452301; @@ -191,6 +192,10 @@ sha1_init(sha1_ctx_t *ctx) { ctx->H[3] = 0x10325476; ctx->H[4] = 0xc3d2e1f0; + for(i = 0; i < 16; i++) { + ctx->M[i] = 0; + } + /* indicate that message buffer is empty */ ctx->octets_in_buffer = 0; |