uudecode: fix flushing in corner case

This commit is contained in:
Tai Chi Minh Ralph Eastwood 2015-02-10 19:36:34 +00:00 committed by sin
parent ec02816d3e
commit 6d2cbf7a3f

View File

@ -173,16 +173,16 @@ uudecodeb64(FILE *fp, FILE *outfp)
if (++t < 4) if (++t < 4)
continue; continue;
else else
return; goto flush;
} else if (b == 1) { } else if (b == 1) {
eprintf("unexpected \"=\" appeared."); eprintf("unexpected \"=\" appeared.");
} else if (b == 2) { } else if (b == 2) {
*po++ = b24[0]; *po++ = b24[0];
fwrite(out, 1, (po - out), outfp); goto flush;
} else if (b == 3) { } else if (b == 3) {
*po++ = b24[0]; *po++ = b24[0];
*po++ = b24[1]; *po++ = b24[1];
fwrite(out, 1, (po - out), outfp); goto flush;
} }
} }
if ((e = b64dt[(int)*pb]) == -1) { if ((e = b64dt[(int)*pb]) == -1) {
@ -205,9 +205,11 @@ uudecodeb64(FILE *fp, FILE *outfp)
b = 0; b = 0;
} }
} }
fwrite(out, 1, (po - out), outfp); goto flush;
} }
eprintf("invalid uudecode footer \"====\" not found\n"); eprintf("invalid uudecode footer \"====\" not found\n");
flush:
fwrite(out, 1, (po - out), outfp);
} }
static void static void