1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-12-25 18:47:42 +02:00

ar71xx: add sanity checks to decode_rle

Also use -EINVAL instead of -1.

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31353 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
juhosg 2012-04-19 21:31:40 +00:00
parent 4cb60d0721
commit 9ec35a5650

View File

@ -299,24 +299,29 @@ static int decode_rle(char *output, int len, char *in)
{ {
char *ptr = output; char *ptr = output;
char *end = output + len; char *end = output + len;
if (!output || !in)
return -EINVAL;
while (*in) { while (*in) {
if (*in < 0) { if (*in < 0) {
int i = -*in++; int i = -*in++;
while (i-- > 0) { while (i-- > 0) {
if (ptr >= end) if (ptr >= end)
return -1; return -EINVAL;
*ptr++ = *in++; *ptr++ = *in++;
} }
} else if (*in > 0) { } else if (*in > 0) {
int i = *in++; int i = *in++;
while (i-- > 0) { while (i-- > 0) {
if (ptr >= end) if (ptr >= end)
return -1; return -EINVAL;
*ptr++ = *in; *ptr++ = *in;
} }
in++; in++;
} }
} }
return ptr - output; return ptr - output;
} }