Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Arm Trusted Firmware
Commits
bf6363ac
Commit
bf6363ac
authored
Jan 23, 2017
by
danh-arm
Committed by
GitHub
Jan 23, 2017
Browse files
Merge pull request #810 from masahir0y/fiptool_fix
Fix fiptool bug introduced by recent rework
parents
7b94e4b9
11c0a4ff
Changes
1
Hide whitespace changes
Inline
Side-by-side
tools/fiptool/fiptool.c
View file @
bf6363ac
...
...
@@ -155,12 +155,17 @@ static void *xmalloc(size_t size, const char *msg)
return
d
;
}
static
void
*
xzalloc
(
size_t
size
,
const
char
*
msg
)
{
return
memset
(
xmalloc
(
size
,
msg
),
0
,
size
);
}
static
image_desc_t
*
new_image_desc
(
const
uuid_t
*
uuid
,
const
char
*
name
,
const
char
*
cmdline_name
)
{
image_desc_t
*
desc
;
desc
=
x
m
alloc
(
sizeof
(
*
desc
),
desc
=
x
z
alloc
(
sizeof
(
*
desc
),
"failed to allocate memory for image descriptor"
);
memcpy
(
&
desc
->
uuid
,
uuid
,
sizeof
(
uuid_t
));
desc
->
name
=
xstrdup
(
name
,
...
...
@@ -168,7 +173,6 @@ static image_desc_t *new_image_desc(const uuid_t *uuid,
desc
->
cmdline_name
=
xstrdup
(
cmdline_name
,
"failed to allocate memory for image command line name"
);
desc
->
action
=
DO_UNSPEC
;
desc
->
action_arg
=
NULL
;
return
desc
;
}
...
...
@@ -196,9 +200,14 @@ static void free_image_desc(image_desc_t *desc)
static
void
add_image_desc
(
image_desc_t
*
desc
)
{
image_desc_t
**
p
=
&
image_desc_head
;
assert
(
lookup_image_desc_from_uuid
(
&
desc
->
uuid
)
==
NULL
);
desc
->
next
=
image_desc_head
;
image_desc_head
=
desc
;
while
(
*
p
)
p
=
&
(
*
p
)
->
next
;
*
p
=
desc
;
nr_image_descs
++
;
}
...
...
@@ -233,9 +242,15 @@ static void fill_image_descs(void)
static
void
add_image
(
image_t
*
image
)
{
image_t
**
p
=
&
image_head
;
assert
(
lookup_image_from_uuid
(
&
image
->
uuid
)
==
NULL
);
image
->
next
=
image_head
;
image_head
=
image
;
while
(
*
p
)
p
=
&
(
*
p
)
->
next
;
*
p
=
image
;
nr_images
++
;
}
...
...
@@ -393,7 +408,7 @@ static int parse_fip(const char *filename, fip_toc_header_t *toc_header_out)
* Build a new image out of the ToC entry and add it to the
* table of images.
*/
image
=
x
m
alloc
(
sizeof
(
*
image
),
image
=
x
z
alloc
(
sizeof
(
*
image
),
"failed to allocate memory for image"
);
memcpy
(
&
image
->
uuid
,
&
toc_entry
->
uuid
,
sizeof
(
uuid_t
));
image
->
buffer
=
xmalloc
(
toc_entry
->
size
,
...
...
@@ -450,7 +465,7 @@ static image_t *read_image_from_file(const uuid_t *uuid, const char *filename)
if
(
fstat
(
fileno
(
fp
),
&
st
)
==
-
1
)
log_errx
(
"fstat %s"
,
filename
);
image
=
x
m
alloc
(
sizeof
(
*
image
),
"failed to allocate memory for image"
);
image
=
x
z
alloc
(
sizeof
(
*
image
),
"failed to allocate memory for image"
);
memcpy
(
&
image
->
uuid
,
uuid
,
sizeof
(
uuid_t
));
image
->
buffer
=
xmalloc
(
st
.
st_size
,
"failed to allocate image buffer"
);
if
(
fread
(
image
->
buffer
,
1
,
st
.
st_size
,
fp
)
!=
st
.
st_size
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment