mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-07 14:32:23 +00:00
sparc: piggyback: handle invalid image
With an old elftoaout, the generation of tftpboot.img fail with "lseek: invalid argument". This is due to offset being negative. Instead of printing this error message, let's print a better one. Signed-off-by: Corentin Labbe <clabbe@baylibre.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
c05d042fda
commit
5124b31c1e
@ -154,6 +154,10 @@ static off_t get_hdrs_offset(int kernelfd, const char *filename)
|
|||||||
offset -= LOOKBACK;
|
offset -= LOOKBACK;
|
||||||
/* skip a.out header */
|
/* skip a.out header */
|
||||||
offset += AOUT_TEXT_OFFSET;
|
offset += AOUT_TEXT_OFFSET;
|
||||||
|
if (offset < 0) {
|
||||||
|
errno = -EINVAL;
|
||||||
|
die("Calculated a negative offset, probably elftoaout generated an invalid image. Did you use a recent elftoaout ?");
|
||||||
|
}
|
||||||
if (lseek(kernelfd, offset, SEEK_SET) < 0)
|
if (lseek(kernelfd, offset, SEEK_SET) < 0)
|
||||||
die("lseek");
|
die("lseek");
|
||||||
if (read(kernelfd, buffer, BUFSIZE) != BUFSIZE)
|
if (read(kernelfd, buffer, BUFSIZE) != BUFSIZE)
|
||||||
|
Loading…
Reference in New Issue
Block a user