@@ -873,6 +873,7 @@ char *swupdate_temporary_mount(tmp_mountpoint_t type,
const char *device, const
char *mountpoint;
const char *dir;
int ret = 0;
+ unsigned int len;
if (type != MNT_SCRIPTS && type != MNT_DATA && type !=
MNT_BOOT_SCRIPTS)
return NULL;
@@ -883,10 +884,12 @@ char *swupdate_temporary_mount(tmp_mountpoint_t type,
const char *device, const
}
dir = mount_points[type];
- if (asprintf(&mountpoint, "%s%sXXXXXX", get_tmpdir(), dir) == -1) {
+ len = asprintf(&mountpoint, "%s%sXXXXXX/", get_tmpdir(), dir);
+ if (len == -1) {
ERROR("Unable to allocate memory");
return NULL;
}
+ mountpoint[len-1] = '\0'; /* last six characters of template must
be XXXXXX */
if (!mkdtemp(mountpoint)) {
TRACE("Unable to create a unique temporary directory %s:
%s",
@@ -904,6 +907,7 @@ char *swupdate_temporary_mount(tmp_mountpoint_t type,
const char *device, const
return NULL;
}
+ mountpoint[len-1] = '/'; /* restore the trailing slash */
return mountpoint;
}
Best regards
Einar Jon
On Thursday, 19 December 2024 at 11:08:09 UTC+1 Michael Glembotzki wrote:
The raw_handler requires a slash between the mountpoint and the file path.
Otherwise, no correct mount is performed, and the file is saved to the
wrong
location.
[TRACE] : SWUPDATE running : [install_raw_file] : Installing file
fitimage.itb.signed on /tmp/datadst/UEE6x2fitImage.signed
Fixes: 5d57a9c05ec2 (util: introduce generic mount helpers)
Fixes: aff67cdb2c62 (Make use of introduced swupdate_temporary_(u)mount)
Signed-off-by: Michael Glembotzki <Michael.G...@iris-sensing.com>
The bug is pretty bad because, for example, it caused parts of the update
(e.g. for us the kernel fitimage) to not be installed. I could imagine that
some systems would not boot as expected.
Only the raw_handler has been tested. Other handlers, such as rdiff, btrfs,
archive, delta, could also be affected and should be explicitly tested.
core/util.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
@@ -873,6 +873,7 @@ char *swupdate_temporary_mount(tmp_mountpoint_t type,
const char *device, const
char *mountpoint;
const char *dir;
int ret = 0;
+ unsigned int len;
if (type != MNT_SCRIPTS && type != MNT_DATA && type != MNT_BOOT_SCRIPTS)