From 8b0ec6d07a62a22586adb2b077612dd532996fa9 Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Sat, 25 Jan 2020 18:30:31 +0100 Subject: avoid endless loops on device going away (AFL) --- camlibs/kodak/dc240/library.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/camlibs/kodak/dc240/library.c b/camlibs/kodak/dc240/library.c index 5352e9db2..d9949687b 100644 --- a/camlibs/kodak/dc240/library.c +++ b/camlibs/kodak/dc240/library.c @@ -60,6 +60,10 @@ #define GP_MODULE "dc240" +/* do not sleep during fuzzing */ +#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION +# define usleep(x) +#endif /* legacy from dc240.h */ /* @@ -165,10 +169,13 @@ write_again: /* Read in the response from the camera if requested */ while (read_response) { - if (gp_port_read(camera->port, in, 1) >= GP_OK) { + int ret; + if ((ret=gp_port_read(camera->port, in, 1)) >= GP_OK) { /* On error, read again */ read_response = 0; + break; } + if (ret == GP_ERROR_IO_READ) return ret; /* e.g. device detached? */ } return GP_OK; -- cgit v1.2.1