]> granicus.if.org Git - mutt/commitdiff
Full large file support. Keep a close watch on your mailboxes everyone!
authorBrendan Cully <brendan@kublai.com>
Fri, 21 Oct 2005 04:35:37 +0000 (04:35 +0000)
committerBrendan Cully <brendan@kublai.com>
Fri, 21 Oct 2005 04:35:37 +0000 (04:35 +0000)
22 files changed:
attach.c
buffy.c
copy.c
copy.h
crypt-gpgme.c
crypt.c
edit.c
handler.c
mbox.c
mutt.h
pager.c
parse.c
pattern.c
pgp.c
pgpmicalg.c
pgppacket.c
pgppubring.c
pop.c
postpone.c
protos.h
sendlib.c
smime.c

index 8a44859bb6d5d666fd0529f2ad5b121d673d59ea..74377b0d7c9026d8219017402b5ff87d1b89f6af 100644 (file)
--- a/attach.c
+++ b/attach.c
@@ -168,7 +168,7 @@ int mutt_compose_attachment (BODY *a)
 
            /* Remove headers by copying out data to another file, then 
             * copying the file back */
-           fseek (fp, b->offset, 0);
+           fseeko (fp, b->offset, 0);
            mutt_mktemp (tempfile);
            if ((tfp = safe_fopen (tempfile, "w")) == NULL)
            {
@@ -771,7 +771,7 @@ int mutt_save_attachment (FILE *fp, BODY *m, char *path, int flags, HEADER *hdr)
       hn->msgno = hdr->msgno; /* required for MH/maildir */
       hn->read = 1;
 
-      fseek (fp, m->offset, 0);
+      fseeko (fp, m->offset, 0);
       if (fgets (buf, sizeof (buf), fp) == NULL)
        return -1;
       if (mx_open_mailbox(path, M_APPEND | M_QUIET, &ctx) == NULL)
@@ -806,7 +806,7 @@ int mutt_save_attachment (FILE *fp, BODY *m, char *path, int flags, HEADER *hdr)
        mutt_perror ("fopen");
        return (-1);
       }
-      fseek ((s.fpin = fp), m->offset, 0);
+      fseeko ((s.fpin = fp), m->offset, 0);
       mutt_decode_attachment (m, &s);
       
       if (fclose (s.fpout) != 0)
