X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=tfc_base64.c;h=68f0677998db07d6046e1edf8e8af87ae17711fb;hb=92b6bb91a5be9fc1b4d300f99b239cb8e3a6398d;hp=f1d68f670e9d5c380e210a5446ab79aeeecc3cc2;hpb=429747d78e7e60b3dc44fd8b23f1626c386663e0;p=tfcrypt.git diff --git a/tfc_base64.c b/tfc_base64.c index f1d68f6..68f0677 100644 --- a/tfc_base64.c +++ b/tfc_base64.c @@ -2,7 +2,7 @@ * tfcrypt -- high security Threefish encryption tool. * * tfcrypt is copyrighted: - * Copyright (C) 2012-2018 Andrey Rys. All rights reserved. + * Copyright (C) 2012-2019 Andrey Rys. All rights reserved. * * tfcrypt is licensed to you under the terms of std. MIT/X11 license: * @@ -28,12 +28,16 @@ #include "tfcrypt.h" +enum { TFB64_STOP1 = 1, TFB64_STOPF }; + void do_edbase64(char **fargv) { struct base64_decodestate dstate; struct base64_encodestate estate; size_t lread = 0; + xexit_no_nl = YES; + sfd = 0; dfd = 1; if (fargv[0]) { @@ -70,7 +74,7 @@ void do_edbase64(char **fargv) ldone = 0; if (error_action == TFC_ERRACT_SYNC) rdpos = tfc_fdgetpos(sfd); _again: lio = xread(sfd, pblk, lrem); - if (lio == 0) do_stop = YES; + if (lio == 0) do_stop = TFB64_STOP1; if (lio != NOSIZE) ldone += lio; else { if (errno != EIO && catch_all_errors != YES) @@ -108,7 +112,7 @@ _again: lio = xread(sfd, pblk, lrem); pblk = dstblk; if (ldone == 0) { - do_stop = TFC_STOP_FULL; + do_stop = TFB64_STOPF; break; } lrem = ldone; @@ -118,7 +122,7 @@ _wagain: lio = xwrite(dfd, pblk, lrem); else xerror(NO, NO, NO, "%s", fargv[1]); if (do_edcrypt == TFC_DO_ENCRYPT) { size_t t; - if (lread >= lblock || do_stop == TFC_STOP_FULL) { + if (lread >= lblock || do_stop == TFB64_STOPF) { t = xwrite(dfd, "\n", 1); if (t != NOSIZE) lio += t; else lio = NOSIZE; @@ -134,19 +138,18 @@ _wagain: lio = xwrite(dfd, pblk, lrem); } } - if (do_edcrypt == TFC_DO_ENCRYPT && do_stop == TFC_STOP_BEGAN) { + if (do_edcrypt == TFC_DO_ENCRYPT && do_stop == TFB64_STOP1) { size_t t = estate.count; pblk = dstblk + estate.count; base64_encode_blockend((char *)dstblk, &estate); lrem = estate.count - t; ldone = 0; - do_stop = TFC_STOP_FULL; + do_stop = TFB64_STOPF; goto _wagain; } memset(&estate, 0, sizeof(struct base64_encodestate)); memset(&dstate, 0, sizeof(struct base64_decodestate)); - if (do_preserve_time) fcopy_matime(dfd, &s_stat); xexit(0); }