volume_id/romfs: limit the maximum size of label to VOLUME_ID_LABEL_SIZE
No binary (build failed)
—
(log yok)
| @@ -44,8 +44,8 @@ int FAST_FUNC volume_id_probe_romfs(struct volume_id *id /*,uint64_t off*/) | |
| if (rfs == NULL) | |
| return -1; | |
| - | if (memcmp(rfs->magic, "-rom1fs-", 4) == 0) { |
| - | size_t len = strlen((char *)rfs->name); |
| + | if (memcmp(rfs->magic, "-rom1fs-", 8) == 0) { |
| + | size_t len = strnlen((char *)rfs->name, VOLUME_ID_LABEL_SIZE); |
| if (len) { | |
| // volume_id_set_label_raw(id, rfs->name, len); | |
| @@ -116,6 +116,10 @@ void volume_id_set_label_string(struct volume_id *id, const uint8_t *buf, size_t | |
| { | |
| unsigned i; | |
| + | /* Do not overflow label[VOLUME_ID_LABEL_SIZE+1] */ |
| + | if (count > VOLUME_ID_LABEL_SIZE) |
| + | count = VOLUME_ID_LABEL_SIZE; |
| + | |
| memcpy(id->label, buf, count); | |
| /* remove trailing whitespace */ | |