catcrypt.c, catsign.c: Shorten chunk sizes.
[u/mdw/catacomb] / catsign.c
index 727c980..8171404 100644 (file)
--- a/catsign.c
+++ b/catsign.c
@@ -7,7 +7,7 @@
  * (c) 2005 Straylight/Edgeware
  */
 
-/*----- Licensing notice --------------------------------------------------* 
+/*----- Licensing notice --------------------------------------------------*
  *
  * This file is part of Catacomb.
  *
  * it under the terms of the GNU Library General Public License as
  * published by the Free Software Foundation; either version 2 of the
  * License, or (at your option) any later version.
- * 
+ *
  * Catacomb is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU Library General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Library General Public
  * License along with Catacomb; if not, write to the Free
  * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
@@ -199,7 +199,7 @@ static void textwrite(msgcanon *m, const void *bp, size_t n)
 static size_t binreadembed(msgcanon *m, void *bp)
   { return (chunk_read(m->e, bp)); }
 static size_t binreaddetach(msgcanon *m, void *bp)
-  { return (fread(bp, 1, MSGBUFSZ, m->fp)); }
+  { return (fread(bp, 1, MSGBUFSZ - 1, m->fp)); }
 
 static void binwriteembed(msgcanon *m, const void *bp, size_t n)
   { chunk_write(m->e, bp, n); }
@@ -292,7 +292,7 @@ static void mc_endread(msgcanon *m, const encops *eops, enc **ee)
   if (m->fp && !(m->f & F_NOCLOSE)) {
     if (ferror(m->fp) || fclose(m->fp))
       die(EXIT_FAILURE, "error closing message file: %s", strerror(errno));
-  }    
+  }
 }
 
 static void mc_endwrite(msgcanon *m, const encops *eops, enc **ee)
@@ -310,7 +310,7 @@ static void mc_endwrite(msgcanon *m, const encops *eops, enc **ee)
   if (m->fp && !(m->f & F_NOCLOSE)) {
     if (fflush(m->fp) || ferror(m->fp) || fclose(m->fp))
       die(EXIT_FAILURE, "error closing message file: %s", strerror(errno));
-  }    
+  }
 }
 
 /*----- Signature reading and writing -------------------------------------*/
@@ -439,7 +439,7 @@ static int sign(int argc, char *argv[])
   int i;
   char bb[MSGBUFSZ];
   size_t n;
-  dstr d = DSTR_INIT;  
+  dstr d = DSTR_INIT;
   const encops *eo;
   msgcanon mc_in = MC_INIT, mc_out = MC_INIT;
   enc *e;
@@ -618,7 +618,7 @@ static int verify(int argc, char *argv[])
       case 'C': v.f |= F_NOCHECK; break;
       case 't':
        if (strcmp(optarg, "always") == 0) t_fresh = 0;
-        else if ((t_fresh = get_date(optarg, 0)) < 0)
+       else if ((t_fresh = get_date(optarg, 0)) < 0)
          die(EXIT_FAILURE, "bad freshness time");
        break;
       case 'q': if (v.verb > 0) v.verb--; break;
@@ -684,7 +684,7 @@ static int verify(int argc, char *argv[])
   if (dd.len != s.kh.len || memcmp(dd.buf, s.kh.buf, dd.len) != 0) {
     if (v.verb) printf("FAIL key hash mismatch\n");
     exit(EXIT_FAILURE);
-  }    
+  }
 
   /* --- Now a merry dance --- */
 
@@ -767,7 +767,7 @@ static int verify(int argc, char *argv[])
       die(EXIT_FAILURE, "error unbuffering output: %s", strerror(errno));
   }
   if (ofp && (fflush(ofp) || ferror(ofp) || fclose(ofp)))
-      die(EXIT_FAILURE, "error writing output: %s", strerror(errno));    
+      die(EXIT_FAILURE, "error writing output: %s", strerror(errno));
 
   /* --- Tidy up --- */
 
@@ -779,7 +779,7 @@ static int verify(int argc, char *argv[])
   sig_destroy(&s);
   dstr_destroy(&d);
   dstr_destroy(&dd);
-  return (0);  
+  return (0);
 }
 
 /*----- Reformatting ------------------------------------------------------*/
@@ -809,8 +809,8 @@ static int format(int argc, char *argv[])
       { "embed",       0,              0,      'E' },
       { "format-in",   OPTF_ARGREQ,    0,      'f' },
       { "format-out",  OPTF_ARGREQ,    0,      'F' },
-      { "message",     OPTF_ARGREQ,    0,      'm' },
-      { "output",      OPTF_ARGREQ,    0,      'o' },
+      { "message",     OPTF_ARGREQ,    0,      'm' },
+      { "output",      OPTF_ARGREQ,    0,      'o' },
       { 0,             0,              0,      0 }
     };
     i = mdwopt(argc, argv, "f:F:m:o:aADE", opt, 0, 0, 0);
@@ -858,7 +858,7 @@ static int format(int argc, char *argv[])
 
   if (((s.f ^ v.f) & v.m) != 0)
     moan("boundary string inconsistent with contents (ignoring)");
-  
+
   mcsetup_read(&mc_in, s.f, &ie, dfn);
 
   /* --- Prepare the output stuff --- */