klauspost / reedsolomon

Reed-Solomon Erasure Coding in Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

^@^@^@ added to the end of the file

chranmat opened this issue · comments

Hi,

I recently downloaded this library and started to test the examples attached in the examples/ folder.

When decoding a random text file I experienced that a string ^@^@^@ is added to the end of the decoded file.

Steps to reproduce:

  1. Create a text file with some content. (Mark! Several newlines is used between the text in this file)

1

  1. Use "simple-encoder" to encode the file in to 6 shards (default 4+2):

2

  1. Delete the original file and 2 of 6 encoded shards

3

  1. Decode the remaining shards with "simple-decoder" (default 4+2)

4

Expected Result:
File is recovered in the original state

Actual Result:
The string ^@^@^@ is added on separate linje in the end of the file.
AR

Additional info:
When using another example text with more content and less newlines this does not happen.

This picture is from when using the exact same method to reproduce, but different content:
ER

Attached is also original and decoded file that reproduces the issue:

Original:
file.original.txt

Decoded:
file.decided.txt

commented

https://github.com/klauspost/reedsolomon#splittingjoining-data

An important thing to note is that you have to keep track of the exact input size. If the size of the input isn't divisible by the number of data shards, extra zeros will be inserted in the last shard.