mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-19 21:58:04 +00:00
ar71xx: add sanity checks to decode_rle
Also use -EINVAL instead of -1. SVN-Revision: 31353
This commit is contained in:
parent
8f921175ba
commit
5c9ca38e47
@ -299,24 +299,29 @@ static int decode_rle(char *output, int len, char *in)
|
||||
{
|
||||
char *ptr = output;
|
||||
char *end = output + len;
|
||||
|
||||
if (!output || !in)
|
||||
return -EINVAL;
|
||||
|
||||
while (*in) {
|
||||
if (*in < 0) {
|
||||
int i = -*in++;
|
||||
while (i-- > 0) {
|
||||
if (ptr >= end)
|
||||
return -1;
|
||||
return -EINVAL;
|
||||
*ptr++ = *in++;
|
||||
}
|
||||
} else if (*in > 0) {
|
||||
int i = *in++;
|
||||
while (i-- > 0) {
|
||||
if (ptr >= end)
|
||||
return -1;
|
||||
return -EINVAL;
|
||||
*ptr++ = *in;
|
||||
}
|
||||
in++;
|
||||
}
|
||||
}
|
||||
|
||||
return ptr - output;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user