libdvbv5: Don't go past the size of dvb_v5_name
authorMauro Carvalho Chehab <m.chehab@samsung.com>
Sun, 31 Aug 2014 23:53:30 +0000 (20:53 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Sun, 31 Aug 2014 23:53:30 +0000 (20:53 -0300)
commit08253c317be2aa523fe5a4f6523a1140031b2327
tree50b92d17ff03b670b9b1c6bea28d3d3d73135966
parent48587483bf2f87c9e1e8438dd4233ceab71119e0
libdvbv5: Don't go past the size of dvb_v5_name

As reported by Coverity:

4. cond_between: Checking cmd < 256 implies that cmd has the value which is between 0 and 255 (inclusive) on the true branch.
460        if (cmd >= 0 && cmd < DTV_USER_COMMAND_START)
CID 1054605 (#1 of 1): Out-of-bounds read (OVERRUN)5. overrun-local: Overrunning array dvb_v5_name of 71 8-byte elements at element index 255 (byte offset 2040) using index cmd (which evaluates to 255).
461                return dvb_v5_name[cmd];
462        else if (cmd >= 0 && cmd <= DTV_MAX_STAT_COMMAND)
463                return dvb_user_name[cmd - DTV_USER_COMMAND_START];
464        return NULL;

This wouldn't be a problem if the function was just internal,
but this is part of the public functions.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
lib/libdvbv5/dvb-fe.c