Update upstream source from tag 'upstream/1.9'
Update to upstream version '1.9'
with Debian dir 17f8173afae9645be82dd83a13a06295e25e6cdc
Joao Eriberto Mota Filho
1 year, 2 months ago
0 | 2023-02-08 Joao Eriberto Mota Filho <eriberto@eriberto.pro.br> | |
1 | Version 1.9 | |
2 | ||
3 | [ Tibor Szolnoki ] | |
4 | ||
5 | * Added support for writing to output only if destination block content | |
6 | differs ('diffwr' option). | |
7 | ||
8 | [ David Polverari ] | |
9 | ||
10 | * Added bash completion for diffwr. | |
11 | * Minor fixes in manpage and help. | |
12 | * Minor optimizations in source code. | |
13 | ||
0 | 14 | 2022-10-17 Joao Eriberto Mota Filho <eriberto@eriberto.pro.br> |
1 | 15 | Version 1.8 |
2 | 16 |
20 | 20 | |
21 | 21 | AC_PREREQ([2.69]) |
22 | 22 | |
23 | AC_INIT([dcfldd],[1.8],[https://github.com/resurrecting-open-source-projects/dcfldd/issues]) | |
23 | AC_INIT([dcfldd],[1.9],[https://github.com/resurrecting-open-source-projects/dcfldd/issues]) | |
24 | 24 | AC_CONFIG_SRCDIR(src/dcfldd.c) |
25 | 25 | AM_INIT_AUTOMAKE |
26 | 26 |
0 | 0 | # bash completion for dcfldd -*- shell-script -*- |
1 | 1 | # Copyright 2017-2020 Joao Eriberto Mota Filho <eriberto@debian.org> |
2 | # Copyright 2022 David Polverari <david.polverari@gmail.com> | |
2 | 3 | # Version: 20200113 |
3 | 4 | # Based in dd completion script. |
4 | 5 | |
40 | 41 | COMPREPLY=( $( compgen -W 'if of' -- "$cur" ) ) |
41 | 42 | return 0 |
42 | 43 | ;; |
44 | diffwr=*) | |
45 | cur=${cur#*=} | |
46 | COMPREPLY=( $( compgen -W 'on off' -- "$cur") ) | |
47 | return 0 | |
48 | ;; | |
43 | 49 | esac |
44 | 50 | |
45 | 51 | _expand || return 0 |
49 | 55 | textpattern errlog hash md5log sha1log sha256log sha384log |
50 | 56 | sha512log hashwindow hashconv hashformat totalhashformat |
51 | 57 | status statusinterval sizeprobe split splitformat vf |
52 | verifylog' -S '=' -- "$cur" ) ) | |
58 | verifylog diffwr' -S '=' -- "$cur" ) ) | |
53 | 59 | } && |
54 | 60 | complete -F _dcfldd -o nospace dcfldd |
15 | 15 | #-------------------------------------------------------- |
16 | 16 | |
17 | 17 | # Put here all data for your first manpage (in T2M lines) |
18 | T2M_DATE="17 Oct 2022" | |
18 | T2M_DATE="08 Feb 2023" | |
19 | 19 | T2M_NAME=dcfldd |
20 | T2M_VERSION=1.8 | |
20 | T2M_VERSION=1.9 | |
21 | 21 | T2M_LEVEL=1 |
22 | 22 | T2M_DESC="enhanced version of dd for forensics and security" |
23 | 23 | create-man |
0 | 0 | .\" Text automatically generated by txt2man |
1 | .TH dcfldd 1 "17 Oct 2022" "dcfldd-1.8" "enhanced version of dd for forensics and security" | |
1 | .TH dcfldd 1 "08 Feb 2023" "dcfldd-1.9" "enhanced version of dd for forensics and security" | |
2 | 2 | .SH NAME |
3 | 3 | \fBdcfldd \fP- enhanced version of dd for forensics and security |
4 | 4 | \fB |
206 | 206 | Exec and write verify results to process COMMAND. |
207 | 207 | .TP |
208 | 208 | .B |
209 | diffwr=[on|off] | |
210 | Only write to output if destination block content differs. This operation applies | |
211 | to any of=FILE that follows (diffwr= must be put before any of=). | |
212 | .TP | |
213 | .B | |
209 | 214 | \fB--help\fP |
210 | 215 | Display a help page and exit. |
211 | 216 | .TP |
96 | 96 | vf=FILE Verify that FILE matches the specified input. |
97 | 97 | verifylog=FILE Send verify results to FILE instead of stderr. |
98 | 98 | verifylog:=COMMAND Exec and write verify results to process COMMAND. |
99 | diffwr=[on|off] Only write to output if destination block content differs. This operation applies | |
100 | to any of=FILE that follows (diffwr= must be put before any of=). | |
99 | 101 | --help Display a help page and exit. |
100 | 102 | --version Output version information and exit. |
101 | 103 |
6 | 6 | Copyright 2008 David Loveall <dave@loveall.org> |
7 | 7 | Copyright 2012 Miah Gregory <mace@debian.org> |
8 | 8 | Copyright 2014 Vangelis Koukis <vkoukis@gmail.com> |
9 | Copyright 2022 David Polverari <david.polverari@gmail.com> | |
10 | Copyright 2022 Tibor Szolnoki <szolnoki.tibor@gmail.com> | |
9 | 11 | |
10 | 12 | This program is free software; you can redistribute it and/or modify |
11 | 13 | it under the terms of the GNU General Public License as published by |
132 | 134 | int do_hash = 0; |
133 | 135 | int do_verify = 0; |
134 | 136 | int do_split = 0; |
137 | int do_diffwr = 0; | |
135 | 138 | |
136 | 139 | hashconv_t hashconv = DEFAULT_HASHCONV; |
137 | 140 | |
201 | 204 | vf=FILE verify that FILE matches the specified input\n\ |
202 | 205 | verifylog=FILE send verify results to FILE instead of stderr\n\ |
203 | 206 | verifylog:=COMMAND exec and write verify results to process COMMAND\n\ |
207 | diffwr=[on|off] only write to output if destination block content differs\n\ | |
204 | 208 | \n\ |
205 | 209 | --help display this help and exit\n\ |
206 | 210 | --version output version information and exit\n\ |
578 | 582 | if (invalid) |
579 | 583 | probe = PROBE_NONE; |
580 | 584 | } |
585 | } else if (STREQ(name, "diffwr")) { | |
586 | if (STREQ(val, "off")) | |
587 | do_diffwr = 0; | |
588 | else if (STREQ(val, "on")) | |
589 | do_diffwr = 1; | |
581 | 590 | } else { |
582 | 591 | int invalid = 0; |
583 | 592 | uintmax_t n = parse_integer(val, &invalid); |
5 | 5 | /* Copyright 85, 90, 91, 1995-2001, 2005 Free Software Foundation, Inc. |
6 | 6 | Copyright 2008 David Loveall <dave@loveall.org> |
7 | 7 | Copyright 2017-2019 Joao Eriberto Mota Filho <eriberto@eriberto.pro.br> |
8 | Copyright 2022 Tibor Szolnoki <szolnoki.tibor@gmail.com> | |
8 | 9 | |
9 | 10 | This program is free software; you can redistribute it and/or modify |
10 | 11 | it under the terms of the GNU General Public License as published by |
143 | 144 | extern int do_hash; |
144 | 145 | extern int do_verify; |
145 | 146 | extern int do_status; |
147 | extern int do_diffwr; | |
146 | 148 | |
147 | 149 | extern int char_is_saved; |
148 | 150 | extern unsigned char saved_char; |
0 | 0 | /* full-write.c -- an interface to write that retries after interrupts |
1 | Copyright (C) 1993, 1994, 1997, 1998, 2000 Free Software Foundation, Inc. | |
1 | Copyright 1993, 1994, 1997, 1998, 2000 Free Software Foundation, Inc. | |
2 | Copyright 2022 David Polverari <david.polverari@gmail.com> | |
3 | Copyright 2022 Tibor Szolnoki <szolnoki.tibor@gmail.com> | |
2 | 4 | |
3 | 5 | This program is free software; you can redistribute it and/or modify |
4 | 6 | it under the terms of the GNU General Public License as published by |
24 | 26 | #endif |
25 | 27 | |
26 | 28 | #include <sys/types.h> |
29 | #include "safe-read.h" | |
27 | 30 | |
28 | 31 | #if HAVE_UNISTD_H |
29 | 32 | # include <unistd.h> |
38 | 41 | Return LEN upon success, write's (negative) error code otherwise. */ |
39 | 42 | |
40 | 43 | int |
41 | full_write (int desc, const char *ptr, size_t len) | |
44 | full_write (int desc, const char *ptr, size_t len, int diffwr) | |
42 | 45 | { |
43 | 46 | int total_written; |
44 | 47 | |
45 | 48 | total_written = 0; |
46 | 49 | while (len > 0) |
47 | 50 | { |
48 | int written = write (desc, ptr, len); | |
51 | int written = 0; | |
52 | if (diffwr) { /* Check destination block content is same as the buffer */ | |
53 | char *rptr = NULL; | |
54 | off_t pos = lseek(desc, 0, SEEK_CUR); | |
55 | if ((pos >= 0) && (rptr = malloc(len))) { | |
56 | int rlen = safe_read(desc, rptr, len); | |
57 | if ((rlen <= 0) || (rlen != len) || (memcmp(rptr, ptr, len))) { | |
58 | free(rptr); | |
59 | lseek(desc, pos, SEEK_SET); | |
60 | } else { | |
61 | written = len; | |
62 | } | |
63 | } | |
64 | } | |
65 | if (written <= 0) { | |
66 | written = write (desc, ptr, len); | |
67 | } | |
49 | 68 | /* write on an old Slackware Linux 1.2.13 returns zero when |
50 | 69 | I try to write more data than there is room on a floppy disk. |
51 | 70 | This puts dd into an infinite loop. Reproduce with |
2 | 2 | * By Nicholas Harbour |
3 | 3 | */ |
4 | 4 | |
5 | /* Copyright (C) 85, 90, 91, 1995-2001, 2005 Free Software Foundation, Inc. | |
5 | /* Copyright 85, 90, 91, 1995-2001, 2005 Free Software Foundation, Inc. | |
6 | Copyright 2022 Tibor Szolnoki <szolnoki.tibor@gmail.com> | |
6 | 7 | |
7 | 8 | This program is free software; you can redistribute it and/or modify |
8 | 9 | it under the terms of the GNU General Public License as published by |
23 | 24 | #ifndef FULL_WRITE_H |
24 | 25 | #define FULL_WRITE_H |
25 | 26 | |
26 | int full_write(int, const char *, size_t); | |
27 | int full_write(int, const char *, size_t, int diffwr); | |
27 | 28 | |
28 | 29 | #endif /* FULL_WRITE_H */ |
4 | 4 | |
5 | 5 | /* Copyright 85, 90, 91, 1995-2001, 2005 Free Software Foundation, Inc. |
6 | 6 | Copyright 2008 David Loveall <dave@loveall.org> |
7 | Copyright 2022 Tibor Szolnoki <szolnoki.tibor@gmail.com> | |
7 | 8 | |
8 | 9 | This program is free software; you can redistribute it and/or modify |
9 | 10 | it under the terms of the GNU General Public License as published by |
44 | 45 | int fd; |
45 | 46 | int opts |
46 | 47 | = (O_CREAT |
47 | | (seek_records || (conversions_mask & C_NOTRUNC) ? 0 : O_TRUNC)); | |
48 | | ((seek_records || do_diffwr || (conversions_mask & C_NOTRUNC)) ? 0 : O_TRUNC)); | |
48 | 49 | |
49 | 50 | /* Open the output file with *read* access only if we might |
50 | need to read to satisfy a `seek=' request. If we can't read | |
51 | need to read to satisfy a `seek=' or "diffwr=on" request. If we can't read | |
51 | 52 | the file, go ahead with write-only access; it might work. */ |
52 | if ((! seek_records | |
53 | if ((! (seek_records || do_diffwr) | |
53 | 54 | || (fd = open(filename, O_RDWR | opts, perms)) < 0) |
54 | 55 | && (fd = open(filename, O_WRONLY | opts, perms)) < 0) |
55 | 56 | { |
120 | 121 | |
121 | 122 | ptr->next = NULL; |
122 | 123 | ptr->type = type; |
124 | ptr->diffwr = do_diffwr; | |
123 | 125 | |
124 | 126 | switch (type) { |
125 | 127 | case SINGLE_FILE: |
129 | 131 | ptr->type = SINGLE_FILE; |
130 | 132 | ptr->stream = va_arg(ap, FILE *); |
131 | 133 | ptr->data.fd = fileno(ptr->stream); |
134 | ptr->diffwr = 0; | |
132 | 135 | break; |
133 | 136 | case SPLIT_FILE: |
134 | 137 | split = malloc(sizeof *split); |
154 | 157 | nwritten = 0; |
155 | 158 | switch (ptr->type) { |
156 | 159 | case SINGLE_FILE: |
157 | nwritten = full_write(ptr->data.fd, buf, len); | |
160 | nwritten = full_write(ptr->data.fd, buf, len, ptr->diffwr); | |
158 | 161 | break; |
159 | 162 | case SPLIT_FILE: |
160 | nwritten = split_write(ptr->data.split, buf, len); | |
163 | nwritten = split_write(ptr->data.split, buf, len, ptr->diffwr); | |
161 | 164 | break; |
162 | 165 | } |
163 | 166 | if (nwritten < len) |
4 | 4 | |
5 | 5 | /* Copyright 85, 90, 91, 1995-2001, 2005 Free Software Foundation, Inc. |
6 | 6 | Copyright 2008 David Loveall <dave@loveall.org> |
7 | Copyright 2022 Tibor Szolnoki <szolnoki.tibor@gmail.com> | |
7 | 8 | |
8 | 9 | This program is free software; you can redistribute it and/or modify |
9 | 10 | it under the terms of the GNU General Public License as published by |
45 | 46 | int fd; |
46 | 47 | split_t *split; |
47 | 48 | } data; |
49 | int diffwr; | |
48 | 50 | } outputlist_t; |
49 | 51 | |
50 | 52 | extern outputlist_t *outputlist; |
6 | 6 | Copyright 2012 Miah Gregory <mace@debian.org> |
7 | 7 | Copyright 2015-2019 Joao Eriberto Mota Filho <eriberto@eriberto.pro.br> |
8 | 8 | Copyright 2019 Bernhard Übelacker <bernhardu@mailbox.org> |
9 | Copyright 2022 Tibor Szolnoki <szolnoki.tibor@gmail.com> | |
9 | 10 | |
10 | 11 | This program is free software; you can redistribute it and/or modify |
11 | 12 | it under the terms of the GNU General Public License as published by |
139 | 140 | free(fname); |
140 | 141 | } |
141 | 142 | |
142 | int split_write(split_t *split, const char *buf, size_t len) | |
143 | int split_write(split_t *split, const char *buf, size_t len, int diffwr) | |
143 | 144 | { |
144 | 145 | off_t left = split->max_bytes - split->curr_bytes; |
145 | 146 | int nwritten = 0; |
150 | 151 | } |
151 | 152 | |
152 | 153 | if (len <= left) { |
153 | nwritten = full_write(split->currfd, buf, len); | |
154 | nwritten = full_write(split->currfd, buf, len, diffwr); | |
154 | 155 | split->total_bytes += nwritten; |
155 | 156 | split->curr_bytes += nwritten; |
156 | 157 | } else { |
157 | nwritten = full_write(split->currfd, buf, left); | |
158 | nwritten = full_write(split->currfd, buf, left, diffwr); | |
158 | 159 | split->total_bytes += nwritten; |
159 | 160 | split->curr_bytes += nwritten; |
160 | nwritten += split_write(split, &buf[nwritten], len - nwritten); | |
161 | nwritten += split_write(split, &buf[nwritten], len - nwritten, diffwr); | |
161 | 162 | } |
162 | 163 | |
163 | 164 | return nwritten; |
1 | 1 | * dcfldd - The Enhanced Forensic DD |
2 | 2 | * By Nicholas Harbour |
3 | 3 | */ |
4 | /* Copyright (C) 85, 90, 91, 1995-2001, 2005 Free Software Foundation, Inc. | |
4 | /* Copyright 85, 90, 91, 1995-2001, 2005 Free Software Foundation, Inc. | |
5 | Copyright 2022 Tibor Szolnoki <szolnoki.tibor@gmail.com> | |
5 | 6 | |
6 | 7 | This program is free software; you can redistribute it and/or modify |
7 | 8 | it under the terms of the GNU General Public License as published by |
35 | 36 | char *format; |
36 | 37 | } split_t; |
37 | 38 | |
38 | extern int split_write(split_t *, const char *, size_t); | |
39 | extern int split_write(split_t *, const char *, size_t, int diffwr); | |
39 | 40 | |
40 | 41 | #endif /* SPLIT_H */ |