Add to check the return of fseek() 37/198737/1
authorjiyong.min <jiyong.min@samsung.com>
Tue, 29 Jan 2019 00:20:07 +0000 (09:20 +0900)
committerJiyong Min <jiyong.min@samsung.com>
Tue, 29 Jan 2019 05:52:02 +0000 (05:52 +0000)
Change-Id: Iba167d0f8aa4ceb095f3a27202fb0ac2a0ce75b1

src/media_playlist.c

index b7bc197..5d0f87a 100755 (executable)
@@ -241,16 +241,24 @@ static int __media_playlist_import_item_from_file(const char* playlist_path, cha
        fp = fopen(playlist_path, "rb");
        media_content_retvm_if(fp == NULL, MEDIA_CONTENT_ERROR_INVALID_OPERATION, "fopen fail");
 
-       fseek(fp, 0, SEEK_END);
+       if (fseek(fp, 0, SEEK_END) < 0) {
+               media_content_stderror("fseek failed");
+               fclose(fp);
+               return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
+       }
        file_size = ftell(fp);
-       fseek(fp, 0 , SEEK_SET);
-
        if (file_size == 0) {
                media_content_debug("file is empty.");
                fclose(fp);
                return MEDIA_CONTENT_ERROR_NONE;
        }
 
+       if (fseek(fp, 0, SEEK_SET) < 0) {
+               media_content_stderror("fseek failed");
+               fclose(fp);
+               return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
+       }
+
        *item_list = calloc(current_max_size, sizeof(char*));
        if (*item_list == NULL) {
                fclose(fp);