elftools: StringTableSection: Check table size before returning string

Some ELF files have strings pointing to an offset outside the string
table dimension, let's throw an exception in that case.

BUG=chromium:788925
TEST=sudo /mnt/host/source/chromite/bin/test_image --board edgar \
        chromiumos_base_image_R64-10166.0.0-rc1.bin
     => Succeeds
TEST=sudo /mnt/host/source/chromite/bin/test_image --board edgar \
        chromiumos_base_image_R64-10166.0.0-rc2.bin
     => Fails with a clearer error message than currently

Change-Id: Id6919d29f5f4c14f03b11ff540adf63dc1fe9c6f
Reviewed-on: https://chromium-review.googlesource.com/792553
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
1 file changed