Added safety check len == 0 (#109)
This commit is contained in:
parent
b83cbcbb09
commit
d13eca5d3c
1 changed files with 6 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue