From 652efae78c00b812033ea162d76cd13bd40dcab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Mon, 9 Jun 2025 14:27:29 +0200 Subject: New upstream version 1.4.0 --- backend/hp5590.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'backend/hp5590.c') 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) -- cgit v1.2.3