diff options
| author | Tom Rini <[email protected]> | 2022-02-03 15:55:02 -0500 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2022-02-03 15:55:02 -0500 |
| commit | 3e5f4b337d89e95af9d3700a4b055b552bf22ac4 (patch) | |
| tree | 86ff5fbee12f43f7d700d130c92009aef12fc185 /common | |
| parent | 006fddde01da7e8b3c7cad4a35f3245edc894ab4 (diff) | |
| parent | 5b9a5b2b966bf738ca4115a9dca52d0dc9f2710d (diff) | |
Merge branch '2022-02-03-assorted-fixes'
- Update CI image to have libgnutls available.
- Assorted ARM and SPL bugfixes
Diffstat (limited to 'common')
| -rw-r--r-- | common/spl/spl_ymodem.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/common/spl/spl_ymodem.c b/common/spl/spl_ymodem.c index 047df74856b..fdd52610429 100644 --- a/common/spl/spl_ymodem.c +++ b/common/spl/spl_ymodem.c @@ -42,6 +42,7 @@ static ulong ymodem_read_fit(struct spl_load_info *load, ulong offset, int res, err, buf_offset; struct ymodem_fit_info *info = load->priv; char *buf = info->buf; + ulong copy_size = size; while (info->image_read < offset) { res = xyzModem_stream_read(buf, BUF_SIZE, &err); @@ -57,8 +58,14 @@ static ulong ymodem_read_fit(struct spl_load_info *load, ulong offset, buf_offset = (info->image_read % BUF_SIZE); else buf_offset = BUF_SIZE; + + if (res > copy_size) { + memcpy(addr, &buf[buf_offset - res], copy_size); + goto done; + } memcpy(addr, &buf[buf_offset - res], res); addr = addr + res; + copy_size -= res; } while (info->image_read < offset + size) { @@ -66,11 +73,17 @@ static ulong ymodem_read_fit(struct spl_load_info *load, ulong offset, if (res <= 0) break; - memcpy(addr, buf, res); info->image_read += res; + if (res > copy_size) { + memcpy(addr, buf, copy_size); + goto done; + } + memcpy(addr, buf, res); addr += res; + copy_size -= res; } +done: return size; } |
