X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=tfcrypt.c;h=363e3c4825c8735dcae93c7e10cf338fbcb49056;hb=630fb7d8dc740715cdc52114d736d64bf14f0798;hp=8608cf16011399202e66f08b8855211c6368a56e;hpb=429747d78e7e60b3dc44fd8b23f1626c386663e0;p=tfcrypt.git diff --git a/tfcrypt.c b/tfcrypt.c index 8608cf1..363e3c4 100644 --- a/tfcrypt.c +++ b/tfcrypt.c @@ -171,6 +171,10 @@ int main(int argc, char **argv) catch_all_errors = YES; break; } + if (!strcmp(optarg, "xseek")) { + ignore_seek_errors = YES; + break; + } if (!strcmp(optarg, "exit")) error_action = TFC_ERRACT_EXIT; else if (!strncmp(optarg, "cont", 4)) @@ -328,13 +332,25 @@ int main(int argc, char **argv) s += 5; maxkeylen = tfc_humanfsize(s, &stoi); if (!str_empty(stoi)) { - maxkeylen = (size_t)tfc_fnamesize(s, YES); - maxkeylen = (size_t)tfc_modifysize((tfc_fsize)maxkeylen, strchr(s, ':')); + maxkeylen = tfc_fnamesize(s, YES); + maxkeylen = tfc_modifysize(maxkeylen, strchr(s, ':')); if (maxkeylen == NOSIZE) xerror(NO, YES, YES, "%s: invalid key length value", s); } - else maxkeylen = (size_t)tfc_modifysize((tfc_fsize)maxkeylen, strchr(s, ':')); + else maxkeylen = tfc_modifysize(maxkeylen, strchr(s, ':')); + } + else if (!strncmp(s, "okey", 4) && *(s+4) == '=') { + s += 5; + keyoffset = tfc_humanfsize(s, &stoi); + if (!str_empty(stoi)) { + keyoffset = tfc_fnamesize(s, YES); + keyoffset = tfc_modifysize(keyoffset, strchr(s, ':')); + if (keyoffset == NOFSIZE) + xerror(NO, YES, YES, + "%s: invalid key offset value", s); + } + else keyoffset = tfc_modifysize(keyoffset, strchr(s, ':')); } else if (!strncmp(s, "xctr", 4) && *(s+4) == '=') { s += 5; @@ -683,7 +699,7 @@ _ctrskip1: if (counter_opt == TFC_CTR_HEAD && ctr_mode != TFC_MODE_ECB) iseek += ctrsz; if (lseek(sfd, iseek, SEEK_SET) == -1) - xerror(YES, NO, NO, "%s: seek failed", srcfname); + xerror(ignore_seek_errors, NO, NO, "%s: seek failed", srcfname); } if (ctr_mode == TFC_MODE_PLAIN) goto _plain; @@ -814,7 +830,7 @@ _pwdagain: memset(&getps, 0, sizeof(struct getpasswd_state)); memset(pwdagain, 0, sizeof(pwdagain)); } else { - if (skeinfd(key, TFC_KEY_BITS, mackey_opt ? mackey : NULL, kfd, maxkeylen) != YES) + if (skeinfd(key, TFC_KEY_BITS, mackey_opt ? mackey : NULL, kfd, keyoffset, maxkeylen) != YES) xerror(NO, NO, YES, "hashing key"); } @@ -926,7 +942,7 @@ _plain: if (oseek) { if (lseek(dfd, oseek, SEEK_SET) == -1) - xerror(YES, NO, NO, "%s: seek failed", dstfname); + xerror(ignore_seek_errors, NO, NO, "%s: seek failed", dstfname); } for (x = 1; x < NSIG; x++) signal(x, SIG_IGN);