Skip to content
  • Michal Simek's avatar
    tools: mkimage: Use fstat instead of stat to avoid malicious hacks · ebe0f53f
    Michal Simek authored
    The patch is fixing:
    "tools: mkimage: Check if file is regular file"
    (sha1: 56c7e801)
    which contains two issues reported by Coverity
    Unchecked return value from stat and incorrect calling sequence where
    attack can happen between calling stat and fopen.
    Using pair in opposite order (fopen and fstat) is fixing this issue
    because fstat is using the same file descriptor (FILE *).
    
    Also fixing issue with:
    "tools: mkimage: Add support for initialization table for Zynq and
    ZynqMP" (sha1: 3b646080
    
    )
    where file wasn't checked that it is regular file.
    
    Reported-by: Coverity (CID: 154711, 154712)
    Signed-off-by: default avatarMichal Simek <michal.simek@xilinx.com>
    Reviewed-by: default avatarTom Rini <trini@konsulko.com>
    ebe0f53f