Message ID | 20250122161505.74348-1-maks.mishinFZ@gmail.com |
---|---|
State | Accepted |
Commit | f55fa90a959e4644b89c56e692930810c5c462b4 |
Delegated to: | Tom Rini |
Headers | show |
Series | tools: check result of lseek | expand |
On Wed, Jan 22, 2025 at 07:15:04PM +0300, Maks Mishin wrote: > Return value of function 'lseek', called at pblimage.c:211, > is not checked, but it is usually checked for this function. > > This trigger was found using the Svace static analyzer. > > Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com> Reviewed-by: Tom Rini <trini@konsulko.com>
On Wed, 22 Jan 2025 19:15:04 +0300, Maks Mishin wrote: > Return value of function 'lseek', called at pblimage.c:211, > is not checked, but it is usually checked for this function. > > This trigger was found using the Svace static analyzer. > > Applied to u-boot/master, thanks!
diff --git a/tools/pblimage.c b/tools/pblimage.c index 6c4d360e46..34650cf7b7 100644 --- a/tools/pblimage.c +++ b/tools/pblimage.c @@ -188,7 +188,7 @@ static void add_end_cmd(void) void pbl_load_uboot(int ifd, struct image_tool_params *params) { FILE *fp_uboot; - int size; + int size, ret; /* parse the rcw.cfg file. */ pbl_parser(params->imagename); @@ -208,7 +208,12 @@ void pbl_load_uboot(int ifd, struct image_tool_params *params) fclose(fp_uboot); } add_end_cmd(); - lseek(ifd, 0, SEEK_SET); + ret = lseek(ifd, 0, SEEK_SET); + if (ret < 0) { + fprintf(stderr, "%s: lseek error %s\n", + __func__, strerror(errno)); + exit(EXIT_FAILURE); + } size = pbl_size; if (write(ifd, (const void *)&mem_buf, size) != size) {
Return value of function 'lseek', called at pblimage.c:211, is not checked, but it is usually checked for this function. This trigger was found using the Svace static analyzer. Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com> --- tools/pblimage.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)