Просмотр исходного кода

Use off_t and %jd or %jx to handle file sizes and offsets

This allows to support large files on 32-bit systems were a ‘long int’
type might not be of at least 64-bits. For printing %jd or %jx is used,
and the value is cast to intmax_t.
Guillem Jover лет назад: 15
Родитель
Сommit
86cbf575b1
15 измененных файлов с 58 добавлено и 48 удалено
  1. 3 2
      dpkg-deb/build.c
  2. 10 8
      dpkg-deb/extract.c
  3. 3 2
      dpkg-deb/info.c
  4. 6 6
      dpkg-split/dpkg-split.h
  5. 10 10
      dpkg-split/info.c
  6. 2 2
      dpkg-split/main.c
  7. 5 4
      dpkg-split/queue.c
  8. 6 4
      dpkg-split/split.c
  9. 4 3
      lib/dpkg/ar.c
  10. 1 1
      lib/dpkg/ar.h
  11. 1 1
      lib/dpkg/buffer.c
  12. 1 1
      lib/dpkg/tarfn.c
  13. 1 1
      lib/dpkg/tarfn.h
  14. 3 2
      src/archives.c
  15. 2 1
      src/processarc.c

+ 3 - 2
dpkg-deb/build.c

@@ -34,6 +34,7 @@
 #include <fcntl.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <unistd.h>
 #include <stdbool.h>
 #include <stdbool.h>
