From 6c9fa2460000aa0562417c95a71879e9b023ee55 Mon Sep 17 00:00:00 2001 From: Tormod Volden Date: Tue, 5 Jan 2021 20:34:19 +0100 Subject: [PATCH] Limit transfer size only on Linux And it is limited in libusb and not necessarily linked to the memory page size any longer. https://sourceforge.net/p/dfu-util/tickets/102/ Signed-off-by: Tormod Volden --- configure.ac | 2 +- src/main.c | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/configure.ac b/configure.ac index e35aa9d..9013812 100644 --- a/configure.ac +++ b/configure.ac @@ -34,7 +34,7 @@ AC_TYPE_SIZE_T # Checks for library functions. AC_FUNC_MEMCMP -AC_CHECK_FUNCS([getpagesize nanosleep err]) +AC_CHECK_FUNCS([nanosleep err]) # Checks how to do large files AC_SYS_LARGEFILE diff --git a/src/main.c b/src/main.c index 1e98006..f204a40 100644 --- a/src/main.c +++ b/src/main.c @@ -661,16 +661,13 @@ int main(int argc, char **argv) errx(EX_USAGE, "Transfer size must be specified"); } -#ifdef HAVE_GETPAGESIZE -/* autotools lie when cross-compiling for Windows using mingw32/64 */ -#ifndef __MINGW32__ - /* limitation of Linux usbdevio */ - if ((int)transfer_size > getpagesize()) { - transfer_size = getpagesize(); +#ifdef __linux__ + /* limited to 4k in libusb Linux backend */ + if ((int)transfer_size > 4096) { + transfer_size = 4096; printf("Limited transfer size to %i\n", transfer_size); } -#endif /* __MINGW32__ */ -#endif /* HAVE_GETPAGESIZE */ +#endif /* __linux__ */ if (transfer_size < dfu_root->bMaxPacketSize0) { transfer_size = dfu_root->bMaxPacketSize0;