diff --git a/buffy.c b/buffy.c
index 0e85877aec5be9235c4638d6df4303ee74ba113f..11d133d8f81ab2275eb6e3497671b044af512ee4 100644 (file)
--- a/buffy.c
+++ b/buffy.c
@@ -52,14 +52,14 @@ static short BuffyNotify = 0;       /* # of unnotified new boxes */
 
 int fseek_last_message (FILE * f)
 {
-  long int pos;
+  LOFF_T pos;
   char buffer[BUFSIZ + 9];     /* 7 for "\n\nFrom " */
   int bytes_read;
   int i;                       /* Index into `buffer' for scanning.  */
 
   memset (buffer, 0, sizeof(buffer));
   fseek (f, 0, SEEK_END);
-  pos = ftell (f);
+  pos = ftello (f);
 
   /* Set `bytes_read' to the size of the last, probably partial, buffer; 0 <
    * `bytes_read' <= `BUFSIZ'.  */
@@ -72,14 +72,14 @@ int fseek_last_message (FILE * f)
   {
     /* we save in the buffer at the end the first 7 chars from the last read */
     strncpy (buffer + BUFSIZ, buffer, 5+2); /* 2 == 2 * mutt_strlen(CRLF) */
-    fseek (f, pos, SEEK_SET);
+    fseeko (f, pos, SEEK_SET);
     bytes_read = fread (buffer, sizeof (char), bytes_read, f);
     if (bytes_read == -1)
       return -1;
     for (i = bytes_read; --i >= 0;)
       if (!mutt_strncmp (buffer + i, "\n\nFrom ", mutt_strlen ("\n\nFrom ")))
       {                                /* found it - go to the beginning of the From */
-       fseek (f, pos + i + 2, SEEK_SET);
+       fseeko (f, pos + i + 2, SEEK_SET);
        return 0;
       }
     bytes_read = BUFSIZ;
diff --git a/copy.c b/copy.c
index 05a0e3bdb090cd9493d5764293c02b3a073cbfbb..16af8e8f0bd120e843aa985c19c01022e1c722bb 100644 (file)
--- a/copy.c
+++ b/copy.c
@@ -41,7 +41,7 @@ static int copy_delete_attach (BODY *b, FILE *fpin, FILE *fpout, char *date);
  * below is to avoid creating a HEADER structure in message_handler().
  */
 int
-mutt_copy_hdr (FILE *in, FILE *out, long off_start, long off_end, int flags,
+mutt_copy_hdr (FILE *in, FILE *out, LOFF_T off_start, LOFF_T off_end, int flags,
               const char *prefix)
 {
   int from = 0;
@@ -56,8 +56,8 @@ mutt_copy_hdr (FILE *in, FILE *out, long off_start, long off_end, int flags,
   char *this_one = NULL;
   int error;
 
-  if (ftell (in) != off_start)
-    fseek (in, off_start, 0);
+  if (ftello (in) != off_start)
+    fseeko (in, off_start, 0);
 
   buf[0] = '\n';
   buf[1] = 0;
@@ -67,7 +67,7 @@ mutt_copy_hdr (FILE *in, FILE *out, long off_start, long off_end, int flags,
     /* Without these flags to complicate things
      * we can do a more efficient line to line copying
      */
-    while (ftell (in) < off_end)
+    while (ftello (in) < off_end)
     {
       nl = strchr (buf, '\n');
 
@@ -136,7 +136,7 @@ mutt_copy_hdr (FILE *in, FILE *out, long off_start, long off_end, int flags,
   headers = safe_calloc (hdr_count, sizeof (char *));
 
   /* Read all the headers into the array */
-  while (ftell (in) < off_end)
+  while (ftello (in) < off_end)
   {
     nl = strchr (buf, '\n');
 
@@ -165,10 +165,10 @@ mutt_copy_hdr (FILE *in, FILE *out, long off_start, long off_end, int flags,
          strcat (headers[x], this_one); /* __STRCAT_CHECKED__ */
          FREE (&this_one);
        }
-       
+
        this_one = NULL;
       }
-      
+
       ignore = 1;
       this_is_from = 0;
       if (!from && mutt_strncmp ("From ", buf, 5) == 0)
@@ -222,7 +222,7 @@ mutt_copy_hdr (FILE *in, FILE *out, long off_start, long off_end, int flags,
          }
        }
       }
-      
+
       ignore = 0;
     } /* If beginning of header */
 
@@ -238,7 +238,7 @@ mutt_copy_hdr (FILE *in, FILE *out, long off_start, long off_end, int flags,
        strcat (this_one, buf); /* __STRCAT_CHECKED__ */
       }
     }
-  } /* while (ftell (in) < off_end) */
+  } /* while (ftello (in) < off_end) */
 
   /* Do we have anything pending?  -- XXX, same code as in above in the loop. */
   if (this_one)
@@ -258,7 +258,7 @@ mutt_copy_hdr (FILE *in, FILE *out, long off_start, long off_end, int flags,
       strcat (headers[x], this_one); /* __STRCAT_CHECKED__ */
       FREE (&this_one);
     }
-    
+
     this_one = NULL;
   }
 
@@ -571,7 +571,7 @@ _mutt_copy_message (FILE *fpout, FILE *fpin, HEADER *hdr, BODY *body,
       date[5] = date[mutt_strlen (date) - 1] = '\"';
 
       /* Count the number of lines and bytes to be deleted */
-      fseek (fpin, body->offset, SEEK_SET);
+      fseeko (fpin, body->offset, SEEK_SET);
       new_lines = hdr->lines -
        count_delete_lines (fpin, body, &new_length, mutt_strlen (date));
 
@@ -586,10 +586,10 @@ _mutt_copy_message (FILE *fpout, FILE *fpin, HEADER *hdr, BODY *body,
        fprintf (fpout, "Lines: %d\n\n", new_lines);
       if (ferror (fpout) || feof (fpout))
        return -1;
-      new_offset = ftell (fpout);
+      new_offset = ftello (fpout);
 
       /* Copy the body */
-      fseek (fpin, body->offset, SEEK_SET);
+      fseeko (fpin, body->offset, SEEK_SET);
       if (copy_delete_attach (body, fpin, fpout, date))
        return -1;
 
@@ -686,7 +686,7 @@ _mutt_copy_message (FILE *fpout, FILE *fpin, HEADER *hdr, BODY *body,
     mutt_write_mime_header (cur, fpout);
     fputc ('\n', fpout);
 
-    fseek (fp, cur->offset, 0);
+    fseeko (fp, cur->offset, 0);
     if (mutt_copy_bytes (fp, fpout, cur->length) == -1)
     {
       fclose (fp);
@@ -698,7 +698,7 @@ _mutt_copy_message (FILE *fpout, FILE *fpin, HEADER *hdr, BODY *body,
   }
   else
   {
-    fseek (fpin, body->offset, 0);
+    fseeko (fpin, body->offset, 0);
     if (flags & M_CM_PREFIX)
     {
       int c;
@@ -767,7 +767,7 @@ _mutt_append_message (CONTEXT *dest, FILE *fpin, CONTEXT *src, HEADER *hdr,
   MESSAGE *msg;
   int r;
 
-  fseek(fpin, hdr->offset, 0);
+  fseek(fpin, hdr->offset, 0);
   if (fgets (buf, sizeof (buf), fpin) == NULL)
     return -1;
   
@@ -814,7 +814,7 @@ static int copy_delete_attach (BODY *b, FILE *fpin, FILE *fpout, char *date)
     if (part->deleted || part->parts)
     {
       /* Copy till start of this part */
-      if (mutt_copy_bytes (fpin, fpout, part->hdr_offset - ftell (fpin)))
+      if (mutt_copy_bytes (fpin, fpout, part->hdr_offset - ftello (fpin)))
        return -1;
 
       if (part->deleted)
@@ -827,11 +827,11 @@ static int copy_delete_attach (BODY *b, FILE *fpin, FILE *fpout, char *date)
          return -1;
 
        /* Copy the original mime headers */
-       if (mutt_copy_bytes (fpin, fpout, part->offset - ftell (fpin)))
+       if (mutt_copy_bytes (fpin, fpout, part->offset - ftello (fpin)))
          return -1;
 
        /* Skip the deleted body */
-       fseek (fpin, part->offset + part->length, SEEK_SET);
+       fseeko (fpin, part->offset + part->length, SEEK_SET);
       }
       else
       {
@@ -842,7 +842,7 @@ static int copy_delete_attach (BODY *b, FILE *fpin, FILE *fpout, char *date)
   }
 
   /* Copy the last parts */
-  if (mutt_copy_bytes (fpin, fpout, b->offset + b->length - ftell (fpin)))
+  if (mutt_copy_bytes (fpin, fpout, b->offset + b->length - ftello (fpin)))
     return -1;
 
   return 0;
diff --git a/copy.h b/copy.h
index d254272a5d8d43f624552c9206a4896e57ed5646..8197299d758e4fd4edd10dbb14a20d036f090510 100644 (file)
--- a/copy.h
+++ b/copy.h
@@ -37,7 +37,7 @@
 
 
 
-int mutt_copy_hdr (FILE *, FILE *, long, long, int, const char *);
+int mutt_copy_hdr (FILE *, FILE *, LOFF_T, LOFF_T, int, const char *);
 
 int mutt_copy_header (FILE *, HEADER *, FILE *, int, const char *);
 
index f90cb5f1dd697d02a4b8526221ad457056ba85aa..07d0039a97ebe25cefd6e45324e1142927e2471f 100644 (file)
@@ -1621,7 +1621,7 @@ int smime_gpgme_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur)
   STATE s;
   FILE *tmpfp=NULL;
   int is_signed;
-  long saved_b_offset;
+  LOFF_T saved_b_offset;
   size_t saved_b_length;
   int saved_b_type;
 
@@ -1640,7 +1640,7 @@ int smime_gpgme_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur)
   saved_b_length = b->length;
   memset (&s, 0, sizeof (s));
   s.fpin = fpin;
-  fseek (s.fpin, b->offset, 0); 
+  fseeko (s.fpin, b->offset, 0); 
   mutt_mktemp (tempfile);
   if (!(tmpfp = safe_fopen (tempfile, "w+")))
     {
@@ -1652,7 +1652,7 @@ int smime_gpgme_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur)
   s.fpout = tmpfp;
   mutt_decode_attachment (b, &s);
   fflush (tmpfp);
-  b->length = ftell (s.fpout);
+  b->length = ftello (s.fpout);
   b->offset = 0;
   rewind (tmpfp);
 
@@ -1694,7 +1694,7 @@ int smime_gpgme_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur)
       saved_b_length = bb->length;
       memset (&s, 0, sizeof (s));
       s.fpin = *fpout;
-      fseek (s.fpin, bb->offset, 0); 
+      fseeko (s.fpin, bb->offset, 0); 
       mutt_mktemp (tempfile);
       if (!(tmpfp = safe_fopen (tempfile, "w+")))
         {
@@ -1706,7 +1706,7 @@ int smime_gpgme_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur)
       s.fpout = tmpfp;
       mutt_decode_attachment (bb, &s);
       fflush (tmpfp);
-      bb->length = ftell (s.fpout);
+      bb->length = ftello (s.fpout);
       bb->offset = 0;
       rewind (tmpfp);
       fclose (*fpout); 
@@ -1887,7 +1887,8 @@ int pgp_gpgme_application_handler (BODY *m, STATE *s)
   int needpass = -1, pgp_keyblock = 0;
   int clearsign = 0;
   long start_pos = 0;
-  long bytes, last_pos, offset;
+  long bytes;
+  LOFF_T last_pos, offset;
   char buf[HUGE_STRING];
   FILE *pgpout = NULL;
 
@@ -1907,7 +1908,7 @@ int pgp_gpgme_application_handler (BODY *m, STATE *s)
   if (!mutt_get_body_charset (body_charset, sizeof (body_charset), m))
     strfcpy (body_charset, "iso-8859-1", sizeof body_charset);
 
-  fseek (s->fpin, m->offset, 0);
+  fseeko (s->fpin, m->offset, 0);
   last_pos = m->offset;
   
   for (bytes = m->length; bytes > 0;)
@@ -1915,7 +1916,7 @@ int pgp_gpgme_application_handler (BODY *m, STATE *s)
       if (fgets (buf, sizeof (buf), s->fpin) == NULL)
         break;
       
-      offset = ftell (s->fpin);
+      offset = ftello (s->fpin);
       bytes -= (offset - last_pos); /* don't rely on mutt_strlen(buf) */
       last_pos = offset;
       
@@ -1954,7 +1955,7 @@ int pgp_gpgme_application_handler (BODY *m, STATE *s)
           gpgme_data_write (armored_data, buf, strlen (buf));
           while (bytes > 0 && fgets (buf, sizeof (buf) - 1, s->fpin) != NULL)
             {
-              offset = ftell (s->fpin);
+              offset = ftello (s->fpin);
               bytes -= (offset - last_pos); /* don't rely on mutt_strlen(buf)*/
               last_pos = offset;
               
diff --git a/crypt.c b/crypt.c
index 3afbd9ae0a80eb687ab15827ecdf82c6dd77d130..0f08f2a6f23a900f318d4ca751337538ff634281 100644 (file)
--- a/crypt.c
+++ b/crypt.c
@@ -504,7 +504,7 @@ int crypt_write_signed(BODY *a, STATE *s, const char *tempfile)
     return -1;
   }
       
-  fseek (s->fpin, a->hdr_offset, 0);
+  fseeko (s->fpin, a->hdr_offset, 0);
   bytes = a->length + a->offset - a->hdr_offset;
   hadcr = 0;
   while (bytes > 0)
diff --git a/edit.c b/edit.c
index eb50e4f4d0c80a2b84205f40a1a3aac5c3a6dc5e..d952e9a25ec4e7f5915ac44494fed689a114f408 100644 (file)
--- a/edit.c
+++ b/edit.c
@@ -61,7 +61,7 @@ static char* EditorHelp2 = N_("\
 .              on a line by itself ends input\n");
 
 static char **
-be_snarf_data (FILE *f, char **buf, int *bufmax, int *buflen, int offset,
+be_snarf_data (FILE *f, char **buf, int *bufmax, int *buflen, LOFF_T offset,
               int bytes, int prefix)
 {
   char tmp[HUGE_STRING];
@@ -77,7 +77,7 @@ be_snarf_data (FILE *f, char **buf, int *bufmax, int *buflen, int offset,
     tmplen = sizeof (tmp) - tmplen;
   }
 
-  fseek (f, offset, 0);
+  fseeko (f, offset, 0);
   while (bytes > 0)
   {
     if (fgets (p, tmplen - 1, f) == NULL) break;
index c2d7fd74a1ecc1804f0a39d9b954a25bb0cf1f55..a5b04c27e14e2fe5d14d8d64ecd6857f05000a62 100644 (file)
--- a/handler.c
+++ b/handler.c
@@ -1340,7 +1340,7 @@ static int alternative_handler (BODY *a, STATE *s)
   {
     if (s->flags & M_DISPLAY && !option (OPTWEED))
     {
-      fseek (s->fpin, choice->hdr_offset, 0);
+      fseeko (s->fpin, choice->hdr_offset, 0);
       mutt_copy_bytes(s->fpin, s->fpout, choice->offset-choice->hdr_offset);
     }
     mutt_body_handler (choice, s);
@@ -1364,16 +1364,16 @@ int message_handler (BODY *a, STATE *s)
 {
   struct stat st;
   BODY *b;
-  long off_start;
+  LOFF_T off_start;
   int rc = 0;
 
-  off_start = ftell (s->fpin);
+  off_start = ftello (s->fpin);
   if (a->encoding == ENCBASE64 || a->encoding == ENCQUOTEDPRINTABLE || 
       a->encoding == ENCUUENCODED)
   {
     fstat (fileno (s->fpin), &st);
     b = mutt_new_body ();
-    b->length = (long) st.st_size;
+    b->length = (LOFF_T) st.st_size;
     b->parts = mutt_parse_messageRFC822 (s->fpin, b);
   }
   else
@@ -1482,7 +1482,7 @@ int multipart_handler (BODY *a, STATE *s)
                    TYPE (p), p->subtype, ENCODING (p->encoding), length);
       if (!option (OPTWEED))
       {
-       fseek (s->fpin, p->hdr_offset, 0);
+       fseeko (s->fpin, p->hdr_offset, 0);
        mutt_copy_bytes(s->fpin, s->fpout, p->offset-p->hdr_offset);
       }
       else
@@ -1697,7 +1697,7 @@ static int external_body_handler (BODY *b, STATE *s)
        state_printf (s, _("[-- name: %s --]\n"), b->parts->filename);
       }
 
-      mutt_copy_hdr (s->fpin, s->fpout, ftell (s->fpin), b->parts->offset,
+      mutt_copy_hdr (s->fpin, s->fpout, ftello (s->fpin), b->parts->offset,
                     (option (OPTWEED) ? (CH_WEED | CH_REORDER) : 0) |
                     CH_DECODE , NULL);
     }
@@ -1712,7 +1712,7 @@ static int external_body_handler (BODY *b, STATE *s)
       state_attach_puts (_("[-- and the indicated external source has --]\n"
                           "[-- expired. --]\n"), s);
 
-      mutt_copy_hdr(s->fpin, s->fpout, ftell (s->fpin), b->parts->offset,
+      mutt_copy_hdr(s->fpin, s->fpout, ftello (s->fpin), b->parts->offset,
                    (option (OPTWEED) ? (CH_WEED | CH_REORDER) : 0) |
                    CH_DECODE, NULL);
     }
@@ -1729,7 +1729,7 @@ static int external_body_handler (BODY *b, STATE *s)
       state_printf (s, 
                    _("[-- and the indicated access-type %s is unsupported --]\n"),
                    access_type);
-      mutt_copy_hdr (s->fpin, s->fpout, ftell (s->fpin), b->parts->offset,
+      mutt_copy_hdr (s->fpin, s->fpout, ftello (s->fpin), b->parts->offset,
                     (option (OPTWEED) ? (CH_WEED | CH_REORDER) : 0) |
                     CH_DECODE , NULL);
     }
@@ -1750,7 +1750,7 @@ void mutt_decode_attachment (BODY *b, STATE *s)
       cd = mutt_iconv_open (Charset, charset, M_ICONV_HOOK_FROM);
   }
 
-  fseek (s->fpin, b->offset, 0);
+  fseeko (s->fpin, b->offset, 0);
   switch (b->encoding)
   {
     case ENCQUOTEDPRINTABLE:
@@ -1867,7 +1867,7 @@ int mutt_body_handler (BODY *b, STATE *s)
 
   if (plaintext || handler)
   {
-    fseek (s->fpin, b->offset, 0);
+    fseeko (s->fpin, b->offset, 0);
 
     /* see if we need to decode this part before processing it */
     if (b->encoding == ENCBASE64 || b->encoding == ENCQUOTEDPRINTABLE ||
@@ -1912,7 +1912,7 @@ int mutt_body_handler (BODY *b, STATE *s)
 
       if (decode)
       {
-       b->length = ftell (s->fpout);
+       b->length = ftello (s->fpout);
        b->offset = 0;
        fclose (s->fpout);
 
diff --git a/mbox.c b/mbox.c
index cd8a20545d93bef365eeb23bad3d8e860efc0eee..751697e8dd77edf9f69747cba6aebaa26e877c36 100644 (file)
--- a/mbox.c
+++ b/mbox.c
 struct m_update_t
 {
   short valid;
-  long hdr;
-  long body;
+  LOFF_T hdr;
+  LOFF_T body;
   long lines;
-  long length;
+  LOFF_T length;
 };
 
 /* parameters:
@@ -147,7 +147,7 @@ int mmdf_parse_mailbox (CONTEXT *ctx)
 
       if (!is_from (buf, return_path, sizeof (return_path), &t))
       {
-       if (fseek (ctx->fp, loc, SEEK_SET) != 0)
+       if (fseeko (ctx->fp, loc, SEEK_SET) != 0)
        {
          dprint (1, (debugfile, "mmdf_parse_mailbox: fseek() failed\n"));
          mutt_error _("Mailbox is corrupt!");
@@ -167,11 +167,11 @@ int mmdf_parse_mailbox (CONTEXT *ctx)
 
        if (0 < tmploc && tmploc < ctx->size)
        {
-         if (fseek (ctx->fp, tmploc, SEEK_SET) != 0 ||
+         if (fseeko (ctx->fp, tmploc, SEEK_SET) != 0 ||
              fgets (buf, sizeof (buf) - 1, ctx->fp) == NULL ||
              mutt_strcmp (MMDF_SEP, buf) != 0)
          {
-           if (fseek (ctx->fp, loc, SEEK_SET) != 0)
+           if (fseeko (ctx->fp, loc, SEEK_SET) != 0)
              dprint (1, (debugfile, "mmdf_parse_mailbox: fseek() failed\n"));
            hdr->content->length = -1;
          }
@@ -319,7 +319,7 @@ int mbox_parse_mailbox (CONTEXT *ctx)
              fgets (buf, sizeof (buf), ctx->fp) == NULL ||
              mutt_strncmp ("From ", buf, 5) != 0)
          {
-           dprint (1, (debugfile, "mbox_parse_mailbox: bad content-length in message %d (cl=%ld)\n", curhdr->index, curhdr->content->length));
+           dprint (1, (debugfile, "mbox_parse_mailbox: bad content-length in message %d (cl=" OFF_T_FMT ")\n", curhdr->index, curhdr->content->length));
            dprint (1, (debugfile, "\tLINE: %s", buf));
            if (fseeko (ctx->fp, loc, SEEK_SET) != 0) /* nope, return the previous position */
            {
@@ -601,14 +601,14 @@ int mbox_check_mailbox (CONTEXT *ctx, int *index_hint)
        * see the message separator at *exactly* what used to be the end of the
        * folder.
        */
-      if (fseek (ctx->fp, ctx->size, SEEK_SET) != 0)
+      if (fseeko (ctx->fp, ctx->size, SEEK_SET) != 0)
        dprint (1, (debugfile, "mbox_check_mailbox: fseek() failed\n"));
       if (fgets (buffer, sizeof (buffer), ctx->fp) != NULL)
       {
        if ((ctx->magic == M_MBOX && mutt_strncmp ("From ", buffer, 5) == 0) ||
            (ctx->magic == M_MMDF && mutt_strcmp (MMDF_SEP, buffer) == 0))
        {
-         if (fseek (ctx->fp, ctx->size, SEEK_SET) != 0)
+         if (fseeko (ctx->fp, ctx->size, SEEK_SET) != 0)
            dprint (1, (debugfile, "mbox_check_mailbox: fseek() failed\n"));
          if (ctx->magic == M_MBOX)
            mbox_parse_mailbox (ctx);
@@ -675,7 +675,7 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint)
   int rc = -1;
   int need_sort = 0; /* flag to resort mailbox if new mail arrives */
   int first = -1;      /* first message to be written */
-  long offset; /* location in mailbox to write changed messages */
+  LOFF_T offset;       /* location in mailbox to write changed messages */
   struct stat statbuf;
   struct utimbuf utimebuf;
   struct m_update_t *newOffset = NULL;
@@ -808,7 +808,7 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint)
        * temporary file only contains saved message which are located after
        * `offset' in the real mailbox
        */
-      newOffset[i - first].hdr = ftell (fp) + offset;
+      newOffset[i - first].hdr = ftello (fp) + offset;
 
       if (mutt_copy_message (fp, ctx, ctx->hdrs[i], M_CM_UPDATE, CH_FROM | CH_UPDATE | CH_UPDATE_LEN) == -1)
       {
@@ -824,7 +824,7 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint)
        * we just flush the in memory cache so that the message will be reparsed
        * if the user accesses it later.
        */
-      newOffset[i - first].body = ftell (fp) - ctx->hdrs[i]->content->length + offset;
+      newOffset[i - first].body = ftello (fp) - ctx->hdrs[i]->content->length + offset;
       mutt_free_body (&ctx->hdrs[i]->content->parts);
 
       switch(ctx->magic)
@@ -880,7 +880,7 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint)
     return (-1);
   }
 
-  if (fseek (ctx->fp, offset, SEEK_SET) != 0 ||  /* seek the append location */
+  if (fseeko (ctx->fp, offset, SEEK_SET) != 0 ||  /* seek the append location */
       /* do a sanity check to make sure the mailbox looks ok */
       fgets (buf, sizeof (buf), ctx->fp) == NULL ||
       (ctx->magic == M_MBOX && mutt_strncmp ("From ", buf, 5) != 0) ||
@@ -892,7 +892,7 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint)
   }
   else
   {
-    if (fseek (ctx->fp, offset, SEEK_SET) != 0) /* return to proper offset */
+    if (fseeko (ctx->fp, offset, SEEK_SET) != 0) /* return to proper offset */
     {
       i = -1;
       dprint (1, (debugfile, "mbox_sync_mailbox: fseek() failed\n"));
@@ -910,7 +910,7 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint)
     }
     if (i == 0)
     {
-      ctx->size = ftell (ctx->fp); /* update the size of the mailbox */
+      ctx->size = ftello (ctx->fp); /* update the size of the mailbox */
       ftruncate (fileno (ctx->fp), ctx->size);
     }
   }
diff --git a/mutt.h b/mutt.h
index 7b2d3e3ef6e4a1caff2a031833d61b6325baa498..d57b7d807d671f9460ce01da2fdcd4905aa65e16 100644 (file)
--- a/mutt.h
+++ b/mutt.h
@@ -627,8 +627,8 @@ typedef struct body
                                 * where we need to send the headers of the
                                 * attachment
                                 */
-  long offset;                  /* offset where the actual data begins */
-  LOFF_T length;                  /* length (in bytes) of attachment */
+  LOFF_T offset;                /* offset where the actual data begins */
+  LOFF_T length;                /* length (in bytes) of attachment */
   char *filename;               /* when sending a message, this is the file
                                 * to which this structure refers
                                 */
@@ -740,7 +740,7 @@ typedef struct header
 
   time_t date_sent;            /* time when the message was sent (UTC) */
   time_t received;             /* time when the message was placed in the mailbox */
-  long offset;                 /* where in the stream does this message begin? */
+  LOFF_T offset;               /* where in the stream does this message begin? */
   int lines;                   /* how many lines in the body of this message? */
   int index;                   /* the absolute (unsorted) message number */
   int msgno;                   /* number displayed to the user */
diff --git a/pager.c b/pager.c
index e5c89a3120825f4dab4c26834f971d7e8bc8cf22..440d7c6d14412f028b3c022ee14bad32cbd6344e 100644 (file)
--- a/pager.c
+++ b/pager.c
@@ -113,7 +113,7 @@ struct syntax_t
 
 struct line_t
 {
-  long offset;
+  LOFF_T offset;
   short type;
   short continuation;
   short chunks;
@@ -999,7 +999,7 @@ trim_incomplete_mbyte(unsigned char *buf, size_t len)
 }
 
 static int
-fill_buffer (FILE *f, long *last_pos, long offset, unsigned char *buf, 
+fill_buffer (FILE *f, LOFF_T *last_pos, LOFF_T offset, unsigned char *buf, 
             unsigned char *fmt, size_t blen, int *buf_ready)
 {
   unsigned char *p;
@@ -1009,13 +1009,13 @@ fill_buffer (FILE *f, long *last_pos, long offset, unsigned char *buf,
   {
     buf[blen - 1] = 0;
     if (offset != *last_pos)
-      fseek (f, offset, 0);
+      fseeko (f, offset, 0);
     if (fgets ((char *) buf, blen - 1, f) == NULL)
     {
       fmt[0] = 0;
       return (-1);
     }
-    *last_pos = ftell (f);
+    *last_pos = ftello (f);
     b_read = (int) (*last_pos - offset);
     *buf_ready = 1;
 
@@ -1232,7 +1232,7 @@ static int format_line (struct line_t **lineInfo, int n, unsigned char *buf,
  */
 
 static int
-display_line (FILE *f, long *last_pos, struct line_t **lineInfo, int n, 
+display_line (FILE *f, LOFF_T *last_pos, struct line_t **lineInfo, int n, 
              int *last, int *max, int flags, struct q_class_t **QuoteList,
              int *q_level, int *force_redraw, regex_t *SearchRE)
 {
@@ -1519,7 +1519,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra)
   int r = -1;
   int redraw = REDRAW_FULL;
   FILE *fp = NULL;
-  long last_pos = 0, last_offset = 0;
+  LOFF_T last_pos = 0, last_offset = 0;
   int old_smart_wrap, old_markers;
   struct stat sb;
   regex_t SearchRE;
diff --git a/parse.c b/parse.c
index 697662a11c73d8b6a62052321921aca0c50e3cb1..7c637a9f68c15445681bba76087c6d23c89fcd3c 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -431,7 +431,7 @@ BODY *mutt_read_mime_header (FILE *fp, int digest)
   char *line = safe_malloc (LONG_STRING);
   size_t linelen = LONG_STRING;
   
-  p->hdr_offset  = ftell(fp);
+  p->hdr_offset  = ftell(fp);
 
   p->encoding    = ENC7BIT; /* default from RFC1521 */
   p->type        = digest ? TYPEMESSAGE : TYPETEXT;
@@ -488,7 +488,7 @@ BODY *mutt_read_mime_header (FILE *fp, int digest)
     }
 #endif
   }
-  p->offset = ftell (fp); /* Mark the start of the real data */
+  p->offset = ftello (fp); /* Mark the start of the real data */
   if (p->type == TYPETEXT && !p->subtype)
     p->subtype = safe_strdup ("plain");
   else if (p->type == TYPEMESSAGE && !p->subtype)
@@ -513,7 +513,7 @@ void mutt_parse_part (FILE *fp, BODY *b)
 #endif
           bound = mutt_get_parameter ("boundary", b->parameter);
 
-      fseek (fp, b->offset, SEEK_SET);
+      fseeko (fp, b->offset, SEEK_SET);
       b->parts =  mutt_parse_multipart (fp, bound, 
                                        b->offset + b->length,
                                        ascii_strcasecmp ("digest", b->subtype) == 0);
@@ -522,7 +522,7 @@ void mutt_parse_part (FILE *fp, BODY *b)
     case TYPEMESSAGE:
       if (b->subtype)
       {
-       fseek (fp, b->offset, SEEK_SET);
+       fseeko (fp, b->offset, SEEK_SET);
        if (mutt_is_message_type(b->type, b->subtype))
          b->parts = mutt_parse_messageRFC822 (fp, b);
        else if (ascii_strcasecmp (b->subtype, "external-body") == 0)
@@ -560,7 +560,7 @@ BODY *mutt_parse_messageRFC822 (FILE *fp, BODY *parent)
   BODY *msg;
 
   parent->hdr = mutt_new_header ();
-  parent->hdr->offset = ftell (fp);
+  parent->hdr->offset = ftello (fp);
   parent->hdr->env = mutt_read_rfc822_header (fp, parent->hdr, 0, 0);
   msg = parent->hdr->content;
 
@@ -590,7 +590,7 @@ BODY *mutt_parse_messageRFC822 (FILE *fp, BODY *parent)
  *     digest          1 if reading a multipart/digest, 0 otherwise
  */
 
-BODY *mutt_parse_multipart (FILE *fp, const char *boundary, long end_off, int digest)
+BODY *mutt_parse_multipart (FILE *fp, const char *boundary, LOFF_T end_off, int digest)
 {
 #ifdef SUN_ATTACHMENT
   int lines;
@@ -608,7 +608,7 @@ BODY *mutt_parse_multipart (FILE *fp, const char *boundary, long end_off, int di
   }
 
   blen = mutt_strlen (boundary);
-  while (ftell (fp) < end_off && fgets (buffer, LONG_STRING, fp) != NULL)
+  while (ftello (fp) < end_off && fgets (buffer, LONG_STRING, fp) != NULL)
   {
     len = mutt_strlen (buffer);
 
@@ -619,9 +619,9 @@ BODY *mutt_parse_multipart (FILE *fp, const char *boundary, long end_off, int di
     {
       if (last)
       {
-       last->length = ftell (fp) - last->offset - len - 1 - crlf;
+       last->length = ftello (fp) - last->offset - len - 1 - crlf;
        if (last->parts && last->parts->length == 0)
-         last->parts->length = ftell (fp) - last->parts->offset - len - 1 - crlf;
+         last->parts->length = ftello (fp) - last->parts->offset - len - 1 - crlf;
        /* if the body is empty, we can end up with a -1 length */
        if (last->length < 0)
          last->length = 0;
@@ -645,7 +645,7 @@ BODY *mutt_parse_multipart (FILE *fp, const char *boundary, long end_off, int di
         if (mutt_get_parameter ("content-lines", new->parameter)) {
          for (lines = atoi(mutt_get_parameter ("content-lines", new->parameter));
               lines; lines-- )
-            if (ftell (fp) >= end_off || fgets (buffer, LONG_STRING, fp) == NULL)
+            if (ftello (fp) >= end_off || fgets (buffer, LONG_STRING, fp) == NULL)
               break;
        }
 #endif
@@ -1304,7 +1304,7 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs,
   LIST *last = NULL;
   char *line = safe_malloc (LONG_STRING);
   char *p;
-  long loc;
+  LOFF_T loc;
   int matched;
   size_t linelen = LONG_STRING;
   char buf[LONG_STRING+1];
@@ -1326,7 +1326,7 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs,
     }
   }
 
-  while ((loc = ftell (f)),
+  while ((loc = ftello (f)),
          *(line = mutt_read_rfc822_line (f, line, &linelen)) != 0)
   {
     matched = 0;
@@ -1347,7 +1347,7 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs,
        continue;
       }
 
-      fseek (f, loc, 0);
+      fseeko (f, loc, 0);
       break; /* end of header */
     }
 
@@ -1409,7 +1409,7 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs,
   if (hdr)
   {
     hdr->content->hdr_offset = hdr->offset;
-    hdr->content->offset = ftell (f);
+    hdr->content->offset = ftello (f);
 
     /* do RFC2047 decoding */
     rfc2047_decode_adrlist (e->from);
index 12d413f0e467031fb2d0aa28d57d1d256373264c..0e21f5958e0143c068cc0005482efebffdba695b 100644 (file)
--- a/pattern.c
+++ b/pattern.c
@@ -190,7 +190,7 @@ msg_search (CONTEXT *ctx, pattern_t* pat, int msgno)
          return (0);
        }
 
-       fseek (msg->fp, h->offset, 0);
+       fseeko (msg->fp, h->offset, 0);
        mutt_body_handler (h->content, &s);
       }
 
@@ -206,13 +206,13 @@ msg_search (CONTEXT *ctx, pattern_t* pat, int msgno)
       fp = msg->fp;
       if (pat->op != M_BODY)
       {
-       fseek (fp, h->offset, 0);
+       fseeko (fp, h->offset, 0);
        lng = h->content->offset - h->offset;
       }
       if (pat->op != M_HEADER)
       {
        if (pat->op == M_BODY)
-         fseek (fp, h->content->offset, 0);
+         fseeko (fp, h->content->offset, 0);
        lng += h->content->length;
       }
     }
diff --git a/pgp.c b/pgp.c
index 7760f2a7e9124105825e63db399a7bfb4dd8b772..796b0e809991dc56d21695e8ee43cde4b866dc0b 100644 (file)
--- a/pgp.c
+++ b/pgp.c
@@ -247,7 +247,8 @@ int pgp_application_pgp_handler (BODY *m, STATE *s)
   int clearsign = 0, rv, rc;
   int c = 1; /* silence GCC warning */
   long start_pos = 0;
-  long bytes, last_pos, offset;
+  long bytes;
+  LOFF_T last_pos, offset;
   char buf[HUGE_STRING];
   char outfile[_POSIX_PATH_MAX];
   char tmpfname[_POSIX_PATH_MAX];
@@ -263,7 +264,7 @@ int pgp_application_pgp_handler (BODY *m, STATE *s)
 
   rc = 0;      /* silence false compiler warning if (s->flags & M_DISPLAY) */
 
-  fseek (s->fpin, m->offset, 0);
+  fseeko (s->fpin, m->offset, 0);
   last_pos = m->offset;
   
   for (bytes = m->length; bytes > 0;)
@@ -271,7 +272,7 @@ int pgp_application_pgp_handler (BODY *m, STATE *s)
     if (fgets (buf, sizeof (buf), s->fpin) == NULL)
       break;
     
-    offset = ftell (s->fpin);
+    offset = ftello (s->fpin);
     bytes -= (offset - last_pos); /* don't rely on mutt_strlen(buf) */
     last_pos = offset;
     
@@ -315,7 +316,7 @@ int pgp_application_pgp_handler (BODY *m, STATE *s)
       fputs (buf, tmpfp);
       while (bytes > 0 && fgets (buf, sizeof (buf) - 1, s->fpin) != NULL)
       {
-       offset = ftell (s->fpin);
+       offset = ftello (s->fpin);
        bytes -= (offset - last_pos); /* don't rely on mutt_strlen(buf) */
        last_pos = offset;
        
@@ -591,7 +592,7 @@ int pgp_verify_one (BODY *sigbdy, STATE *s, const char *tempfile)
     return -1;
   }
        
-  fseek (s->fpin, sigbdy->offset, 0);
+  fseeko (s->fpin, sigbdy->offset, 0);
   mutt_copy_bytes (s->fpin, fp, sigbdy->length);
   fclose (fp);
   
@@ -787,7 +788,7 @@ BODY *pgp_decrypt_part (BODY *a, STATE *s, FILE *fpout, BODY *p)
    * the temporary file.
    */
 
-  fseek (s->fpin, a->offset, 0);
+  fseeko (s->fpin, a->offset, 0);
   mutt_copy_bytes (s->fpin, pgptmp, a->length);
   fclose (pgptmp);
 
index e92eab122559aba2031f7478301b2c4c910d48fe..10e273728419b232fc07a7fbbed44b4b1c339ece 100644 (file)
@@ -68,8 +68,8 @@ static const char *pgp_hash_to_micalg (short id)
 static void pgp_dearmor (FILE *in, FILE *out)
 {
   char line[HUGE_STRING];
-  long start;
-  long end;
+  LOFF_T start;
+  LOFF_T end;
   char *r;
 
   STATE state;
@@ -105,7 +105,7 @@ static void pgp_dearmor (FILE *in, FILE *out)
   }
   
   /* actual data starts here */
-  start = ftell (in);
+  start = ftello (in);
   
   /* find the checksum */
   
@@ -120,13 +120,13 @@ static void pgp_dearmor (FILE *in, FILE *out)
     return;
   }
   
-  if ((end = ftell (in) - strlen (line)) < start)
+  if ((end = ftello (in) - strlen (line)) < start)
   {
     dprint (1, (debugfile, "pgp_dearmor: end < start???\n"));
     return;
   }
   
-  if (fseek (in, start, SEEK_SET) == -1)
+  if (fseeko (in, start, SEEK_SET) == -1)
   {
     dprint (1, (debugfile, "pgp_dearmor: Can't seekto start.\n"));
     return;
index 2b3f93340170e431cffdf96517566f10ffde0054..acf617d0e86c9532234af12b4033d6d03337e248 100644 (file)
@@ -68,12 +68,12 @@ static int read_material (size_t material, size_t * used, FILE * fp)
 unsigned char *pgp_read_packet (FILE * fp, size_t * len)
 {
   size_t used = 0;
-  long startpos;
+  LOFF_T startpos;
   unsigned char ctb;
   unsigned char b;
   size_t material;
 
-  startpos = ftell (fp);
+  startpos = ftello (fp);
 
   if (!plen)
   {
@@ -216,7 +216,7 @@ unsigned char *pgp_read_packet (FILE * fp, size_t * len)
 
 bail:
 
-  fseek (fp, startpos, SEEK_SET);
+  fseeko (fp, startpos, SEEK_SET);
   return NULL;
 }
 
index 2fae6d2984c5b36796739078049ae0a5efb6c74c..401b94c63ae877218852802ecb169f458e439b75 100644 (file)
@@ -63,8 +63,8 @@ extern int optind;
 #define FGETPOS(fp,pos) fgetpos((fp),&(pos))
 #define FSETPOS(fp,pos) fsetpos((fp),&(pos))
 #else
-#define FGETPOS(fp,pos) pos=ftell((fp));
-#define FSETPOS(fp,pos) fseek((fp),(pos),SEEK_SET)
+#define FGETPOS(fp,pos) pos=ftello((fp));
+#define FSETPOS(fp,pos) fseeko((fp),(pos),SEEK_SET)
 #endif
 
 
@@ -595,7 +595,7 @@ static pgp_key_t pgp_parse_keyblock (FILE * fp)
 #ifdef HAVE_FGETPOS
   fpos_t pos;
 #else
-  long pos;
+  LOFF_T pos;
 #endif
 
   pgp_key_t root = NULL;
@@ -752,7 +752,7 @@ static void pgpring_find_candidates (char *ringfile, const char *hints[], int nh
 #ifdef HAVE_FGETPOS
   fpos_t pos, keypos;
 #else
-  long pos, keypos;
+  LOFF_T pos, keypos;
 #endif
 
   unsigned char *buff = NULL;
diff --git a/pop.c b/pop.c
index a24734b7eeb834a1558fad438cc24c182a9b9166..20cccb4a29d650411c1bac395a1721a0be914079 100644 (file)
--- a/pop.c
+++ b/pop.c
@@ -439,7 +439,7 @@ int pop_fetch_message (MESSAGE* msg, CONTEXT* ctx, int msgno)
     fgets (buf, sizeof (buf), msg->fp);
   }
 
-  h->content->length = ftell (msg->fp) - h->content->offset;
+  h->content->length = ftello (msg->fp) - h->content->offset;
 
   /* This needs to be done in case this is a multipart message */
   if (!WithCrypto)
index ab443ad9ba564166c72e028f86b6c709c3b079b2..25f4800b709a01183a594d78ed5afd6c625c4389 100644 (file)
@@ -534,7 +534,7 @@ int mutt_prepare_template (FILE *fp, CONTEXT *ctx, HEADER *newhdr, HEADER *hdr,
 
   /* parse the message header and MIME structure */
 
-  fseek (fp, hdr->offset, 0);
+  fseeko (fp, hdr->offset, 0);
   newhdr->offset = hdr->offset;
   newhdr->env = mutt_read_rfc822_header (fp, newhdr, 1, weed);
   newhdr->content->length = hdr->content->length;
index f1fda6c23e3bf0fac64a39e1f43d7cf48e27247a..8b4340a5917505024efb9b110b2e293dcb636ad7 100644 (file)
--- a/protos.h
+++ b/protos.h
@@ -93,7 +93,7 @@ BODY *mutt_make_message_attach (CONTEXT *, HEADER *, int);
 BODY *mutt_remove_multipart (BODY *);
 BODY *mutt_make_multipart (BODY *);
 BODY *mutt_new_body (void);
-BODY *mutt_parse_multipart (FILE *, const char *, long, int);
+BODY *mutt_parse_multipart (FILE *, const char *, LOFF_T, int);
 BODY *mutt_parse_messageRFC822 (FILE *, BODY *);
 BODY *mutt_read_mime_header (FILE *, int);
 
index 5f644772658177742e0bea7e29579d7af10a4fc1..71602da10548c4cca13c70c52fa0531ef6cd6148 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -1049,7 +1049,7 @@ void mutt_message_to_7bit (BODY *a, FILE *fp)
     goto cleanup;
   }
 
-  fseek (fpin, a->offset, 0);
+  fseeko (fpin, a->offset, 0);
   a->parts = mutt_parse_messageRFC822 (fpin, a);
 
   transform_to_7bit (a->parts, fpin);
@@ -2167,7 +2167,7 @@ static int _mutt_bounce_message (FILE *fp, HEADER *h, ADDRESS *to, const char *r
     if (!option (OPTBOUNCEDELIVERED))
       ch_flags |= CH_WEED_DELIVERED;
     
-    fseek (fp, h->offset, 0);
+    fseeko (fp, h->offset, 0);
     fprintf (f, "Resent-From: %s", resent_from);
     fprintf (f, "\nResent-%s", mutt_make_date (date, sizeof(date)));
     fprintf (f, "Resent-Message-ID: %s\n", mutt_gen_msgid());
@@ -2428,7 +2428,7 @@ int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int post,
     rewind (tempfp);
     while (fgets (sasha, sizeof (sasha), tempfp) != NULL)
       lines++;
-    fprintf (msg->fp, "Content-Length: " OFF_T_FMT "\n", (LOFF_T) ftell (tempfp));
+    fprintf (msg->fp, "Content-Length: " OFF_T_FMT "\n", ftello (tempfp));
     fprintf (msg->fp, "Lines: %d\n\n", lines);
 
     /* copy the body and clean up */
diff --git a/smime.c b/smime.c
index 5667ea1066bac7f1d630eb51326553e8e67f46f3..12c0151db20870b2d825d0a5c4648504351ead2d 100644 (file)
--- a/smime.c
+++ b/smime.c
@@ -1577,7 +1577,7 @@ int smime_verify_one (BODY *sigbdy, STATE *s, const char *tempfile)
 
   mutt_decode_attachment (sigbdy, s);
 
-  sigbdy->length = ftell (s->fpout);
+  sigbdy->length = ftello (s->fpout);
   sigbdy->offset = 0;
   fclose (s->fpout);
 
@@ -1702,7 +1702,7 @@ static BODY *smime_handle_entity (BODY *m, STATE *s, FILE *outFile)
     return NULL;
   }
 
-  fseek (s->fpin, m->offset, 0);
+  fseeko (s->fpin, m->offset, 0);
   last_pos = m->offset;
 
   mutt_copy_bytes (s->fpin, tmpfp,  m->length);
@@ -1880,7 +1880,7 @@ int smime_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur)
   
   memset (&s, 0, sizeof (s));
   s.fpin = fpin;
-  fseek (s.fpin, b->offset, 0);
+  fseeko (s.fpin, b->offset, 0);
 
   mutt_mktemp (tempfile);
   if ((tmpfp = safe_fopen (tempfile, "w+")) == NULL)
@@ -1893,7 +1893,7 @@ int smime_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur)
   s.fpout = tmpfp;
   mutt_decode_attachment (b, &s);
   fflush (tmpfp);
-  b->length = ftell (s.fpout);
+  b->length = ftello (s.fpout);
   b->offset = 0;
   rewind (tmpfp);
   s.fpin = tmpfp;