summaryrefslogtreecommitdiff
path: root/backend/gt68xx.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2020-03-30 21:30:45 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2020-03-30 21:30:45 +0200
commitee770c2346eb37e0dcb8b6cf3eaacf3d8efd6bbc (patch)
tree58f05092be1a17a939e861f8cadcda1b6ca2ecef /backend/gt68xx.c
parent0da9e21872802cfc6e975b1ebaf9efb9e5934d84 (diff)
parentfef76e17ed4c607ea73b81279f9ef1d7121be900 (diff)
Merge branch 'release/experimental/1.0.29-1_experimental1'experimental/1.0.29-1_experimental1
Diffstat (limited to 'backend/gt68xx.c')
-rw-r--r--backend/gt68xx.c75
1 files changed, 39 insertions, 36 deletions
diff --git a/backend/gt68xx.c b/backend/gt68xx.c
index 13efe91..00190fe 100644
--- a/backend/gt68xx.c
+++ b/backend/gt68xx.c
@@ -2,46 +2,46 @@
Copyright (C) 2002 Sergey Vlasov <vsu@altlinux.ru>
Copyright (C) 2002 - 2007 Henning Geinitz <sane@geinitz.org>
- Copyright (C) 2009 Stéphane Voltz <stef.dev@free.fr> for sheetfed
+ Copyright (C) 2009 Stéphane Voltz <stef.dev@free.fr> for sheetfed
calibration code.
This file is part of the SANE package.
-
+
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
-
+
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA.
-
+
As a special exception, the authors of SANE give permission for
additional uses of the libraries contained in this release of SANE.
-
+
The exception is that, if you link a SANE library with other files
to produce an executable, this does not by itself cause the
resulting executable to be covered by the GNU General Public
License. Your use of that executable is in no way restricted on
account of linking the SANE library code into it.
-
+
This exception does not, however, invalidate any other reasons why
the executable file might be covered by the GNU General Public
License.
-
+
If you submit changes to SANE to the maintainers to be included in
a subsequent release, you agree by submitting the changes that
those changes may be distributed with this exception intact.
If you write modifications of your own for SANE, it is your choice
whether to permit this exception to apply to your modifications.
- If you do not wish that, delete this exception notice.
+ If you do not wish that, delete this exception notice.
*/
/*
@@ -162,13 +162,6 @@ static SANE_Range y_range = {
SANE_FIX (0.0) /* quantization */
};
-
-static const SANE_Range offset_range = {
- -63, /* minimum */
- 63, /* maximum */
- 1 /* quantization */
-};
-
static SANE_Range gamma_range = {
SANE_FIX (0.01), /* minimum */
SANE_FIX (5.0), /* maximum */
@@ -756,10 +749,10 @@ init_options (GT68xx_Scanner * s)
s->opt[OPT_SENSOR_GROUP].desc = SANE_DESC_SENSORS;
s->opt[OPT_SENSOR_GROUP].type = SANE_TYPE_GROUP;
s->opt[OPT_SENSOR_GROUP].constraint_type = SANE_CONSTRAINT_NONE;
-
+
/* calibration needed */
s->opt[OPT_NEED_CALIBRATION_SW].name = "need-calibration";
- s->opt[OPT_NEED_CALIBRATION_SW].title = SANE_I18N ("Need calibration");
+ s->opt[OPT_NEED_CALIBRATION_SW].title = SANE_I18N ("Needs calibration");
s->opt[OPT_NEED_CALIBRATION_SW].desc = SANE_I18N ("The scanner needs calibration for the current settings");
s->opt[OPT_NEED_CALIBRATION_SW].type = SANE_TYPE_BOOL;
s->opt[OPT_NEED_CALIBRATION_SW].unit = SANE_UNIT_NONE;
@@ -954,25 +947,30 @@ download_firmware_file (GT68xx_Device * dev)
if (strncmp (dev->model->firmware_name, PATH_SEP, 1) != 0)
{
/* probably filename only */
- snprintf (filename, PATH_MAX, "%s%s%s%s%s%s%s",
+ snprintf (filename, sizeof(filename), "%s%s%s%s%s%s%s",
STRINGIFY (PATH_SANE_DATA_DIR),
PATH_SEP, "sane", PATH_SEP, "gt68xx", PATH_SEP,
dev->model->firmware_name);
- snprintf (dirname, PATH_MAX, "%s%s%s%s%s",
+ snprintf (dirname, sizeof(dirname), "%s%s%s%s%s",
STRINGIFY (PATH_SANE_DATA_DIR),
PATH_SEP, "sane", PATH_SEP, "gt68xx");
- strncpy (basename, dev->model->firmware_name, PATH_MAX);
+ strncpy (basename, dev->model->firmware_name, sizeof(basename) - 1);
+ basename[sizeof(basename) - 1] = '\0';
}
else
{
/* absolute path */
char *pos;
- strncpy (filename, dev->model->firmware_name, PATH_MAX);
- strncpy (dirname, dev->model->firmware_name, PATH_MAX);
+ strncpy (filename, dev->model->firmware_name, sizeof(filename) - 1);
+ filename[sizeof(filename) - 1] = '\0';
+ strncpy (dirname, dev->model->firmware_name, sizeof(dirname) - 1);
+ dirname[sizeof(dirname) - 1] = '\0';
+
pos = strrchr (dirname, PATH_SEP[0]);
if (pos)
pos[0] = '\0';
- strncpy (basename, pos + 1, PATH_MAX);
+ strncpy (basename, pos + 1, sizeof(basename) - 1);
+ basename[sizeof(basename) - 1] = '\0';
}
/* first, try to open with exact case */
@@ -1001,11 +999,16 @@ download_firmware_file (GT68xx_Device * dev)
{
direntry = readdir (dir);
if (direntry
- && (strncasecmp (direntry->d_name, basename, PATH_MAX) ==
- 0))
+ && (strncasecmp (direntry->d_name, basename, PATH_MAX) == 0))
{
- snprintf (filename, PATH_MAX, "%s%s%s",
- dirname, PATH_SEP, direntry->d_name);
+ int len = snprintf (filename, sizeof(filename), "%s%s%s",
+ dirname, PATH_SEP, direntry->d_name);
+ if ((len < 0) || (len >= (int) sizeof(filename)))
+ {
+ DBG (5, "download_firmware: filepath `%s%s%s' too long\n",
+ dirname, PATH_SEP, direntry->d_name);
+ status = SANE_STATUS_INVAL;
+ }
break;
}
}
@@ -1487,7 +1490,7 @@ sane_open (SANE_String_Const devicename, SANE_Handle * handle)
DBG (0, "WARNING: Your scanner is not fully supported or at least \n");
DBG (0, " had only limited testing. Please be careful and \n");
DBG (0, " report any failure/success to \n");
- DBG (0, " sane-devel@lists.alioth.debian.org. Please provide as many\n");
+ DBG (0, " sane-devel@alioth-lists.debian.net. Please provide as many\n");
DBG (0, " details as possible, e.g. the exact name of your\n");
DBG (0, " scanner and what does (not) work.\n");
}
@@ -1502,7 +1505,7 @@ sane_open (SANE_String_Const devicename, SANE_Handle * handle)
DBG (0,
" the scanner immediately if you hear unusual noise. \n");
DBG (0, " Please report any success to \n");
- DBG (0, " sane-devel@lists.alioth.debian.org. Please provide as many\n");
+ DBG (0, " sane-devel@alioth-lists.debian.net. Please provide as many\n");
DBG (0, " details as possible, e.g. the exact name of your\n");
DBG (0, " scanner, ids, settings etc.\n");
@@ -1616,7 +1619,7 @@ sane_close (SANE_Handle handle)
gt68xx_device_lamp_control (s->dev, SANE_FALSE, SANE_FALSE);
dev = s->dev;
-
+
free (s->val[OPT_MODE].s);
free (s->val[OPT_GRAY_MODE_COLOR].s);
free (s->val[OPT_SOURCE].s);
@@ -1624,7 +1627,7 @@ sane_close (SANE_Handle handle)
free ((void *)(size_t)s->opt[OPT_RESOLUTION].constraint.word_list);
gt68xx_scanner_free (s);
-
+
gt68xx_device_fix_descriptor (dev);
gt68xx_device_deactivate (dev);
@@ -1859,7 +1862,7 @@ sane_control_option (SANE_Handle handle, SANE_Int option,
status = gt68xx_sheetfed_scanner_calibrate (s);
myinfo |= SANE_INFO_RELOAD_OPTIONS;
break;
-
+
case OPT_CLEAR_CALIBRATION:
gt68xx_clear_calibration (s);
myinfo |= SANE_INFO_RELOAD_OPTIONS;
@@ -2045,14 +2048,14 @@ sane_start (SANE_Handle handle)
{
/* compute scan parameters */
scan_request.calculate = SANE_TRUE;
- gt68xx_device_setup_scan (s->dev, &scan_request, SA_SCAN, &scan_params);
+ gt68xx_device_setup_scan (s->dev, &scan_request, SA_SCAN, &scan_params);
/* restore settings from calibration stored */
memcpy(s->dev->afe,&(s->afe_params), sizeof(GT68xx_AFE_Parameters));
RIE (gt68xx_assign_calibration (s, scan_params));
scan_request.calculate = SANE_FALSE;
}
-
+
/* send scan request to the scanner */
RIE (gt68xx_scanner_start_scan (s, &scan_request, &scan_params));
@@ -2331,7 +2334,7 @@ sane_cancel (SANE_Handle handle)
if (s->dev->model->flags & GT68XX_FLAG_SHEET_FED)
{
gt68xx_device_paperfeed (s->dev);
- }
+ }
else
{
sanei_usb_set_timeout (SHORT_TIMEOUT);