image: Use size of image data when writing images
When detaching a signature, we need to know the size of the non-signature data. So, add a data_size member to struct image, and populate it when we iterate through the section table. When writing the image, use data_size rather than size, so we don't unnecessarily add the (now unused) signature data. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
This commit is contained in:
parent
8a55df5e96
commit
5466f381dd
4 changed files with 26 additions and 4 deletions
15
tests/detach-remove.sh
Executable file
15
tests/detach-remove.sh
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash -ex
|
||||
|
||||
signed="test.signed"
|
||||
unsigned="test.unsigned"
|
||||
|
||||
"$sbsign" --cert "$cert" --key "$key" --output "$signed" "$image"
|
||||
cp "$signed" "$unsigned"
|
||||
"$sbattach" --remove "$unsigned"
|
||||
|
||||
# ensure that there is no security directory
|
||||
objdump -p $unsigned | grep -q '0\+ 0\+ Security Directory'
|
||||
|
||||
# ensure that the unsigned file is the same size as our original binary
|
||||
[ $(stat --format=%s "$image") -eq $(stat --format=%s "$unsigned") ]
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue