Use 64bit type internally for package archive size & offset
authorPanu Matilainen <pmatilai@redhat.com>
Mon, 9 Jun 2008 09:29:07 +0000 (12:29 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Mon, 9 Jun 2008 09:29:07 +0000 (12:29 +0300)
- cpio "new" ascii format limits individual files to UINT32_MAX, no such
  limit on the entire archive though
- RPMSIGTAG_PAYLOADSIZE is 32bit type atm, assert that the archive size
  fits to UINT32_MAX despite internal presentation being larger
- FD_t limits the real archive to rpm_off_t still

build/buildio.h
build/pack.c
lib/fsm.c
lib/fsm.h
lib/rpmfi_internal.h

index 355944f..ad3f9fd 100644 (file)
@@ -17,7 +17,7 @@ extern "C" {
 /**
  */
 typedef struct cpioSourceArchive_s {
-    rpm_off_t  cpioArchiveSize;
+    rpm_loff_t cpioArchiveSize;
     FD_t       cpioFdIn;
     rpmfi      cpioList;
 } * CSA_t;
index 912f0e3..0d3e2db 100644 (file)
@@ -467,7 +467,12 @@ rpmRC writeRPM(Header *hdrp, unsigned char ** pkgidp, const char *fileName,
        SHA1 = _free(SHA1);
     }
 
-    {  rpm_off_t payloadSize = csa->cpioArchiveSize;
+    {  /* 
+        * XXX size mismatch here, payloadsize is 32bit while archive
+        * is 64bit. Just assert for now, deal with this properly later...
+        */
+       assert(csa->cpioArchiveSize < UINT32_MAX);
+       rpm_off_t payloadSize = csa->cpioArchiveSize;
        (void) headerAddEntry(sig, RPMSIGTAG_PAYLOADSIZE, RPM_INT32_TYPE,
                        &payloadSize, 1);
     }
index be7c7f4..283d9ff 100644 (file)
--- a/lib/fsm.c
+++ b/lib/fsm.c
@@ -505,9 +505,9 @@ FSM_t freeFSM(FSM_t fsm)
 
 int fsmSetup(FSM_t fsm, fileStage goal,
                const rpmts ts, const rpmfi fi, FD_t cfd,
-               rpm_off_t * archiveSize, char ** failedFile)
+               rpm_loff_t * archiveSize, char ** failedFile)
 {
-    rpm_off_t pos = 0;
+    rpm_loff_t pos = 0;
     int rc, ec = 0;
 
     fsm->goal = goal;
@@ -765,7 +765,7 @@ static int fsmMapAttrs(FSM_t fsm)
 static int expandRegular(FSM_t fsm)
 {
     const struct stat * st = &fsm->sb;
-    rpm_off_t left = st->st_size;
+    rpm_loff_t left = st->st_size;
     int rc = 0;
 
     rc = fsmNext(fsm, FSM_WOPEN);
@@ -1712,7 +1712,7 @@ if (!(fsm->mapFlags & CPIO_ALL_HARDLINKS)) break;
            rpmts ts = fsmGetTs(fsm);
            rpmfi fi = fsmGetFi(fsm);
            void * ptr;
-           rpm_off_t archivePos = fdGetCpioPos(fsm->cfd);
+           rpm_loff_t archivePos = fdGetCpioPos(fsm->cfd);
            if (archivePos > fi->archivePos) {
                fi->archivePos = archivePos;
                ptr = rpmtsNotify(ts, fi->te, RPMCALLBACK_INST_PROGRESS,
index ca903b7..42936f6 100644 (file)
--- a/lib/fsm.h
+++ b/lib/fsm.h
@@ -130,7 +130,7 @@ struct fsm_s {
     int ix;                    /*!< Current file iterator index. */
     hardLink_t links;          /*!< Pending hard linked file(s). */
     hardLink_t li;             /*!< Current hard linked file(s). */
-    rpm_off_t * archiveSize;   /*!< Pointer to archive size. */
+    rpm_loff_t * archiveSize;  /*!< Pointer to archive size. */
     char ** failedFile;                /*!< First file name that failed. */
     const char * subdir;       /*!< Current file sub-directory. */
     char subbuf[64];   /* XXX eliminate */
@@ -197,7 +197,7 @@ int fsmSetup(FSM_t fsm, fileStage goal,
                const rpmts ts,
                const rpmfi fi,
                FD_t cfd,
-               rpm_off_t * archiveSize,
+               rpm_loff_t * archiveSize,
                char ** failedFile);
 
 /**
index 647f973..4cfc4f4 100644 (file)
@@ -108,8 +108,8 @@ struct rpmfi_s {
 
     size_t astriplen;
     size_t striplen;
-    rpm_off_t archivePos;
-    rpm_off_t archiveSize;
+    rpm_loff_t archivePos;
+    rpm_loff_t archiveSize;
     mode_t dperms;             /*!< Directory perms (0755) if not mapped. */
     mode_t fperms;             /*!< File perms (0644) if not mapped. */
     const char ** apath;