klauspost / reedsolomon

Reed-Solomon Erasure Coding in Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Example encoders might check for too large dataShards value

numbleroot opened this issue · comments

Hi @klauspost,
awesome library, thanks for developing and maintaining it.

This is a minor issue I noticed in the example encoders provided in the example folder of the project. It appears to be the case that the data shard argument is checked to be below 258 instead of below 257 as mentioned throughout various places in this project.

Concretely, I believe, the referenced lines below should check for >= 257 or > 256:

Furthermore, though, setting dataShards = 256 and parShards = 1 as per respective command-line flags yields the ErrMaxShardNum error. It looks like actually the sum of dataShards and parShards should be checked to stay below 2^8 = 256, instead of solely enforcing dataShards to stay below this bound.

I might be missing crucial information here, though, and have not spent tremendous amount of further research on this issue, as I believe it to be a rather minor issue. Please let me know if I am missing something here.

Sounds like you found a bug. Feel free to open a PR then you can get proper credit for it. 👍

Merged! Thanks!