@@ -58,6 +58,12 @@ swupdate_file_t check_if_required(struct imglist *list, struct filehdr *pfdh,
if (strcmp(pfdh->filename, img->fname) == 0) {
skip = COPY_FILE;
img->provided = 1;
+ if (img->size && img->size != (unsigned int)pfdh->size) {
+ ERROR("Size in sw-description %llu does not match size in cpio %u",
+ img->size, (unsigned int)pfdh->size);
+ return -EINVAL;
+
+ }
img->size = (unsigned int)pfdh->size;
if (snprintf(img->extract_file,
@@ -1491,3 +1491,8 @@ There are 4 main sections inside sw-description:
| | | | the mtd to update, instead of |
| | | | specifying the devicenode |
+-------------+----------+------------+---------------------------------------+
+ | size | int64 | images | size of the file as it is expected |
+ | | | files | in the SWU. If set and the cpio size |
+ | | | scripts | does not match for some reason the |
+ | | | | update will fail with an error. |
+ +-------------+----------+------------+---------------------------------------+
@@ -420,6 +420,7 @@ static int parse_common_attributes(parsertype p, void *elem, struct img_type *im
GET_FIELD_STRING(p, elem, "filesystem", image->filesystem);
GET_FIELD_STRING(p, elem, "type", image->type);
GET_FIELD_STRING(p, elem, "data", image->type_data);
+ GET_FIELD_INT64(p, elem, "size", &image->size);
get_hash_value(p, elem, image->sha256);
/*
This allows specifying the size of each cpio file in the sw-description The motivation behind this change is that files are only verified as they are copied to temporary directory or streamed, but without the size information a file could be streamed forever and easily fill in the tmp directory by replacing the files of a valid (signed) SWU. This will be useful even if a chunked checksum is implemented, because while the chunked checksum implicitly also validates the files length it is not useful to include chunked checksums for files that have an intermediate copy stored, and it is more efficient and simpler to only have this size information. Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com> --- v1->v2: remove cpio_scan bit. core/installer.c | 6 ++++++ doc/source/sw-description.rst | 5 +++++ parser/parser.c | 1 + 3 files changed, 12 insertions(+)