From: Tim Kientzle Date: Sat, 19 Mar 2016 18:18:16 +0000 (-0700) Subject: Comment fileno() usage X-Git-Tag: v3.1.901a~9^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f8e09322f156cb7880759d49a9bcc3fed9a5b95;p=thirdparty%2Flibarchive.git Comment fileno() usage --- diff --git a/libarchive/archive_read_open_file.c b/libarchive/archive_read_open_file.c index 3b7ff5ffd..bfe933bf3 100644 --- a/libarchive/archive_read_open_file.c +++ b/libarchive/archive_read_open_file.c @@ -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)