summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2012-07-02 17:11:00 +0300
committerPanu Matilainen <pmatilai@redhat.com>2012-07-02 17:11:00 +0300
commit338f6e4cf76807744aac31016c9f357631bc7d86 (patch)
treef6276799b2017279416b02e43a218a0d01464851
parentf79ce27fffb7cee7353ca2f4bc9a4bfafb0cda34 (diff)
downloadlibrpm-tizen-338f6e4cf76807744aac31016c9f357631bc7d86.tar.gz
librpm-tizen-338f6e4cf76807744aac31016c9f357631bc7d86.tar.bz2
librpm-tizen-338f6e4cf76807744aac31016c9f357631bc7d86.zip
Push payload file size limit checking into cpio code
- At the time when the file list is being processed, we dont yet have the slightest clue what kind of payload will be used for for the archive or what limits it might have. Let the cpio code handle its own limits checking, the build-side only needs to worry about whether 32bit uints are sufficient for storing the sizes in headers.
-rw-r--r--build/files.c15
-rw-r--r--lib/cpio.c5
-rw-r--r--lib/cpio.h1
3 files changed, 8 insertions, 13 deletions
diff --git a/build/files.c b/build/files.c
index f42110ac6..8affb9a80 100644
--- a/build/files.c
+++ b/build/files.c
@@ -1057,11 +1057,7 @@ static void genCpioListAndHeader(FileList fl,
headerPutString(h, RPMTAG_FILEUSERNAME, flp->uname);
headerPutString(h, RPMTAG_FILEGROUPNAME, flp->gname);
- /*
- * Only use 64bit filesizes if file sizes require it.
- * This is basically no-op for now as we error out in addFile() if
- * any individual file size exceeds the cpio limit.
- */
+ /* Only use 64bit filesizes tag if required. */
if (fl->largeFiles) {
rpm_loff_t rsize64 = (rpm_loff_t)flp->fl_size;
headerPutUint64(h, RPMTAG_LONGFILESIZES, &rsize64, 1);
@@ -1437,15 +1433,8 @@ static rpmRC addFile(FileList fl, const char * diskPath,
flp->verifyFlags = fl->cur.verifyFlags;
if (!(flp->flags & RPMFILE_EXCLUDE) && S_ISREG(flp->fl_mode)) {
- /*
- * XXX Simple and stupid check for now, this needs to be per-payload
- * format check once we have other payloads than good 'ole cpio.
- */
- if ((rpm_loff_t) flp->fl_size >= CPIO_FILESIZE_MAX) {
+ if (flp->fl_size >= UINT32_MAX) {
fl->largeFiles = 1;
- rpmlog(RPMLOG_ERR, _("File %s too large for payload\n"),
- flp->diskPath);
- goto exit;
}
}
}
diff --git a/lib/cpio.c b/lib/cpio.c
index c7a8bdf99..1ddd1e33e 100644
--- a/lib/cpio.c
+++ b/lib/cpio.c
@@ -178,6 +178,10 @@ int rpmcpioHeaderWrite(rpmcpio_t cpio, char * path, struct stat * st)
return CPIOERR_WRITE_FAILED;
}
+ if (st->st_size >= CPIO_FILESIZE_MAX) {
+ return CPIOERR_FILE_SIZE;
+ }
+
rc = rpmcpioWritePad(cpio, 4);
if (rc) {
return rc;
@@ -385,6 +389,7 @@ const char * rpmcpioStrerror(int rc)
case CPIOERR_SETCAP_FAILED: s = "cap_set_file"; break;
case CPIOERR_HDR_SIZE: s = _("Header size too big"); break;
+ case CPIOERR_FILE_SIZE: s = _("File too large for archive"); break;
case CPIOERR_UNKNOWN_FILETYPE: s = _("Unknown file type"); break;
case CPIOERR_MISSING_HARDLINK: s = _("Missing hard link(s)"); break;
case CPIOERR_DIGEST_MISMATCH: s = _("Digest mismatch"); break;
diff --git a/lib/cpio.h b/lib/cpio.h
index 3f514d041..7364caf27 100644
--- a/lib/cpio.h
+++ b/lib/cpio.h
@@ -51,6 +51,7 @@ enum cpioErrorReturns {
CPIOERR_ENOENT = 30,
CPIOERR_ENOTEMPTY = 31,
CPIOERR_SETCAP_FAILED = 32 | CPIOERR_CHECK_ERRNO,
+ CPIOERR_FILE_SIZE = 33,
};
/*