+#include <stdint.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdio.h>
 
 
@@ -488,8 +489,8 @@ void do_build(const char *const *argv) {
 
 
     if (fstat(gzfd, &controlstab))
     if (fstat(gzfd, &controlstab))
       ohshite(_("failed to stat temporary file (%s)"), _("control member"));
       ohshite(_("failed to stat temporary file (%s)"), _("control member"));
-    sprintf(versionbuf, "%-8s\n%ld\n", OLDARCHIVEVERSION,
-            (long)controlstab.st_size);
+    sprintf(versionbuf, "%-8s\n%jd\n", OLDARCHIVEVERSION,
+            (intmax_t)controlstab.st_size);
     if (fd_write(arfd, versionbuf, strlen(versionbuf)) < 0)
     if (fd_write(arfd, versionbuf, strlen(versionbuf)) < 0)
       ohshite(_("error writing `%s'"), debar);
       ohshite(_("error writing `%s'"), debar);
     fd_fd_copy(gzfd, arfd, -1, _("control member"));
     fd_fd_copy(gzfd, arfd, -1, _("control member"));

+ 10 - 8
dpkg-deb/extract.c

@@ -35,6 +35,7 @@
 #include <unistd.h>
 #include <unistd.h>
 #include <ar.h>
 #include <ar.h>
 #include <stdbool.h>
 #include <stdbool.h>
+#include <stdint.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdio.h>
 
 
@@ -106,7 +107,7 @@ extracthalf(const char *debar, const char *dir, const char *taroption,
 {
 {
   char versionbuf[40];
   char versionbuf[40];
   float versionnum;
   float versionnum;
-  size_t ctrllennum, memberlen= 0;
+  off_t ctrllennum, memberlen = 0;
   ssize_t r;
   ssize_t r;
   int dummy;
   int dummy;
   pid_t c1=0,c2,c3;
   pid_t c1=0,c2,c3;
@@ -153,7 +154,7 @@ extracthalf(const char *debar, const char *dir, const char *taroption,
           ohshit(_("file `%.250s' is not a debian binary archive (try dpkg-split?)"),debar);
           ohshit(_("file `%.250s' is not a debian binary archive (try dpkg-split?)"),debar);
         infobuf= m_malloc(memberlen+1);
         infobuf= m_malloc(memberlen+1);
         r = fd_read(arfd, infobuf, memberlen + (memberlen & 1));
         r = fd_read(arfd, infobuf, memberlen + (memberlen & 1));
-        if ((size_t)r != (memberlen + (memberlen & 1)))
+        if (r != (memberlen + (memberlen & 1)))
           read_fail(r, debar, _("archive information header member"));
           read_fail(r, debar, _("archive information header member"));
         infobuf[memberlen] = '\0';
         infobuf[memberlen] = '\0';
         cur= strchr(infobuf,'\n');
         cur= strchr(infobuf,'\n');
@@ -210,8 +211,8 @@ extracthalf(const char *debar, const char *dir, const char *taroption,
 
 
     if (admininfo >= 2) {
     if (admininfo >= 2) {
       printf(_(" new debian package, version %s.\n"
       printf(_(" new debian package, version %s.\n"
-               " size %ld bytes: control archive= %zi bytes.\n"),
-             versionbuf, (long)stab.st_size, ctrllennum);
+               " size %jd bytes: control archive= %jd bytes.\n"),
+             versionbuf, (intmax_t)stab.st_size, (intmax_t)ctrllennum);
       m_output(stdout, _("<standard output>"));
       m_output(stdout, _("<standard output>"));
     }
     }
   } else if (!strncmp(versionbuf,"0.93",4) &&
   } else if (!strncmp(versionbuf,"0.93",4) &&
@@ -228,7 +229,8 @@ extracthalf(const char *debar, const char *dir, const char *taroption,
     r = read_line(arfd, ctrllenbuf, 1, sizeof(ctrllenbuf));
     r = read_line(arfd, ctrllenbuf, 1, sizeof(ctrllenbuf));
     if (r < 0)
     if (r < 0)
       read_fail(r, debar, _("archive control member size"));
       read_fail(r, debar, _("archive control member size"));
-    if (sscanf(ctrllenbuf,"%zi%c%d",&ctrllennum,&nlc,&dummy) !=2 || nlc != '\n')
+    if (sscanf(ctrllenbuf, "%jd%c%d", &ctrllennum, &nlc, &dummy) != 2 ||
+        nlc != '\n')
       ohshit(_("archive has malformatted control member size '%s'"), ctrllenbuf);
       ohshit(_("archive has malformatted control member size '%s'"), ctrllenbuf);
 
 
     if (admininfo) {
     if (admininfo) {
@@ -241,9 +243,9 @@ extracthalf(const char *debar, const char *dir, const char *taroption,
 
 
     if (admininfo >= 2) {
     if (admininfo >= 2) {
       printf(_(" old debian package, version %s.\n"
       printf(_(" old debian package, version %s.\n"
-               " size %ld bytes: control archive= %zi, main archive= %ld.\n"),
-             versionbuf, (long)stab.st_size, ctrllennum,
-             (long) (stab.st_size - ctrllennum - strlen(ctrllenbuf) - l));
+               " size %jd bytes: control archive= %jd, main archive= %jd.\n"),
+             versionbuf, (intmax_t)stab.st_size, (intmax_t)ctrllennum,
+             (intmax_t)(stab.st_size - ctrllennum - strlen(ctrllenbuf) - l));
       m_output(stdout, _("<standard output>"));
       m_output(stdout, _("<standard output>"));
     }
     }
   } else {
   } else {

+ 3 - 2
dpkg-deb/info.c

@@ -33,6 +33,7 @@
 #include <fcntl.h>
 #include <fcntl.h>
 #include <dirent.h>
 #include <dirent.h>
 #include <unistd.h>
 #include <unistd.h>
+#include <stdint.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdio.h>
 
 
@@ -163,8 +164,8 @@ info_list(const char *debar, const char *dir)
       if (ferror(cc)) ohshite(_("failed to read `%.255s' (in `%.255s')"),
       if (ferror(cc)) ohshite(_("failed to read `%.255s' (in `%.255s')"),
                               cdep->d_name, dir);
                               cdep->d_name, dir);
       fclose(cc);
       fclose(cc);
-      printf(_(" %7ld bytes, %5d lines   %c  %-20.127s %.127s\n"),
-             (long)stab.st_size, lines, S_IXUSR & stab.st_mode ? '*' : ' ',
+      printf(_(" %7jd bytes, %5d lines   %c  %-20.127s %.127s\n"),
+             (intmax_t)stab.st_size, lines, S_IXUSR & stab.st_mode ? '*' : ' ',
              cdep->d_name, interpreter);
              cdep->d_name, interpreter);
     } else {
     } else {
       printf(_("     not a plain file          %.255s\n"), cdep->d_name);
       printf(_("     not a plain file          %.255s\n"), cdep->d_name);

+ 6 - 6
dpkg-split/dpkg-split.h

@@ -31,13 +31,13 @@ struct partinfo {
   const char *package;
   const char *package;
   const char *version;
   const char *version;
   const char *md5sum;
   const char *md5sum;
-  unsigned long orglength;
+  off_t orglength;
   unsigned int thispartn, maxpartn;
   unsigned int thispartn, maxpartn;
-  unsigned long maxpartlen;
-  unsigned long thispartoffset;
-  size_t thispartlen;
+  off_t maxpartlen;
+  off_t thispartoffset;
+  off_t thispartlen;
   /* Size of header in part file. */
   /* Size of header in part file. */
-  size_t headerlen;
+  off_t headerlen;
   off_t filesize;
   off_t filesize;
 };
 };
 
 
@@ -52,7 +52,7 @@ struct partqueue {
 
 
 extern struct partqueue *queue;
 extern struct partqueue *queue;
 
 
-extern long opt_maxpartsize;
+extern off_t opt_maxpartsize;
 extern const char *opt_depotdir;
 extern const char *opt_depotdir;
 extern const char *opt_outputfile;
 extern const char *opt_outputfile;
 extern int opt_npquiet;
 extern int opt_npquiet;

+ 10 - 10
dpkg-split/info.c

@@ -204,24 +204,24 @@ void print_info(const struct partinfo *pi) {
          "    Part of package:                %s\n"
          "    Part of package:                %s\n"
          "        ... version:                %s\n"
          "        ... version:                %s\n"
          "        ... MD5 checksum:           %s\n"
          "        ... MD5 checksum:           %s\n"
-         "        ... length:                 %lu bytes\n"
-         "        ... split every:            %lu bytes\n"
+         "        ... length:                 %jd bytes\n"
+         "        ... split every:            %jd bytes\n"
          "    Part number:                    %d/%d\n"
          "    Part number:                    %d/%d\n"
-         "    Part length:                    %zi bytes\n"
-         "    Part offset:                    %lu bytes\n"
-         "    Part file size (used portion):  %lu bytes\n\n"),
+         "    Part length:                    %jd bytes\n"
+         "    Part offset:                    %jd bytes\n"
+         "    Part file size (used portion):  %jd bytes\n\n"),
          pi->filename,
          pi->filename,
          pi->fmtversion,
          pi->fmtversion,
          pi->package,
          pi->package,
          pi->version,
          pi->version,
          pi->md5sum,
          pi->md5sum,
-         pi->orglength,
-         pi->maxpartlen,
+         (intmax_t)pi->orglength,
+         (intmax_t)pi->maxpartlen,
          pi->thispartn,
          pi->thispartn,
          pi->maxpartn,
          pi->maxpartn,
-         pi->thispartlen,
-         pi->thispartoffset,
-         (unsigned long)pi->filesize);
+         (intmax_t)pi->thispartlen,
+         (intmax_t)pi->thispartoffset,
+         (intmax_t)pi->filesize);
 }
 }
 
 
 void do_info(const char *const *argv) {
 void do_info(const char *const *argv) {

+ 2 - 2
dpkg-split/main.c

@@ -99,7 +99,7 @@ const char printforhelp[]= N_("Type dpkg-split --help for help.");
 
 
 struct partqueue *queue= NULL;
 struct partqueue *queue= NULL;
 
 
-long opt_maxpartsize = SPLITPARTDEFMAX;
+off_t opt_maxpartsize = SPLITPARTDEFMAX;
 const char *opt_depotdir = ADMINDIR "/" PARTSDIR;
 const char *opt_depotdir = ADMINDIR "/" PARTSDIR;
 const char *opt_outputfile = NULL;
 const char *opt_outputfile = NULL;
 int opt_npquiet = 0;
 int opt_npquiet = 0;
@@ -111,7 +111,7 @@ void rerreof(FILE *f, const char *fn) {
 }
 }
 
 
 static void setpartsize(const struct cmdinfo *cip, const char *value) {
 static void setpartsize(const struct cmdinfo *cip, const char *value) {
-  long newpartsize;
+  off_t newpartsize;
   char *endp;
   char *endp;
 
 
   newpartsize = strtoimax(value, &endp, 10);
   newpartsize = strtoimax(value, &endp, 10);

+ 5 - 4
dpkg-split/queue.c

@@ -30,6 +30,7 @@
 #include <fcntl.h>
 #include <fcntl.h>
 #include <dirent.h>
 #include <dirent.h>
 #include <unistd.h>
 #include <unistd.h>
+#include <stdint.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdio.h>
 
 
@@ -168,7 +169,7 @@ void do_auto(const char *const *argv) {
     char *p, *q;
     char *p, *q;
 
 
     m_asprintf(&p, "%st.%lx", opt_depotdir, (long)getpid());
     m_asprintf(&p, "%st.%lx", opt_depotdir, (long)getpid());
-    m_asprintf(&q, "%s%s.%lx.%x.%x", opt_depotdir, refi->md5sum,
+    m_asprintf(&q, "%s%s.%jx.%x.%x", (intmax_t)opt_depotdir, refi->md5sum,
                refi->maxpartlen, refi->thispartn, refi->maxpartn);
                refi->maxpartlen, refi->thispartn, refi->maxpartn);
 
 
     fd_src = open(partfile, O_RDONLY);
     fd_src = open(partfile, O_RDONLY);
@@ -219,7 +220,7 @@ void do_queue(const char *const *argv) {
   struct partqueue *pq;
   struct partqueue *pq;
   const char *head;
   const char *head;
   struct stat stab;
   struct stat stab;
-  unsigned long bytes;
+  off_t bytes;
 
 
   if (*argv)
   if (*argv)
     badusage(_("--%s takes no arguments"), cipaction->olong);
     badusage(_("--%s takes no arguments"), cipaction->olong);
@@ -233,7 +234,7 @@ void do_queue(const char *const *argv) {
       ohshit(_("unable to stat `%.250s'"),pq->info.filename);
       ohshit(_("unable to stat `%.250s'"),pq->info.filename);
     if (S_ISREG(stab.st_mode)) {
     if (S_ISREG(stab.st_mode)) {
       bytes= stab.st_size;
       bytes= stab.st_size;
-      printf(_(" %s (%lu bytes)\n"),pq->info.filename,bytes);
+      printf(_(" %s (%jd bytes)\n"), pq->info.filename, (intmax_t)bytes);
     } else {
     } else {
       printf(_(" %s (not a plain file)\n"),pq->info.filename);
       printf(_(" %s (not a plain file)\n"),pq->info.filename);
     }
     }
@@ -268,7 +269,7 @@ void do_queue(const char *const *argv) {
         qq->info.md5sum = NULL;
         qq->info.md5sum = NULL;
       }
       }
     }
     }
-    printf(_("(total %lu bytes)\n"),bytes);
+    printf(_("(total %jd bytes)\n"), (intmax_t)bytes);
   }
   }
   m_output(stdout, _("<standard output>"));
   m_output(stdout, _("<standard output>"));
 }
 }

+ 6 - 4
dpkg-split/split.c

@@ -33,6 +33,7 @@
 #include <ctype.h>
 #include <ctype.h>
 #include <time.h>
 #include <time.h>
 #include <unistd.h>
 #include <unistd.h>
+#include <stdint.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdio.h>
 
 
@@ -109,7 +110,7 @@ clean_msdos_filename(char *filename)
 }
 }
 
 
 static int
 static int
-mksplit(const char *file_src, const char *prefix, size_t maxpartsize,
+mksplit(const char *file_src, const char *prefix, off_t maxpartsize,
         bool msdos)
         bool msdos)
 {
 {
 	int fd_src;
 	int fd_src;
@@ -187,7 +188,7 @@ mksplit(const char *file_src, const char *prefix, size_t maxpartsize,
 		if (curpart == nparts)
 		if (curpart == nparts)
 			partsize = last_partsize;
 			partsize = last_partsize;
 
 
-		if ((size_t)partsize > maxpartsize) {
+		if (partsize > maxpartsize) {
 			ohshit(_("Header is too long, making part too long. "
 			ohshit(_("Header is too long, making part too long. "
 			       "Your package name or version\n"
 			       "Your package name or version\n"
 			       "numbers must be extraordinarily long, "
 			       "numbers must be extraordinarily long, "
@@ -203,9 +204,10 @@ mksplit(const char *file_src, const char *prefix, size_t maxpartsize,
 		dpkg_ar_put_magic(file_dst.buf, fd_dst);
 		dpkg_ar_put_magic(file_dst.buf, fd_dst);
 
 
 		/* Write the debian-split part. */
 		/* Write the debian-split part. */
-		varbuf_printf(&partmagic, "%s\n%s\n%s\n%s\n%zu\n%zu\n%d/%d\n",
+		varbuf_printf(&partmagic, "%s\n%s\n%s\n%s\n%jd\n%jd\n%d/%d\n",
 		              SPLITVERSION, package, version, hash,
 		              SPLITVERSION, package, version, hash,
-		              st.st_size, partsize, curpart, nparts);
+		              (intmax_t)st.st_size, (intmax_t)partsize,
+		              curpart, nparts);
 		dpkg_ar_member_put_mem(file_dst.buf, fd_dst, PARTMAGIC,
 		dpkg_ar_member_put_mem(file_dst.buf, fd_dst, PARTMAGIC,
 		                       partmagic.buf, partmagic.used);
 		                       partmagic.buf, partmagic.used);
 		varbuf_reset(&partmagic);
 		varbuf_reset(&partmagic);

+ 4 - 3
lib/dpkg/ar.c

@@ -25,6 +25,7 @@
 #include <sys/stat.h>
 #include <sys/stat.h>
 
 
 #include <time.h>
 #include <time.h>
+#include <stdint.h>
 #include <unistd.h>
 #include <unistd.h>
 
 
 #include <dpkg/i18n.h>
 #include <dpkg/i18n.h>
@@ -82,13 +83,13 @@ dpkg_ar_put_magic(const char *ar_name, int ar_fd)
 
 
 void
 void
 dpkg_ar_member_put_header(const char *ar_name, int ar_fd,
 dpkg_ar_member_put_header(const char *ar_name, int ar_fd,
-                          const char *name, size_t size)
+                          const char *name, off_t size)
 {
 {
 	char header[sizeof(struct ar_hdr) + 1];
 	char header[sizeof(struct ar_hdr) + 1];
 	int n;
 	int n;
 
 
-	n = sprintf(header, "%-16s%-12lu0     0     100644  %-10lu`\n",
-	            name, time(NULL), (unsigned long)size);
+	n = sprintf(header, "%-16s%-12lu0     0     100644  %-10jd`\n",
+	            name, time(NULL), (intmax_t)size);
 	if (n != sizeof(struct ar_hdr))
 	if (n != sizeof(struct ar_hdr))
 		ohshit(_("generated corrupt ar header for '%s'"), ar_name);
 		ohshit(_("generated corrupt ar header for '%s'"), ar_name);
 
 

+ 1 - 1
lib/dpkg/ar.h

@@ -35,7 +35,7 @@ void dpkg_ar_normalize_name(struct ar_hdr *arh);
 
 
 void dpkg_ar_put_magic(const char *ar_name, int ar_fd);
 void dpkg_ar_put_magic(const char *ar_name, int ar_fd);
 void dpkg_ar_member_put_header(const char *ar_name, int ar_fd,
 void dpkg_ar_member_put_header(const char *ar_name, int ar_fd,
-                               const char *name, size_t size);
+                               const char *name, off_t size);
 void dpkg_ar_member_put_file(const char *ar_name, int ar_fd, const char *name,
 void dpkg_ar_member_put_file(const char *ar_name, int ar_fd, const char *name,
                              int fd, off_t size);
                              int fd, off_t size);
 void dpkg_ar_member_put_mem(const char *ar_name, int ar_fd, const char *name,
 void dpkg_ar_member_put_mem(const char *ar_name, int ar_fd, const char *name,

+ 1 - 1
lib/dpkg/buffer.c

@@ -154,7 +154,7 @@ buffer_copy(struct buffer_data *read_data, struct buffer_data *write_data,
 {
 {
 	char *buf;
 	char *buf;
 	int bufsize = 32768;
 	int bufsize = 32768;
-	long bytesread = 0, byteswritten = 0;
+	off_t bytesread = 0, byteswritten = 0;
 	off_t totalread = 0, totalwritten = 0;
 	off_t totalread = 0, totalwritten = 0;
 
 
 	if ((limit != -1) && (limit < bufsize))
 	if ((limit != -1) && (limit < bufsize))

+ 1 - 1
lib/dpkg/tarfn.c

@@ -196,7 +196,7 @@ tar_header_decode(struct tar_header *h, struct tar_entry *d)
 		d->name = StoC(h->name, sizeof(h->name));
 		d->name = StoC(h->name, sizeof(h->name));
 	d->linkname = StoC(h->linkname, sizeof(h->linkname));
 	d->linkname = StoC(h->linkname, sizeof(h->linkname));
 	d->stat.mode = get_unix_mode(h);
 	d->stat.mode = get_unix_mode(h);
-	d->size = (size_t)OtoM(h->size, sizeof(h->size));
+	d->size = (off_t)OtoM(h->size, sizeof(h->size));
 	d->stat.mtime = (time_t)OtoM(h->mtime, sizeof(h->mtime));
 	d->stat.mtime = (time_t)OtoM(h->mtime, sizeof(h->mtime));
 	d->dev = ((OtoM(h->devmajor, sizeof(h->devmajor)) & 0xff) << 8) |
 	d->dev = ((OtoM(h->devmajor, sizeof(h->devmajor)) & 0xff) << 8) |
 	         (OtoM(h->devminor, sizeof(h->devminor)) & 0xff);
 	         (OtoM(h->devminor, sizeof(h->devminor)) & 0xff);

+ 1 - 1
lib/dpkg/tarfn.h

@@ -56,7 +56,7 @@ struct tar_entry {
 	enum tar_filetype type;	/* Regular, Directory, Special, Link */
 	enum tar_filetype type;	/* Regular, Directory, Special, Link */
 	char *name;		/* File name */
 	char *name;		/* File name */
 	char *linkname;		/* Name for symbolic and hard links */
 	char *linkname;		/* Name for symbolic and hard links */
-	size_t size;		/* Size of file */
+	off_t size;		/* Size of file */
 	dev_t dev;		/* Special device for mknod() */
 	dev_t dev;		/* Special device for mknod() */
 
 
 	struct file_stat stat;
 	struct file_stat stat;

+ 3 - 2
src/archives.c

@@ -34,6 +34,7 @@
 #include <utime.h>
 #include <utime.h>
 #include <fcntl.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <unistd.h>
+#include <stdint.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdio.h>
 #include <obstack.h>
 #include <obstack.h>
@@ -683,8 +684,8 @@ tarobject(void *ctx, struct tar_entry *ti)
       ohshite(_("unable to create `%.255s' (while processing `%.255s')"),
       ohshite(_("unable to create `%.255s' (while processing `%.255s')"),
               fnamenewvb.buf, ti->name);
               fnamenewvb.buf, ti->name);
     push_cleanup(cu_closefd, ehflag_bombout, NULL, 0, 1, &fd);
     push_cleanup(cu_closefd, ehflag_bombout, NULL, 0, 1, &fd);
-    debug(dbg_eachfiledetail, "tarobject file open size=%lu",
-          (unsigned long)ti->size);
+    debug(dbg_eachfiledetail, "tarobject file open size=%jd",
+          (intmax_t)ti->size);
     { char fnamebuf[256];
     { char fnamebuf[256];
     fd_fd_copy(tc->backendpipe, fd, ti->size,
     fd_fd_copy(tc->backendpipe, fd, ti->size,
                _("backend dpkg-deb during `%.255s'"),
                _("backend dpkg-deb during `%.255s'"),

+ 2 - 1
src/processarc.c

@@ -35,6 +35,7 @@
 #include <fcntl.h>
 #include <fcntl.h>
 #include <dirent.h>
 #include <dirent.h>
 #include <unistd.h>
 #include <unistd.h>
+#include <stdint.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdio.h>
 
 
@@ -430,7 +431,7 @@ void process_archive(const char *filename) {
   /* Always nfmalloc. Otherwise, we may overwrite some other field (like
   /* Always nfmalloc. Otherwise, we may overwrite some other field (like
    * md5sum). */
    * md5sum). */
   psize = nfmalloc(30);
   psize = nfmalloc(30);
-  sprintf(psize, "%lu", (unsigned long)stab.st_size);
+  sprintf(psize, "%jd", (intmax_t)stab.st_size);
   pkg->files->size = psize;
   pkg->files->size = psize;
 
 
   if (cipaction->arg_int == act_avail) {
   if (cipaction->arg_int == act_avail) {