]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Comment fileno() usage
authorTim Kientzle <kientzle@acm.org>
Sat, 19 Mar 2016 18:18:16 +0000 (11:18 -0700)
committerTim Kientzle <kientzle@acm.org>
Sat, 19 Mar 2016 18:18:16 +0000 (11:18 -0700)
libarchive/archive_read_open_file.c

index 3b7ff5ffdf61fa7ff16aace8d2438f51d5b3ac07..bfe933bf32e9da2ec118dc8f8814577672e5027e 100644 (file)
@@ -83,8 +83,9 @@ archive_read_open_FILE(struct archive *a, FILE *f)
        mine->f = f;
        /*
         * If we can't fstat() the file, it may just be that it's not
-        * a file.  (FILE * objects can wrap many kinds of I/O
-        * streams, some of which don't support fileno()).)
+        * a file.  (On some platforms, FILE * objects can wrap I/O
+        * streams that don't support fileno()).  As a result, fileno()
+        * should be used cautiously.)
         */
        if (fstat(fileno(mine->f), &st) == 0 && S_ISREG(st.st_mode)) {
                archive_read_extract_set_skip_file(a, st.st_dev, st.st_ino);
@@ -151,6 +152,7 @@ file_skip(struct archive *a, void *client_data, int64_t request)
        }
 
 #ifdef __ANDROID__
+        /* fileno() isn't safe on all platforms ... see above. */
        if (lseek(fileno(mine->f), skip, SEEK_CUR) < 0)
 #elif HAVE_FSEEKO
        if (fseeko(mine->f, skip, SEEK_CUR) != 0)