summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyungwook Tak <k.tak@samsung.com>2016-03-11 06:00:47 (GMT)
committerKyungwook Tak <k.tak@samsung.com>2016-03-11 06:01:17 (GMT)
commitdaa79b8ea309dbf39dcd47cce82cee0e3ba1e4c9 (patch)
treee975d6fbd56239e57fc287c6021991632a39ad07
parent4ac21f065674dd7c1b11a0918953fc552ec9a924 (diff)
downloadlibwebappenc-daa79b8ea309dbf39dcd47cce82cee0e3ba1e4c9.zip
libwebappenc-daa79b8ea309dbf39dcd47cce82cee0e3ba1e4c9.tar.gz
libwebappenc-daa79b8ea309dbf39dcd47cce82cee0e3ba1e4c9.tar.bz2
Remove unused values in test code Handle negative return value from ftell Change-Id: I331e1335ad900ef9e5ec4523a832ec2c38dfb7f8 Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
-rw-r--r--srcs/key_handler.c6
-rw-r--r--tests/wae_tests.c6
2 files changed, 6 insertions, 6 deletions
diff --git a/srcs/key_handler.c b/srcs/key_handler.c
index 7b050d6..714be0f 100644
--- a/srcs/key_handler.c
+++ b/srcs/key_handler.c
@@ -294,6 +294,12 @@ int _read_from_file(const char* path, unsigned char** data, size_t* len)
fseek(f, 0, SEEK_END); // move to the end of a file
file_len = ftell(f);
+ if (file_len <= 0) {
+ WAE_SLOGE("WAE: Failed to get file size by ftell. ret: %d", file_len);
+ ret = WAE_ERROR_FILE;
+ goto error;
+ }
+
fseek(f, 0, SEEK_SET); // move to the start of a file
file_contents = (unsigned char*) malloc(file_len);
diff --git a/tests/wae_tests.c b/tests/wae_tests.c
index 0b584e5..a40b301 100644
--- a/tests/wae_tests.c
+++ b/tests/wae_tests.c
@@ -613,7 +613,6 @@ int wae_tc_load_preloaded_app_deks()
unsigned char* readDek1 = NULL;
size_t readDekLen1 = 0;
char path1[MAX_PATH_LEN] = {0, };
- FILE *f1 = NULL;
const char* pkgId2 = "TEST_PKGID_2";
unsigned char* dek2 = NULL;
@@ -621,7 +620,6 @@ int wae_tc_load_preloaded_app_deks()
unsigned char* readDek2 = NULL;
size_t readDekLen2 = 0;
char path2[MAX_PATH_LEN] = {0, };
- FILE *f2 = NULL;
_get_preloaded_app_dek_file_path(pkgId1, sizeof(path1), path1);
_get_preloaded_app_dek_file_path(pkgId2, sizeof(path2), path2);
@@ -691,14 +689,10 @@ error:
free(dek1);
if(readDek1 != NULL)
free(readDek1);
- if(f1 != NULL)
- fclose(f1);
if(dek2 != NULL)
free(dek2);
if(readDek2 != NULL)
free(readDek2);
- if(f2 != NULL)
- fclose(f2);
return ret;
}