Skip to content

Commit

Permalink
add breach mitigation
Browse files Browse the repository at this point in the history
  • Loading branch information
guzba committed May 1, 2023
1 parent 3b863db commit 955d0b6
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/zippy.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import zippy/adler32, zippy/common, zippy/crc, zippy/deflate, zippy/gzip,
zippy/inflate, zippy/internal
import std/random, std/times, zippy/adler32, zippy/common, zippy/crc, zippy/deflate,
zippy/gzip, zippy/inflate, zippy/internal

export common

Expand All @@ -18,6 +18,15 @@ proc compress*(
result[0] = 31.char
result[1] = 139.char
result[2] = 8.char
result[3] = (1.uint8 shl 3).char

block: # https://github.com/guzba/zippy/issues/61
let now = getTime()
var rand = initRand(now.toUnix * 1_000_000_000 + now.nanosecond)
# Add up to 26 characters as the gzip header file name
for i in 0 ..< (rand.next() mod 26).int:
result.add (97 + i).char
result.add '\0'

deflate(result, src, len, level)

Expand Down

0 comments on commit 955d0b6

Please sign in to comment.