mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-01 18:50:34 +03:00
Merge branch 'contrib/github_pr_18822_v5.3' into 'release/v5.3'
fix(esp_partition): prevent size_t overflow bypassing bounds checks on linux target (GitHub PR) (v5.3) See merge request espressif/esp-idf!50911
This commit is contained in:
@@ -426,7 +426,7 @@ esp_err_t esp_partition_write(const esp_partition_t *partition, size_t dst_offse
|
||||
if (dst_offset > partition->size) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
if (dst_offset + size > partition->size) {
|
||||
if (size > partition->size - dst_offset) {
|
||||
return ESP_ERR_INVALID_SIZE;
|
||||
}
|
||||
|
||||
@@ -480,7 +480,7 @@ esp_err_t esp_partition_read(const esp_partition_t *partition, size_t src_offset
|
||||
if (src_offset > partition->size) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
if (src_offset + size > partition->size) {
|
||||
if (size > partition->size - src_offset) {
|
||||
return ESP_ERR_INVALID_SIZE;
|
||||
}
|
||||
|
||||
@@ -525,7 +525,7 @@ esp_err_t esp_partition_erase_range(const esp_partition_t *partition, size_t off
|
||||
if (offset > partition->size || offset % partition->erase_size != 0) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
if (offset + size > partition->size || size % partition->erase_size != 0) {
|
||||
if (size > partition->size - offset || size % partition->erase_size != 0) {
|
||||
return ESP_ERR_INVALID_SIZE;
|
||||
}
|
||||
|
||||
@@ -577,7 +577,7 @@ esp_err_t esp_partition_mmap(const esp_partition_t *partition, size_t offset, si
|
||||
if (offset > partition->size) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
if (offset + size > partition->size) {
|
||||
if (size > partition->size - offset) {
|
||||
return ESP_ERR_INVALID_SIZE;
|
||||
}
|
||||
if (partition->flash_chip != NULL) {
|
||||
|
||||
Reference in New Issue
Block a user