mirror of
https://git.disroot.org/80486DX2-66/polonium.git
synced 2024-12-27 23:50:29 +05:30
Merge branch 'main' into load_into_mem
This commit is contained in:
commit
6a4104b3d9
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
**Project status:** :warning: Work In Progress
|
**Project status:** :warning: Work In Progress
|
||||||
|
|
||||||
**Polonium** is a deliberate file corrupter simulating Polonium radiation,
|
**Polonium** is a deliberate file corrupter simulating polonium radiation,
|
||||||
damaging files as if bits of file are exposed to it. It modifies file contents,
|
damaging files as if bits of file are exposed to it. It modifies file contents,
|
||||||
causing degradation or information loss by bit flipping. Written in ISO C99.
|
causing degradation or information loss by bit flipping. Written in ISO C99.
|
||||||
|
|
||||||
|
@ -12,19 +12,13 @@ static bool get_chance(uint16_t desired_chance) {
|
|||||||
if (desired_chance == UINT16_MAX)
|
if (desired_chance == UINT16_MAX)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
uint16_t cdf[UINT16_MAX_PLUS_1];
|
|
||||||
memset(cdf, 0, sizeof(cdf));
|
|
||||||
|
|
||||||
for (uint16_t i = 0; i < UINT16_MAX; i++)
|
|
||||||
cdf[i] = (i <= desired_chance) ? i + 1 : cdf[i - 1];
|
|
||||||
|
|
||||||
uint16_t random_number = mt_next() & UINT16_MAX;
|
uint16_t random_number = mt_next() & UINT16_MAX;
|
||||||
|
|
||||||
return random_number < cdf[desired_chance];
|
return random_number < desired_chance;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool is_line_ending(byte c) {
|
static bool is_line_ending(byte c) {
|
||||||
return (c == '\n' || c == '\r');
|
return c == '\n' || c == '\r';
|
||||||
}
|
}
|
||||||
|
|
||||||
Corrupter_Result* corrupt_file(Corrupter_Param* param) {
|
Corrupter_Result* corrupt_file(Corrupter_Param* param) {
|
||||||
|
@ -96,7 +96,7 @@ static char* correct_slashes(const char* path) {
|
|||||||
|
|
||||||
static char* my_basename(const char* raw_path) {
|
static char* my_basename(const char* raw_path) {
|
||||||
char* path =
|
char* path =
|
||||||
#ifdef SYSNT
|
#ifdef SYS_NT
|
||||||
correct_slashes
|
correct_slashes
|
||||||
#else
|
#else
|
||||||
strdup
|
strdup
|
||||||
|
Loading…
Reference in New Issue
Block a user