Check return value of fseek and ftell 11/175611/2
authorSemun Lee <semun.lee@samsung.com>
Wed, 11 Apr 2018 05:45:43 +0000 (14:45 +0900)
committerSemun Lee <semun.lee@samsung.com>
Wed, 11 Apr 2018 06:08:44 +0000 (15:08 +0900)
Change-Id: Ic2518251d8e8bfbfb3d53caa44c9ff378422c482
Signed-off-by: Semun Lee <semun.lee@samsung.com>
src/tool/preference_tool.c

index 97912778316fe87c7387794c90168464a341e222..499093325cc10a084c9248379edf95f81e315d23 100644 (file)
@@ -824,8 +824,20 @@ static int _add_key_info_to_file(const char *key_path, const char *key)
                return -1;
        }
 
-       fseek(fp, 0, SEEK_END);
+       ret = fseek(fp, 0, SEEK_END);
+       if (ret == -1) {
+               printf("failed to fseek.(%d/%s)\n", errno, strerror(errno));
+               ret = -1;
+               goto out;
+       }
+
        file_size = ftell(fp);
+       if (file_size == -1) {
+               printf("failed to ftell.(%d/%s)\n", errno, strerror(errno));
+               ret = -1;
+               goto out;
+       }
+
        rewind(fp);
 
        buf = (char *)calloc(1, file_size);