system: sysupgrade: rework firmware validation
Fixes following deficiencies:
* unhandled read() errors
* everything bundled in one long function, which is hard to follow and
reason about
* JSON parser errors are being ignored, anything else then
json_tokener_continue is fatal error
* JSON parser errors are being output to stderr, thus invisible via SSH
* validate_firmware_image_call can fail at a lot of places, but we just
get one generic "Firmware image couldn't be validated" so it's hard
to debug
Cc: Rafał Miłecki <rafal@milecki.pl>
Tested-by: Kuan-Yi Li <kyli@abysm.org>
Signed-off-by: Petr Štetiar <ynezz@true.cz>