mirror of
https://xff.cz/git/u-boot/
synced 2025-09-04 10:12:14 +02:00
tools: mkimage: Fix nullptr at strchr()
The copy_datafile(ifd, params.datafile) function has been implemented to copy data by reducing the number of lines in the main function. Signed-off-by: Mikhail Ilin <ilin.mikhail.ol@gmail.com>
This commit is contained in:
@@ -430,6 +430,25 @@ static void verify_image(const struct image_type_params *tparams)
|
|||||||
(void)close(ifd);
|
(void)close(ifd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void copy_datafile(int ifd, char *file)
|
||||||
|
{
|
||||||
|
if (!file)
|
||||||
|
return;
|
||||||
|
for (;;) {
|
||||||
|
char *sep = strchr(file, ':');
|
||||||
|
|
||||||
|
if (sep) {
|
||||||
|
*sep = '\0';
|
||||||
|
copy_file(ifd, file, 1);
|
||||||
|
*sep++ = ':';
|
||||||
|
file = sep;
|
||||||
|
} else {
|
||||||
|
copy_file(ifd, file, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int ifd = -1;
|
int ifd = -1;
|
||||||
@@ -647,21 +666,7 @@ int main(int argc, char **argv)
|
|||||||
file = NULL;
|
file = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
copy_datafile(ifd, params.datafile);
|
||||||
file = params.datafile;
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
char *sep = strchr(file, ':');
|
|
||||||
if (sep) {
|
|
||||||
*sep = '\0';
|
|
||||||
copy_file (ifd, file, 1);
|
|
||||||
*sep++ = ':';
|
|
||||||
file = sep;
|
|
||||||
} else {
|
|
||||||
copy_file (ifd, file, 0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (params.type == IH_TYPE_PBLIMAGE) {
|
} else if (params.type == IH_TYPE_PBLIMAGE) {
|
||||||
/* PBL has special Image format, implements its' own */
|
/* PBL has special Image format, implements its' own */
|
||||||
pbl_load_uboot(ifd, ¶ms);
|
pbl_load_uboot(ifd, ¶ms);
|
||||||
|
Reference in New Issue
Block a user