catid / leopard

Leopard-RS : O(N Log N) MDS Reed-Solomon Block Erasure Code for Large Data
BSD 3-Clause "New" or "Revised" License
141 stars 23 forks source link

Handle the case when no original data was lost #23

Closed gbletr42 closed 7 months ago

gbletr42 commented 7 months ago

I ran into an edge case in my application bef where if there is no corrupted original data, but all the recoveries are corrupted, we head into a null dereference. So to handle the case where we have no lost data, we should just copy that data into the work array and return Leopard_Success. This allows me to naively call the decode library without having to check if the original array is fine or not, and I feel is an undocumented footgun anyways.

gbletr42 commented 7 months ago

we could also solve this by adding in a check for the m=1 case that we actually have 1 recovery, as the reed solomon code handles having zero recoveries fine. It's your choice, but memcpy is probably faster.

catid commented 7 months ago

Looks like a good improvement