mirror of
https://git.code.sf.net/p/ntfs-3g/ntfs-3g.git
synced 2024-11-23 10:04:00 +08:00
Fixed computing the replacement bytes in ntfswipe
The computing of replacement bytes for overwriting undeletable files uses random values and standard ones instead of the values provided in option --bytes. Fix the mixup between both logics, mention the difference in the documentation and reject defining both options --bytes and --undel.
This commit is contained in:
parent
b11a5ea91b
commit
79ea3b49b1
@ -35,7 +35,9 @@ the unused space. BYTE-LIST is a comma-separated list of values in
|
||||
range 0-255 expressed in octal, decimal or hexadecimal base.
|
||||
.TP
|
||||
\fB\-c\fR, \fB\-\-count\fR NUM
|
||||
Define the number of times the unused space is to be overwritten.
|
||||
Define the number of times the unused space is to be overwritten. If both
|
||||
options \fB\-\-bytes\fR and \fB\-\-count\fR are set, the space is
|
||||
repeatedly overwritten this number of times by each of the values in the list.
|
||||
.TP
|
||||
\fB\-d\fR, \fB\-\-directory\fR
|
||||
Wipe all the directory indexes, which may contain names of deleted files.
|
||||
@ -68,7 +70,9 @@ Suppress some debug/warning/error messages.
|
||||
.TP
|
||||
\fB\-s\fR, \fB\-\-undel\fR
|
||||
Overwrite the space which had been allocated to a file which has been deleted
|
||||
recently and is still undeletable.
|
||||
recently and is still undeletable. This option is not compatible with
|
||||
\fB\-\-bytes\fR and the replacement bytes are random ones or taken from a
|
||||
standard list.
|
||||
.TP
|
||||
\fB\-t\fR, \fB\-\-tails\fR
|
||||
Overwrite the space at the end of files which is unused, but allocated
|
||||
|
@ -403,6 +403,10 @@ static int parse_options(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (opts.bytes && opts.undel) {
|
||||
ntfs_log_error("Options --bytes and --undel are not compatible.\n");
|
||||
err++;
|
||||
}
|
||||
/* Make sure we're in sync with the log levels */
|
||||
levels = ntfs_log_get_levels();
|
||||
if (levels & NTFS_LOG_LEVEL_VERBOSE)
|
||||
@ -1661,12 +1665,12 @@ static void fill_buffer (
|
||||
/* For other passes, one of the fixed patterns is selected. */
|
||||
do {
|
||||
#if (!defined __STRICT_ANSI__) && (defined HAVE_RANDOM)
|
||||
i = (size_t)(random() % NPAT);
|
||||
i = (size_t)random() % NPAT;
|
||||
#else
|
||||
i = (size_t)(rand() % NPAT);
|
||||
i = (size_t)rand() % NPAT;
|
||||
#endif
|
||||
} while (selected[i] == 1);
|
||||
bits = opts.bytes[i];
|
||||
bits = patterns[i];
|
||||
selected[i] = 1;
|
||||
}
|
||||
|
||||
@ -2123,6 +2127,9 @@ static void print_summary(void)
|
||||
ntfs_log_quiet("0x%02x ", opts.bytes[i]);
|
||||
}
|
||||
ntfs_log_quiet("\n");
|
||||
if (opts.undel)
|
||||
ntfs_log_quiet("(however undelete data will be overwritten"
|
||||
" by random values)\n");
|
||||
|
||||
if (opts.count > 1)
|
||||
ntfs_log_quiet("%s will repeat these operations %d times.\n", EXEC_NAME, opts.count);
|
||||
|
Loading…
Reference in New Issue
Block a user