try to fix a bug Lorenz told me about
in fread
This commit is contained in:
2023-12-06 07:57:25 +01:00
parent a8537ba6d4
commit d9204ad9ed
2 changed files with 3 additions and 3 deletions

View File

@@ -78,8 +78,8 @@ void tftp_custom_fseek(tftp_custom_file_t* handle, size_t offset, int whence) {
* @param[in,out] handle Custom file handles
*/
size_t tftp_custom_fread(void* buf, size_t bytes, tftp_custom_file_t* handle) {
if (handle->offset + bytes > handle->len) {
bytes = handle->len - handle->offset;
if (handle->offset + bytes >= handle->len) {
bytes = handle->len - handle->offset - 1;
}
memcpy(buf, handle->data + handle->offset, bytes);
handle->offset += bytes;