From: Tim Kientzle Date: Thu, 14 May 2009 23:55:24 +0000 (-0400) Subject: Avoid problems because of varying ino_t sizes on different platforms. In particular... X-Git-Tag: v2.8.0~651 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9fe9e21463d10175cc18ea10ff6adbcc43d67916;p=thirdparty%2Flibarchive.git Avoid problems because of varying ino_t sizes on different platforms. In particular, Windows uses a 16-bit (?!) ino_t, so we can't just cast the constant here to ino_t. The next API changes should avoid ino_t entirely to prevent problems reading cpio archives on platforms where the native ino_t type isn't big enough. SVN-Revision: 1082 --- diff --git a/libarchive/archive_write_set_format_cpio.c b/libarchive/archive_write_set_format_cpio.c index c20abf809..043bf3ccd 100644 --- a/libarchive/archive_write_set_format_cpio.c +++ b/libarchive/archive_write_set_format_cpio.c @@ -109,6 +109,7 @@ archive_write_cpio_header(struct archive_write *a, struct archive_entry *entry) struct cpio *cpio; const char *p, *path; int pathlength, ret; + int64_t ino; struct cpio_header h; cpio = (struct cpio *)a->format_data; @@ -125,7 +126,8 @@ archive_write_cpio_header(struct archive_write *a, struct archive_entry *entry) * re-using the ones off the disk. That way, the 18-bit c_ino * field only limits the number of files in the archive. */ - if ((int)archive_entry_ino(entry) > 0777777) { + ino = (int64_t)archive_entry_ino(entry); + if (ino < 0 || ino > 0777777) { archive_set_error(&a->archive, ERANGE, "large inode number truncated"); ret = ARCHIVE_WARN;