summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
8cd9f01)
The chunks are written with a 16-bit length, so the maximum chunk size
is 2^16 - 1 = 65535. Unfortunately, catsign tried to write 65536-byte
chunks, and catcrypt tried to cram a MAC tag in there too. The result
is that chunk_write fails an assertion because the chunks are too big.
No idea why this ever worked before.
const char *err;
int i;
int en;
const char *err;
int i;
int en;
dstr d = DSTR_INIT;
octet *tag, *ct;
buf b;
dstr d = DSTR_INIT;
octet *tag, *ct;
buf b;
assert(GC_CLASS(c)->blksz <= sizeof(bb));
dstr_ensure(&d, sizeof(bb) + GM_CLASS(m)->hashsz);
seq = 0;
assert(GC_CLASS(c)->blksz <= sizeof(bb));
dstr_ensure(&d, sizeof(bb) + GM_CLASS(m)->hashsz);
seq = 0;
+ chsz = MASK16 - GM_CLASS(m)->hashsz;
for (;;) {
h = GM_INIT(m);
GH_HASHU32(h, seq);
for (;;) {
h = GM_INIT(m);
GH_HASHU32(h, seq);
GC_ENCRYPT(cx, 0, bb, GC_CLASS(c)->blksz);
GC_SETIV(c, bb);
}
GC_ENCRYPT(cx, 0, bb, GC_CLASS(c)->blksz);
GC_SETIV(c, bb);
}
- n = fread(bb, 1, sizeof(bb), fp);
+ n = fread(bb, 1, chsz, fp);
if (!n) break;
buf_init(&b, d.buf, d.sz);
tag = buf_get(&b, GM_CLASS(m)->hashsz);
if (!n) break;
buf_init(&b, d.buf, d.sz);
tag = buf_get(&b, GM_CLASS(m)->hashsz);
static size_t binreadembed(msgcanon *m, void *bp)
{ return (chunk_read(m->e, bp)); }
static size_t binreaddetach(msgcanon *m, void *bp)
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); }
static void binwriteembed(msgcanon *m, const void *bp, size_t n)
{ chunk_write(m->e, bp, n); }