diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2025-06-09 14:27:29 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2025-06-09 14:27:29 +0200 |
commit | 652efae78c00b812033ea162d76cd13bd40dcab6 (patch) | |
tree | 7c139f4d2a28061607cd7e2269693df993e5d60a /backend/hp5590.c | |
parent | bfa2ae8e43fcbab696f272fffd164d0637e965c5 (diff) |
New upstream version 1.4.0upstream/1.4.0upstream
Diffstat (limited to 'backend/hp5590.c')
-rw-r--r-- | backend/hp5590.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/backend/hp5590.c b/backend/hp5590.c index 78c9313..56acfb1 100644 --- a/backend/hp5590.c +++ b/backend/hp5590.c @@ -2154,6 +2154,24 @@ sane_read_internal (struct hp5590_scanner * scanner, SANE_Byte * data, max_length, scanner->transferred_image_size); + /* + * We will truncate down the buffer size to *under* what the + * internal USB reading buffer can supply. This will avoid page read issues + * at the end of the buffer. + * + * See: https://gitlab.com/sane-project/backends/-/issues/781 + * + */ + if (max_length > BULK_READ_PAGE_SIZE * MAX_READ_PAGES) + { + DBG (DBG_proc, "%s, truncating sane_read buffer from %u to %u\n", + __func__, + max_length, + BULK_READ_PAGE_SIZE * MAX_READ_PAGES); + + max_length = BULK_READ_PAGE_SIZE * MAX_READ_PAGES; + } + SANE_Int length_limited = 0; *length = max_length; if ((unsigned long long) *length > scanner->transferred_image_size) |