Added safety check len == 0 (#109)

This commit is contained in:
Martin Dagarin 2019-10-29 21:20:21 +01:00 committed by Romain Tartière
parent b83cbcbb09
commit d13eca5d3c

View file

@ -69,6 +69,9 @@ xor(const uint8_t *ivect, uint8_t *data, const size_t len)
void
rol(uint8_t *data, const size_t len)
{
if (len == 0)
return;
uint8_t first = data[0];
for (size_t i = 0; i < len - 1; i++) {
data[i] = data[i + 1];
@ -79,6 +82,9 @@ rol(uint8_t *data, const size_t len)
void
lsl(uint8_t *data, size_t len)
{
if (len == 0)
return;
for (size_t n = 0; n < len - 1; n++) {
data[n] = (data[n] << 1) | (data[n + 1] >> 7);
}