summaryrefslogtreecommitdiff
path: root/frontend/scanimage.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2023-02-12 17:36:10 +0100
committerJörg Frings-Fürst <debian@jff.email>2023-02-12 17:36:10 +0100
commite0d94cf4d39395df1e2c6bb4d967200298c13881 (patch)
treebe5c7cace6697afc753c152d13ad5145d0884a42 /frontend/scanimage.c
parent527bedac30eb120915718eb7997e6dacd583512e (diff)
parent84357741a6a6e6430f199b2c3f7498e0e97da9ad (diff)
Update upstream source from tag 'upstream/1.2.1'
Update to upstream version '1.2.1' with Debian dir a9bb43f754a5c9a361b076af3635cc767b7e652e
Diffstat (limited to 'frontend/scanimage.c')
-rw-r--r--frontend/scanimage.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/frontend/scanimage.c b/frontend/scanimage.c
index b587b9d..d79d487 100644
--- a/frontend/scanimage.c
+++ b/frontend/scanimage.c
@@ -40,6 +40,14 @@
#include <unistd.h>
#include <stdarg.h>
+#ifdef __FreeBSD__
+#include <libgen.h>
+#endif
+
+#if defined (__APPLE__) && defined (__MACH__)
+#include <libgen.h> // for basename()
+#endif
+
#include <sys/types.h>
#include <sys/stat.h>
@@ -917,9 +925,10 @@ fetch_options (SANE_Device * device)
scanimage_exit (1);
}
- /* create command line option only for settable options */
- if (!SANE_OPTION_IS_SETTABLE (opt->cap) || opt->type == SANE_TYPE_GROUP)
- continue;
+ /* create command line option only for non-group options */
+ /* Also we sometimes see options with no name in rogue backends. */
+ if ((opt->type == SANE_TYPE_GROUP) || (opt->name == NULL))
+ continue;
option_number[option_count] = i;
@@ -1072,6 +1081,12 @@ process_backend_option (SANE_Handle device, int optnum, const char *optarg)
opt = sane_get_option_descriptor (device, optnum);
+ if (!SANE_OPTION_IS_SETTABLE (opt->cap))
+ {
+ fprintf (stderr, "%s: attempted to set readonly option %s\n",
+ prog_name, opt->name);
+ scanimage_exit (1);
+ }
if (!SANE_OPTION_IS_ACTIVE (opt->cap))
{
fprintf (stderr, "%s: attempted to set inactive option %s\n",
@@ -2013,6 +2028,10 @@ static void print_options(SANE_Device * device, SANE_Int num_dev_options, SANE_B
if (!opt)
opt = sane_get_option_descriptor (device, i);
+ /* Some options from rogue backends are empty. */
+ if (opt->name == NULL)
+ continue;
+
if (ro || SANE_OPTION_IS_SETTABLE (opt->cap)
|| opt->type == SANE_TYPE_GROUP)
print_option (device, i, opt);