diff --git a/usr.bin/mkimg/image.c b/usr.bin/mkimg/image.c index c5a75c97a5cb..e92b1f278791 100644 --- a/usr.bin/mkimg/image.c +++ b/usr.bin/mkimg/image.c @@ -119,8 +119,12 @@ image_copyout(int fd) } } free(buffer); + if (error) + return (error); ofs = lseek(fd, 0L, SEEK_CUR); - ftruncate(fd, ofs); + if (ofs == -1) + return (errno); + error = (ftruncate(fd, ofs) == -1) ? errno : 0; return (error); }