From 32c0f5079b4b372d4e88222ab626c4e227dcfeea Mon Sep 17 00:00:00 2001 From: Nils Philippsen Date: Oct 08 2015 12:53:32 +0000 Subject: version 1.0.25 - remove obsolete patches: epson-expression800, hwdb, pixma_bjnp-crash, static-code-check, scsi-permissions, format-security, snprintf-license, usb3-xhci - update udev patch - ship umax_pp tool --- diff --git a/.gitignore b/.gitignore index 9a09ae1..151ebbd 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ sane-backends-1.0.21.tar.gz /sane-backends-1.0.22.tar.gz /sane-backends-1.0.23.tar.gz /sane-backends-1.0.24.tar.gz +/sane-backends-1.0.25.tar.gz diff --git a/sane-backends-1.0.21-epson-expression800.patch b/sane-backends-1.0.21-epson-expression800.patch deleted file mode 100644 index 8a6fb5d..0000000 --- a/sane-backends-1.0.21-epson-expression800.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 305535e303032814b65bf6d889a95f00f08a9071 Mon Sep 17 00:00:00 2001 -From: Nils Philippsen -Date: Wed, 5 May 2010 12:49:02 +0200 -Subject: [PATCH] patch: epson-expression800 - -Squashed commit of the following: - -commit 3b501d7499357438a1fbd63fefb2f977ae3051f5 -Author: Nils Philippsen -Date: Wed May 5 12:14:23 2010 +0200 - - Improve Epson Expression 800 - - Epson Expression 800 models announce themselves as "processor", not - "scanner". ---- - doc/descriptions/epson.desc | 1 + - doc/descriptions/epson2.desc | 1 + - 2 files changed, 2 insertions(+), 0 deletions(-) - -diff --git a/doc/descriptions/epson.desc b/doc/descriptions/epson.desc -index a22325c..55a0136 100644 ---- a/doc/descriptions/epson.desc -+++ b/doc/descriptions/epson.desc -@@ -174,6 +174,7 @@ - :model "Expression 800" - :interface "SCSI" - :status :complete -+:scsi "EPSON" "Expression800" "processor" - - :model "Expression 1600" - :interface "SCSI USB IEEE-1394" -diff --git a/doc/descriptions/epson2.desc b/doc/descriptions/epson2.desc -index 9a14f4f..56cabcd 100644 ---- a/doc/descriptions/epson2.desc -+++ b/doc/descriptions/epson2.desc -@@ -241,6 +241,7 @@ - :model "Expression 800" ; command spec - :interface "SCSI" - :status :complete -+:scsi "EPSON" "Expression800" "processor" - :comment "overseas version of the GT-9600" - - :model "Expression 836XL" ; command spec --- -1.6.6.1 - diff --git a/sane-backends-1.0.24-format-security.patch b/sane-backends-1.0.24-format-security.patch deleted file mode 100644 index 89defc3..0000000 --- a/sane-backends-1.0.24-format-security.patch +++ /dev/null @@ -1,139 +0,0 @@ -From d1c0b7d119bb9dd2c51143b44cc86a369f453746 Mon Sep 17 00:00:00 2001 -From: Nils Philippsen -Date: Wed, 4 Dec 2013 15:21:19 +0100 -Subject: [PATCH] patch: format-security - -Squashed commit of the following: - -commit 19e071b9f6d477462a0f4afbbd17acd15268ddfa -Author: Nils Philippsen -Date: Wed Dec 4 15:04:12 2013 +0100 - - avoid using string formats insecurely with "-f" - - In the process, simplify processing the device list format: don't copy - the format string for writing \0 into it, just iterate over chunks in - the original string. - - (cherry picked from commit 8082a42ec4f3b3cf2cffc30a45dda5fc41d55576) ---- - frontend/scanimage.c | 52 ++++++++++++++++++++-------------------------------- - 1 file changed, 20 insertions(+), 32 deletions(-) - -diff --git a/frontend/scanimage.c b/frontend/scanimage.c -index d41c849..9e1bcfb 100644 ---- a/frontend/scanimage.c -+++ b/frontend/scanimage.c -@@ -1826,23 +1826,16 @@ main (int argc, char **argv) - else - { - int i = 0, int_arg = 0; -- char *percent, *start, *fmt; -+ const char *percent, *start; - const char *text_arg = 0; -- char cc, ftype; -- -- fmt = malloc (strlen (optarg) + 1); -- if (fmt == 0) -- { -- fprintf (stderr, "%s: not enough memory\n", prog_name); -- exit (1); -- } -+ char ftype; - - for (i = 0; device_list[i]; ++i) - { -- strcpy (fmt, optarg); -- start = fmt; -+ start = optarg; - while (*start && (percent = strchr (start, '%'))) - { -+ int start_len = percent - start; - percent++; - if (*percent) - { -@@ -1850,19 +1843,19 @@ main (int argc, char **argv) - { - case 'd': - text_arg = device_list[i]->name; -- ftype = *percent = 's'; -+ ftype = 's'; - break; - case 'v': - text_arg = device_list[i]->vendor; -- ftype = *percent = 's'; -+ ftype = 's'; - break; - case 'm': - text_arg = device_list[i]->model; -- ftype = *percent = 's'; -+ ftype = 's'; - break; - case 't': - text_arg = device_list[i]->type; -- ftype = *percent = 's'; -+ ftype = 's'; - break; - case 'i': - int_arg = i; -@@ -1870,45 +1863,40 @@ main (int argc, char **argv) - break; - case 'n': - text_arg = "\n"; -- ftype = *percent = 's'; -+ ftype = 's'; - break; - case '%': -- ftype = 0; -+ text_arg = "%"; -+ ftype = 's'; - break; - default: - fprintf (stderr, - "%s: unknown format specifier %%%c\n", - prog_name, *percent); -- *percent = '%'; -- ftype = 0; -+ text_arg = "%"; -+ ftype = 's'; - } -- percent++; -- cc = *percent; -- *percent = 0; -+ printf ("%.*s", start_len, start); - switch (ftype) - { - case 's': -- printf (start, text_arg); -+ printf ("%s", text_arg); - break; - case 'i': -- printf (start, int_arg); -- break; -- case 0: -- printf (start); -+ printf ("%i", int_arg); - break; - } -- *percent = cc; -- start = percent; -+ start = percent + 1; - } - else - { -- /* last char of the string is a '%', suppress it */ -- *start = 0; -+ /* last char of the string is a '%', ignore it */ -+ start++; - break; - } - } - if (*start) -- printf (start); -+ printf ("%s", start); - } - } - if (i == 0 && ch != 'f') --- -1.8.4.2 - diff --git a/sane-backends-1.0.24-hwdb.patch b/sane-backends-1.0.24-hwdb.patch deleted file mode 100644 index 372012f..0000000 --- a/sane-backends-1.0.24-hwdb.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 92c55802144a024fb48ca5babeb99254209d2c71 Mon Sep 17 00:00:00 2001 -From: Nils Philippsen -Date: Thu, 24 Oct 2013 14:29:25 +0200 -Subject: [PATCH] patch: hwdb - -Squashed commit of the following: - -commit 6686fded6523a04b26d02e7bbeb906a579c9ef5f -Author: Nils Philippsen -Date: Thu Oct 24 14:22:17 2013 +0200 - - sane-desc: fix udev hwdb generation - - Generated hwdb files listed the vendor ID instead of the product ID - which made udevd not recognizing scanner devices as such. Thanks to - Fabrice Bellet who spotted the problem. - - (cherry picked from commit 3b96baef65ea6c315937f5cd2253c6b6c62636d8) ---- - tools/sane-desc.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/tools/sane-desc.c b/tools/sane-desc.c -index df6d348..ae218c3 100644 ---- a/tools/sane-desc.c -+++ b/tools/sane-desc.c -@@ -3827,7 +3827,7 @@ print_hwdb (void) - - for(j = 0; j < 4; j++) { - vendor_id[j] = toupper(vendor_id[j]); -- product_id[j] = toupper(vendor_id[j]); -+ product_id[j] = toupper(product_id[j]); - } - - printf ("usb:v%sp%s*\n libsane_matched=yes\n\n", --- -1.8.3.1 - diff --git a/sane-backends-1.0.24-pixma_bjnp-crash.patch b/sane-backends-1.0.24-pixma_bjnp-crash.patch deleted file mode 100644 index 721abf7..0000000 --- a/sane-backends-1.0.24-pixma_bjnp-crash.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 11248fb7484c56ecdf14f8f24f2322d887a7e48e Mon Sep 17 00:00:00 2001 -From: Nils Philippsen -Date: Tue, 29 Oct 2013 14:19:16 +0100 -Subject: [PATCH] patch: pixma_bjnp-crash - -Squashed commit of the following: - -commit d7c1db0e79b9e6b1f7c08c16ef883ad414a12bc0 -Author: Nils Philippsen -Date: Tue Oct 29 14:14:18 2013 +0100 - - pixmap: omitting curly braces considered harmful - - The break being outside of the else block effectively made an if clause - out of the while loop. This caused long hostnames to not be shortened - sufficiently which subsequentely made strcpy() write beyond buffer - boundaries. - - (cherry picked from commit d35d6326cb00fcbb19b41599bdff7faf5d79225e) ---- - backend/pixma_bjnp.c | 8 +++++--- - 1 file changed, 5 insertions(+), 3 deletions(-) - -diff --git a/backend/pixma_bjnp.c b/backend/pixma_bjnp.c -index 3046e9d..a1730ad 100644 ---- a/backend/pixma_bjnp.c -+++ b/backend/pixma_bjnp.c -@@ -364,11 +364,13 @@ determine_scanner_serial (const char *hostname, const char * mac_address, char * - /* if this is a FQDN, not an ip-address, remove domain part of the name */ - if ((dot = strchr (copy, '.')) != NULL) - { -- *dot = '\0'; -+ *dot = '\0'; - } - else -- strcpy(copy, mac_address); -- break; -+ { -+ strcpy(copy, mac_address); -+ break; -+ } - } - strcpy( serial, copy ); - return serial; --- -1.8.3.1 - diff --git a/sane-backends-1.0.24-scsi-permissions.patch b/sane-backends-1.0.24-scsi-permissions.patch deleted file mode 100644 index d8e9fd3..0000000 --- a/sane-backends-1.0.24-scsi-permissions.patch +++ /dev/null @@ -1,49 +0,0 @@ -From 1567fcb9d9dd3dea6e0978ef2473ac7dba7dbba0 Mon Sep 17 00:00:00 2001 -From: Nils Philippsen -Date: Wed, 20 Nov 2013 22:04:21 +0100 -Subject: [PATCH] patch: scsi-permissions - -Squashed commit of the following: - -commit 80e8a34505a45dd61761ce557bf029e33e39d2f2 -Author: Nils Philippsen -Date: Wed Nov 20 21:45:23 2013 +0100 - - sane-desc: fix faulty udev logic for SCSI devices - - SUBSYSTEMS!="..." seems to always match, i.e. skip the SCSI-specific - rules. - - (cherry picked from commit 758731489d0d58bab6e4b70db9556038c9f4bb67) ---- - tools/sane-desc.c | 7 +++++-- - 1 file changed, 5 insertions(+), 2 deletions(-) - -diff --git a/tools/sane-desc.c b/tools/sane-desc.c -index ae218c3..72e11b8 100644 ---- a/tools/sane-desc.c -+++ b/tools/sane-desc.c -@@ -3569,7 +3569,8 @@ print_udev (void) - - printf ("\nLABEL=\"libsane_usb_rules_end\"\n\n"); - -- printf ("SUBSYSTEMS!=\"scsi\", GOTO=\"libsane_scsi_rules_end\"\n\n"); -+ printf ("SUBSYSTEMS==\"scsi\", GOTO=\"libsane_scsi_rules_begin\"\n"); -+ printf ("GOTO=\"libsane_scsi_rules_end\"\n\n"); - printf ("LABEL=\"libsane_scsi_rules_begin\"\n"); - printf ("# Generic: SCSI device type 6 indicates a scanner\n"); - -@@ -3695,7 +3696,9 @@ print_udevhwdb (void) - printf("ENV{DEVTYPE}==\"usb_device\", ENV{libsane_matched}==\"yes\", TEST==\"power/control\", ATTR{power/control}=\"on\"\n\n"); - printf("ENV{DEVTYPE}==\"usb_device\", ENV{libsane_matched}==\"yes\", TEST!=\"power/control\", TEST==\"power/level\", ATTR{power/level}=\"on\"\n"); - -- printf ("SUBSYSTEMS!=\"scsi\", GOTO=\"libsane_rules_end\"\n"); -+ printf ("SUBSYSTEMS==\"scsi\", GOTO=\"libsane_scsi_rules_begin\"\n"); -+ printf ("GOTO=\"libsane_rules_end\"\n\n"); -+ printf ("LABEL=\"libsane_scsi_rules_begin\"\n"); - printf ("KERNEL!=\"sg[0-9]*\", GOTO=\"libsane_rules_end\"\n\n"); - - printf ("# Generic: SCSI device type 6 indicates a scanner\n"); --- -1.8.4.2 - diff --git a/sane-backends-1.0.24-snprintf-cleanroom.patch b/sane-backends-1.0.24-snprintf-cleanroom.patch deleted file mode 100644 index 92cf72f..0000000 --- a/sane-backends-1.0.24-snprintf-cleanroom.patch +++ /dev/null @@ -1,1399 +0,0 @@ -From c5210e5a183c7f0dc90a142a6bc8da96d8a2738a Mon Sep 17 00:00:00 2001 -From: Nils Philippsen -Date: Mon, 8 Jun 2015 17:50:42 +0200 -Subject: [PATCH] patch: snprintf-license - -Squashed commit of the following: - -commit 1334efff1a6725f44d8ad11b8ba13ecf47e12ac6 -Author: Tom Callaway -Date: Thu May 29 11:40:08 2014 -0400 - - update lib/snprintf.c to newer version from LPRng - - The old version is licensed under the Artistic License 1.0 which isn't - compatible with the GPL and arguably non-free. - - Signed-off-by: Nils Philippsen - * fix trailing whitespace - - (cherry picked from commit aa0129c4e84264a6903d2a7884298834e1be0624) ---- - lib/snprintf.c | 1139 ++++++++++++++++++++++++++++++++++++++++++-------------- - 1 file changed, 863 insertions(+), 276 deletions(-) - -diff --git a/lib/snprintf.c b/lib/snprintf.c -index aca8df9..cdf6513 100644 ---- a/lib/snprintf.c -+++ b/lib/snprintf.c -@@ -2,180 +2,616 @@ - - #ifndef HAVE_SNPRINTF - --/*************************************************************************** -- * LPRng - An Extended Print Spooler System -- * -- * Copyright 1988-1997, Patrick Powell, San Diego, CA -- * papowell@sdsu.edu -- * See below for conditions of use. -- * -- *************************************************************************** -- * MODULE: snprintf.c -- * PURPOSE: LPRng version of printf - absolutely bombproof (hopefully!) -+/************************************************************************** -+ * Copyright 1994-2003 Patrick Powell, San Diego, CA - **************************************************************************/ --#if 0 - -- The "Artistic License" -+/* -+ Overview: - -- Preamble -+ snprintf( char *buffer, int len, const char *format,...) -+ plp_unsafe_snprintf( char *buffer, int len, const char *format,...) -+ its horribly unsafe companion that does NOT protect you from -+ the printing of evil control characters, but may be necessary -+ See the man page documentation below - --The intent of this document is to state the conditions under which a --Package may be copied, such that the Copyright Holder maintains some --semblance of artistic control over the development of the package, --while giving the users of the package the right to use and distribute --the Package in a more-or-less customary fashion, plus the right to make --reasonable modifications. -+ This version of snprintf was developed originally for printing -+ on a motley collection of specialized hardware that had NO IO -+ library. Due to contractual restrictions, a clean room implementation -+ of the printf() code had to be developed. - --Definitions: -+ The method chosen for printf was to be as paranoid as possible, -+ as these platforms had NO memory protection, and very small -+ address spaces. This made it possible to try to print -+ very long strings, i.e. - all of memory, very easily. To guard -+ against this, all printing was done via a buffer, generous enough -+ to hold strings, but small enough to protect against overruns, -+ etc. - -- "Package" refers to the collection of files distributed by the -- Copyright Holder, and derivatives of that collection of files -- created through textual modification. -+ Strangely enough, this proved to be of immense importance when -+ SPRINTFing to a buffer on a stack... The rest, of course, is -+ well known, as buffer overruns in the stack are a common way to -+ do horrible things to operating systems, security, etc etc. - -- "Standard Version" refers to such a Package if it has not been -- modified, or has been modified in accordance with the wishes -- of the Copyright Holder as specified below. -+ This version of snprintf is VERY limited by modern standards. - -- "Copyright Holder" is whoever is named in the copyright or -- copyrights for the package. -+ Revision History: -+ First Released Version - 1994. This version had NO comments. -+ First Released Version - 1994. This version had NO comments. -+ Second Major Released Version - Tue May 23 10:43:44 PDT 2000 -+ Configuration and other items changed. Read this doc. -+ Treat this as a new version. -+ Minor Revision - Mon Apr 1 09:41:28 PST 2002 -+ - fixed up some constants and casts - -- "You" is you, if you are thinking about copying or distributing -- this Package. -+ COPYRIGHT AND TERMS OF USE: - -- "Reasonable copying fee" is whatever you can justify on the -- basis of media cost, duplication charges, time of people involved, -- and so on. (You will not be required to justify it to the -- Copyright Holder, but only to the computing community at large -- as a market that must bear the fee.) -+ You may use, copy, distribute, or otherwise incorporate this software -+ and documentation into any product or other item, provided that -+ the copyright in the documentation and source code as well as the -+ source code generated constant strings in the object, executable -+ or other code remain in place and are present in executable modules -+ or objects. - -- "Freely Available" means that no fee is charged for the item -- itself, though there may be fees involved in handling the item. -- It also means that recipients of the item may redistribute it -- under the same conditions they received it. -+ You may modify this code as appropriate to your usage; however the -+ modified version must be identified by changing the various source -+ and object code identification strings as is appropriately noted -+ in the source code. - --1. You may make and give away verbatim copies of the source form of the --Standard Version of this Package without restriction, provided that you --duplicate all of the original copyright notices and associated disclaimers. -+ You can use this with the GNU CONFIGURE utility. -+ This should define the following macros appropriately: - --2. You may apply bug fixes, portability fixes and other modifications --derived from the Public Domain or from the Copyright Holder. A Package --modified in such a way shall still be considered the Standard Version. -+ HAVE_STDARG_H - if the include file is available -+ HAVE_VARARG_H - if the include file is available - --3. You may otherwise modify your copy of this Package in any way, provided --that you insert a prominent notice in each changed file stating how and --when you changed that file, and provided that you do at least ONE of the --following: -+ HAVE_STRERROR - if the strerror() routine is available. -+ If it is not available, then examine the lines containing -+ the tests below. - -- a) place your modifications in the Public Domain or otherwise make them -- Freely Available, such as by posting said modifications to Usenet or -- an equivalent medium, or placing the modifications on a major archive -- site such as uunet.uu.net, or by allowing the Copyright Holder to include -- your modifications in the Standard Version of the Package. -+ HAVE_SYS_ERRLIST - have sys_errlist available -+ HAVE_DECL_SYS_ERRLIST - sys_errlist declaration in include files -+ HAVE_SYS_NERR - have sys_nerr available -+ HAVE_DECL_SYS_NERR - sys_nerr declaration in include files - -- b) use the modified Package only within your corporation or organization. -+ HAVE_QUAD_T - if the quad_t type is defined -+ HAVE_LONG_LONG - if the long long type is defined -+ HAVE_LONG_DOUBLE - if the long double type is defined - -- c) rename any non-standard executables so the names do not conflict -- with standard executables, which must also be provided, and provide -- a separate manual page for each non-standard executable that clearly -- documents how it differs from the Standard Version. -+ If you are using the GNU configure (autoconf) facility, add the -+ following line to the configure.in file, to force checking for the -+ quad_t and long long data types: - -- d) make other distribution arrangements with the Copyright Holder. - --4. You may distribute the programs of this Package in object code or --executable form, provided that you do at least ONE of the following: -+ AC_CHECK_HEADERS(stdlib.h,stdio.h,unistd.h,errno.h) -+ AC_CHECK_FUNCS(strerror) -+ AC_CACHE_CHECK(for errno, -+ ac_cv_errno, -+ [ -+ AC_TRY_LINK(,[extern int errno; return (errno);], -+ ac_cv_errno=yes, ac_cv_errno=no) -+ ]) -+ if test "$ac_cv_errno" = yes; then -+ AC_DEFINE(HAVE_ERRNO) -+ AC_CACHE_CHECK(for errno declaration, -+ ac_cv_decl_errno, -+ [ -+ AC_TRY_COMPILE([ -+ #include -+ #ifdef HAVE_STDLIB_H -+ #include -+ #endif -+ #ifdef HAVE_UNISTD_H -+ #include -+ #endif -+ #ifdef HAVE_ERRNO_H -+ #include -+ ],[return(sys_nerr);], -+ ac_cv_decl_errno=yes, ac_cv_decl_errno=no) -+ ]) -+ if test "$ac_cv_decl_errno" = yes; then -+ AC_DEFINE(HAVE_DECL_ERRNO) -+ fi; -+ fi - -- a) distribute a Standard Version of the executables and library files, -- together with instructions (in the manual page or equivalent) on where -- to get the Standard Version. -+ AC_CACHE_CHECK(for sys_nerr, -+ ac_cv_sys_nerr, -+ [ -+ AC_TRY_LINK(,[extern int sys_nerr; return (sys_nerr);], -+ ac_cv_sys_nerr=yes, ac_cv_sys_nerr=no) -+ ]) -+ if test "$ac_cv_sys_nerr" = yes; then -+ AC_DEFINE(HAVE_SYS_NERR) -+ AC_CACHE_CHECK(for sys_nerr declaration, -+ ac_cv_decl_sys_nerr, -+ [ -+ AC_TRY_COMPILE([ -+ #include -+ #ifdef HAVE_STDLIB_H -+ #include -+ #endif -+ #ifdef HAVE_UNISTD_H -+ #include -+ #endif],[return(sys_nerr);], -+ ac_cv_decl_sys_nerr_def=yes, ac_cv_decl_sys_nerr_def=no) -+ ]) -+ if test "$ac_cv_decl_sys_nerr" = yes; then -+ AC_DEFINE(HAVE_DECL_SYS_NERR) -+ fi -+ fi - -- b) accompany the distribution with the machine-readable source of -- the Package with your modifications. - -- c) give non-standard executables non-standard names, and clearly -- document the differences in manual pages (or equivalent), together -- with instructions on where to get the Standard Version. -+ AC_CACHE_CHECK(for sys_errlist array, -+ ac_cv_sys_errlist, -+ [AC_TRY_LINK(,[extern char *sys_errlist[]; -+ sys_errlist[0];], -+ ac_cv_sys_errlist=yes, ac_cv_sys_errlist=no) -+ ]) -+ if test "$ac_cv_sys_errlist" = yes; then -+ AC_DEFINE(HAVE_SYS_ERRLIST) -+ AC_CACHE_CHECK(for sys_errlist declaration, -+ ac_cv_sys_errlist_def, -+ [AC_TRY_COMPILE([ -+ #include -+ #include -+ #ifdef HAVE_STDLIB_H -+ #include -+ #endif -+ #ifdef HAVE_UNISTD_H -+ #include -+ #endif],[char *s = sys_errlist[0]; return(*s);], -+ ac_cv_decl_sys_errlist=yes, ac_cv_decl_sys_errlist=no) -+ ]) -+ if test "$ac_cv_decl_sys_errlist" = yes; then -+ AC_DEFINE(HAVE_DECL_SYS_ERRLIST) -+ fi -+ fi - -- d) make other distribution arrangements with the Copyright Holder. - --5. You may charge a reasonable copying fee for any distribution of this --Package. You may charge any fee you choose for support of this --Package. You may not charge a fee for this Package itself. However, --you may distribute this Package in aggregate with other (possibly --commercial) programs as part of a larger (possibly commercial) software --distribution provided that you do not advertise this Package as a --product of your own. - --6. The name of the Copyright Holder may not be used to endorse or promote --products derived from this software without specific prior written permission. -+ AC_CACHE_CHECK(checking for long long, -+ ac_cv_long_long, -+ [ -+ AC_TRY_COMPILE([ -+ #include -+ #include -+ ], [printf("%d",sizeof(long long));], -+ ac_cv_long_long=yes, ac_cv_long_long=no) -+ ]) -+ if test $ac_cv_long_long = yes; then -+ AC_DEFINE(HAVE_LONG_LONG) -+ fi - --7. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR --IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED --WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. -+ AC_CACHE_CHECK(checking for long double, -+ ac_cv_long_double, -+ [ -+ AC_TRY_COMPILE([ -+ #include -+ #include -+ ], [printf("%d",sizeof(long double));], -+ ac_cv_long_double=yes, ac_cv_long_double=no) -+ ]) -+ if test $ac_cv_long_double = yes; then -+ AC_DEFINE(HAVE_LONG_DOUBLE) -+ fi - -- The End --#include "lp.h" --#endif -+ AC_CACHE_CHECK(checking for quad_t, -+ ac_cv_quad_t, -+ [ -+ AC_TRY_COMPILE([ -+ #include -+ #include -+ ], [printf("%d",sizeof(quad_t));], -+ ac_cv_quad_t=yes, ac_cv_quad_t=no) -+ ]) -+ if test $ac_cv_quad_t = yes; then -+ AC_DEFINE(HAVE_QUAD_T) -+ fi - --#include --#include --#include --#define HAVE_STDARGS /* let's hope that works everywhere (mj) */ --#define VA_LOCAL_DECL va_list ap; --#define VA_START(f) va_start(ap, f) --#define VA_SHIFT(v,t) ; /* no-op for ANSI */ --#define VA_END va_end(ap) - --/**** ENDINCLUDE ****/ - --static char *const _id = "$Id$"; -+ NAME -+ snprintf, plp_vsnprintf - formatted output conversion -+ -+ SYNOPSIS -+ #include -+ #include -+ -+ int -+ snprintf(const char *format, size_t size, va_list ap); -+ int -+ plp_unsafe_snprintf(const char *format, size_t size, va_list ap); -+ -+ AKA snprintf and unsafe_snprintf in the documentation below -+ -+ int -+ vsnprintf(char *str, size_t size, const char *format, va_list ap); -+ int -+ unsafe_vsnprintf(char *str, size_t size, const char *format, va_list ap); -+ -+ AKA vsnprintf and unsafe_vsnprintf in the documentation below -+ -+ (Multithreaded Safe) -+ -+ DESCRIPTION -+ The printf() family of functions produces output according to -+ a format as described below. Snprintf(), and vsnprintf() -+ write to the character string str. These functions write the -+ output under the control of a format string that specifies -+ how subsequent arguments (or arguments accessed via the -+ variable-length argument facilities of stdarg(3)) are converted -+ for output. These functions return the number of characters -+ printed (not including the trailing `\0' used to end output -+ to strings). Snprintf() and vsnprintf() will write at most -+ size-1 of the characters printed into the output string (the -+ size'th character then gets the terminating `\0'); if the -+ return value is greater than or equal to the size argument, -+ the string was too short and some of the printed characters -+ were discarded. The size or str may be given as zero to find -+ out how many characters are needed; in this case, the str -+ argument is ignored. -+ -+ By default, the snprintf function will not format control -+ characters (except new line and tab) in strings. This is a -+ safety feature that has proven to be extremely critical when -+ using snprintf for secure applications and when debugging. -+ If you MUST have control characters formatted or printed, -+ then use the unsafe_snprintf() and unsafe_vsnprintf() and on -+ your own head be the consequences. You have been warned. -+ -+ There is one exception to the comments above, and that is -+ the "%c" (character) format. It brutally assumes that the -+ user will have performed the necessary 'isprint()' or other -+ checks and uses the integer value as a character. -+ -+ The format string is composed of zero or more directives: -+ ordinary characters (not %), which are copied unchanged to -+ the output stream; and conversion specifications, each -+ of which results in fetching zero or more subsequent arguments. -+ Each conversion specification is introduced by the character -+ %. The arguments must correspond properly (after type promotion) -+ with the conversion specifier. After the %, the following -+ appear in sequence: -+ -+ o Zero or more of the following flags: -+ -+ - A zero `0' character specifying zero padding. For -+ all conversions except n, the converted value is padded -+ on the left with zeros rather than blanks. If a -+ precision is given with a numeric conversion (d, i, -+ o, u, i, x, and X), the `0' flag is ignored. -+ -+ - A negative field width flag `-' indicates the converted -+ value is to be left adjusted on the field boundary. Except -+ for n conversions, the converted value is padded on -+ the right with blanks, rather than on the left with -+ blanks or zeros. A `-' overrides a `0' if both are -+ given. -+ -+ - A space, specifying that a blank should be left before -+ a positive number produced by a signed conversion (d, e, E, f, -+ g, G, or i). -+ -+ - A `+' character specifying that a sign always be placed -+ before a number produced by a signed conversion. A `+' overrides -+ a space if both are used. -+ -+ o An optional decimal digit string specifying a minimum -+ field width. If the converted value has fewer -+ characters than the field width, it will be padded -+ with spaces on the left (or right, if the -+ left-adjustment flag has been given) to fill out -+ the field width. -+ -+ o An optional precision, in the form of a period `.' followed -+ by an optional digit string. If the digit string -+ is omitted, the precision is taken as zero. This -+ gives the minimum number of digits to appear for -+ d, i, o, u, x, and X conversions, the number of -+ digits to appear after the decimal-point for e, -+ E, and f conversions, the maximum number of -+ significant digits for g and G conversions, or -+ the maximum number of characters to be printed -+ from a string for s conversions. -+ -+ o The optional character h, specifying that a following d, -+ i, o, u, x, or X conversion corresponds to a short -+ int or unsigned short int argument, or that a -+ following n conversion corresponds to a pointer -+ to a short int argument. -+ -+ o The optional character l (ell) specifying that a following -+ d, i, o, u, x, or X conversion applies to a pointer -+ to a long int or unsigned long int argument, or -+ that a following n conversion corresponds to a -+ pointer to a long int argument. -+ -+ o The optional character q, specifying that a following d, -+ i, o, u, x, or X conversion corresponds to a quad_t -+ or u_quad_t argument, or that a following n -+ conversion corresponds to a quad_t argument. -+ This value is always printed in HEX notation. Tough. -+ quad_t's are an OS system implementation, and should -+ not be allowed. -+ -+ o The character L specifying that a following e, E, f, g, -+ or G conversion corresponds to a long double -+ argument. -+ -+ o A character that specifies the type of conversion to be applied. -+ -+ -+ A field width or precision, or both, may be indicated by an asterisk `*' -+ instead of a digit string. In this case, an int argument supplies the -+ field width or precision. A negative field width is treated as a left -+ adjustment flag followed by a positive field width; a negative precision -+ is treated as though it were missing. -+ -+ The conversion specifiers and their meanings are: -+ -+ diouxX The int (or appropriate variant) argument is converted to signed -+ decimal (d and i), unsigned octal (o), unsigned decimal -+ (u), or unsigned hexadecimal (x and X) notation. The -+ letters abcdef are used for x conversions; the letters -+ ABCDEF are used for X conversions. The precision, if -+ any, gives the minimum number of digits that must -+ appear; if the converted value requires fewer digits, -+ it is padded on the left with zeros. -+ -+ eE The double argument is rounded and converted in the style -+ [-]d.ddde+-dd where there is one digit before the decimal-point -+ character and the number of digits after it is equal -+ to the precision; if the precision is missing, it is -+ taken as 6; if the precision is zero, no decimal-point -+ character appears. An E conversion uses the letter -+ E (rather than e) to introduce the exponent. -+ The exponent always contains at least two digits; if -+ the value is zero, the exponent is 00. -+ -+ f The double argument is rounded and converted to decimal notation -+ in the style [-]ddd.ddd, where the number of digits after the -+ decimal-point character is equal to the precision specification. -+ If the precision is missing, it is taken as 6; if the precision -+ is explicitly zero, no decimal-point character appears. If a -+ decimal point appears, at least one digit appears before it. -+ -+ g The double argument is converted in style f or e (or -+ E for G conversions). The precision specifies the -+ number of significant digits. If the precision is -+ missing, 6 digits are given; if the precision is zero, -+ it is treated as 1. Style e is used if the exponent -+ from its conversion is less than -4 or greater than -+ or equal to the precision. Trailing zeros are removed -+ from the fractional part of the result; a decimal -+ point appears only if it is followed by at least one -+ digit. -+ -+ c The int argument is converted to an unsigned char, -+ and the resulting character is written. -+ -+ s The ``char *'' argument is expected to be a pointer to an array -+ of character type (pointer to a string). Characters -+ from the array are written up to (but not including) -+ a terminating NUL character; if a precision is -+ specified, no more than the number specified are -+ written. If a precision is given, no null character -+ need be present; if the precision is not specified, -+ or is greater than the size of the array, the array -+ must contain a terminating NUL character. -+ -+ % A `%' is written. No argument is converted. The complete -+ conversion specification is `%%'. -+ -+ In no case does a non-existent or small field width cause truncation of a -+ field; if the result of a conversion is wider than the field width, the -+ field is expanded to contain the conversion result. -+ -+ EXAMPLES -+ To print a date and time in the form `Sunday, July 3, 10:02', where -+ weekday and month are pointers to strings: -+ -+ #include -+ fprintf(stdout, "%s, %s %d, %.2d:%.2d\n", -+ weekday, month, day, hour, min); -+ -+ To print pi to five decimal places: -+ -+ #include -+ #include -+ fprintf(stdout, "pi = %.5f\n", 4 * atan(1.0)); -+ -+ To allocate a 128 byte string and print into it: -+ -+ #include -+ #include -+ #include -+ char *newfmt(const char *fmt, ...) -+ { -+ char *p; -+ va_list ap; -+ if ((p = malloc(128)) == NULL) -+ return (NULL); -+ va_start(ap, fmt); -+ (void) vsnprintf(p, 128, fmt, ap); -+ va_end(ap); -+ return (p); -+ } -+ -+ SEE ALSO -+ printf(1), scanf(3) -+ -+ STANDARDS -+ Turkey C Standardization and wimpy POSIX folks did not define -+ snprintf or vsnprintf(). -+ -+ BUGS -+ The conversion formats %D, %O, and %U are not standard and are provided -+ only for backward compatibility. The effect of padding the %p format -+ with zeros (either by the `0' flag or by specifying a precision), and the -+ benign effect (i.e., none) of the `#' flag on %n and %p conversions, as -+ well as other nonsensical combinations such as %Ld, are not standard; -+ such combinations should be avoided. -+ -+ The typedef names quad_t and u_quad_t are infelicitous. -+ -+*/ -+ -+ -+#include -+#include -+#include -+#include -+#if defined(HAVE_STRING_H) -+# include -+#endif -+#if defined(HAVE_STRINGS_H) -+# include -+#endif -+#if defined(HAVE_ERRNO_H) -+#include -+#endif - - /* -- * dopr(): poor man's version of doprintf -+ * For testing, define these values - */ -+#if 0 -+#define HAVE_STDARG_H 1 -+#define TEST 1 -+#define HAVE_QUAD_T 1 -+#endif -+ -+/**** ENDINCLUDE ****/ -+ -+/************************************************* -+ * KEEP THIS STRING - MODIFY AT THE END WITH YOUR REVISIONS -+ * i.e. - the LOCAL REVISIONS part is for your use -+ *************************************************/ -+ -+ -+ static char *const _id = "plp_snprintf V2000.08.18 Copyright Patrick Powell 1988-2000 " -+ "$Id: plp_snprintf.c,v 1.4 2005/04/14 20:05:19 papowell Exp $" -+ " LOCAL REVISIONS: renamed plp_snprintf to snprintf, conditionalized everything on HAVE_SNPRINTF"; -+ -+/* varargs declarations: */ -+ -+# undef HAVE_STDARGS /* let's hope that works everywhere (mj) */ -+# undef VA_LOCAL_DECL -+# undef VA_START -+# undef VA_SHIFT -+# undef VA_END -+ -+#if defined(HAVE_STDARG_H) -+# include -+# define HAVE_STDARGS /* let's hope that works everywhere (mj) */ -+# define VA_LOCAL_DECL va_list ap; -+# define VA_START(f) va_start(ap, f) -+# define VA_SHIFT(v,t) ; /* no-op for ANSI */ -+# define VA_END va_end(ap) -+#else -+# if defined(HAVE_VARARGS_H) -+# include -+# undef HAVE_STDARGS -+# define VA_LOCAL_DECL va_list ap; -+# define VA_START(f) va_start(ap) /* f is ignored! */ -+# define VA_SHIFT(v,t) v = va_arg(ap,t) -+# define VA_END va_end(ap) -+# else -+ XX ** NO VARARGS ** XX -+# endif -+#endif - --static char * plp_Errormsg ( int err ); --static void dopr( char *buffer, const char *format, va_list args ); --static void fmtstr( char *value, int ljust, int len, int zpad, int precision ); --static void fmtnum( long value, int base, int dosign, -+ union value { -+#if defined(HAVE_QUAD_T) -+ quad_t qvalue; -+#endif -+#if defined(HAVE_LONG_LONG) -+ long long value; -+#else -+ long value; -+#endif -+ double dvalue; -+}; -+ -+#undef CVAL -+#define CVAL(s) (*((unsigned char *)s)) -+#define safestrlen(s) ((s)?strlen(s):0) -+ -+ -+ static char * plp_Errormsg ( int err, char *buffer ); -+ static void dopr( int visible_control, char **buffer, int *left, -+ const char *format, va_list args ); -+ static void fmtstr( int visible_control, char **buffer, int *left, -+ char *value, int ljust, int len, int zpad, int precision ); -+ static void fmtnum( char **buffer, int *left, -+ union value *value, int base, int dosign, -+ int ljust, int len, int zpad, int precision ); -+#if defined(HAVE_QUAD_T) -+ static void fmtquad( char **buffer, int *left, -+ union value *value, int base, int dosign, - int ljust, int len, int zpad, int precision ); --static void fmtdouble( int fmt, double value, -+#endif -+ static void fmtdouble( char **bufer, int *left, -+ int fmt, double value, - int ljust, int len, int zpad, int precision ); --static void dostr( char * ); --static char *output; --static void dopr_outch( int c ); --static char *end; --int visible_control = 1; -- --/************************************************************** -- * Original: -- * Patrick Powell Tue Apr 11 09:48:21 PDT 1995 -- * A bombproof version of doprnt (dopr) included. -- * Sigh. This sort of thing is always nasty do deal with. Note that -- * the version here does not include floating point... -- * -- * plp_snprintf() is used instead of sprintf() as it does limit checks -- * for string length. This covers a nasty loophole. -- * -- * The other functions are there to prevent NULL pointers from -- * causing nast effects. -- **************************************************************/ -- --int vsnprintf(char *str, size_t count, const char *fmt, va_list args) -+ static void dostr( char **buffer, int *left, char *str ); -+ static void dopr_outch( char **buffer, int *left, int c ); -+/* VARARGS3 */ -+#ifdef HAVE_STDARGS -+ int plp_vsnprintf(char *str, size_t count, const char *fmt, va_list args) -+#else -+ int plp_vsnprintf(char *str, size_t count, const char *fmt, va_list args) -+#endif -+ -+{ -+ int left; -+ char *buffer; -+ if( (int)count < 0 ) count = 0; -+ left = count; -+ if( count == 0 ) str = 0; -+ buffer = str; -+ dopr( 1, &buffer, &left, fmt, args ); -+ /* fprintf(stderr,"str 0x%x, buffer 0x%x, count %d, left %d\n", -+ (int)str, (int)buffer, count, left ); */ -+ if( str && count > 0 ){ -+ if( left > 0 ){ -+ str[count-left] = 0; -+ } else { -+ str[count-1] = 0; -+ } -+ } -+ return(count - left); -+} -+ -+/* VARARGS3 */ -+#ifdef HAVE_STDARGS -+ int plp_unsafe_vsnprintf(char *str, size_t count, const char *fmt, va_list args) -+#else -+ int plp_unsafe_vsnprintf(char *str, size_t count, const char *fmt, va_list args) -+#endif - { -- str[0] = 0; -- end = str+count-1; -- dopr( str, fmt, args ); -- if( count>0 ){ -- end[0] = 0; -+ int left; -+ char *buffer; -+ if( (int)count < 0 ) count = 0; -+ left = count; -+ if( count == 0 ) str = 0; -+ buffer = str; -+ dopr( 0, &buffer, &left, fmt, args ); -+ /* fprintf(stderr,"str 0x%x, buffer 0x%x, count %d, left %d\n", -+ (int)str, (int)buffer, count, left ); */ -+ if( str && count > 0 ){ -+ if( left > 0 ){ -+ str[count-left] = 0; -+ } else { -+ str[count-1] = 0; -+ } - } -- return(strlen(str)); -+ return(count - left); - } - - /* VARARGS3 */ - #ifdef HAVE_STDARGS --int snprintf (char *str,size_t count,const char *fmt,...) -+ int snprintf (char *str,size_t count,const char *fmt,...) - #else --int snprintf (va_alist) va_dcl -+ int snprintf (va_alist) va_dcl - #endif - { - #ifndef HAVE_STDARGS -@@ -183,22 +619,48 @@ int snprintf (va_alist) va_dcl - size_t count; - char *fmt; - #endif -+ int n = 0; - VA_LOCAL_DECL - - VA_START (fmt); - VA_SHIFT (str, char *); - VA_SHIFT (count, size_t ); - VA_SHIFT (fmt, char *); -- (void) vsnprintf ( str, count, fmt, ap); -+ n = plp_vsnprintf ( str, count, fmt, ap); - VA_END; -- return( strlen( str ) ); -+ return( n ); - } - --static void dopr( char *buffer, const char *format, va_list args ) -+ -+/* VARARGS3 */ -+#ifdef HAVE_STDARGS -+ int plp_unsafe_snprintf (char *str,size_t count,const char *fmt,...) -+#else -+ int plp_unsafe_snprintf (va_alist) va_dcl -+#endif -+{ -+#ifndef HAVE_STDARGS -+ char *str; -+ size_t count; -+ char *fmt; -+#endif -+ int n = 0; -+ VA_LOCAL_DECL -+ -+ VA_START (fmt); -+ VA_SHIFT (str, char *); -+ VA_SHIFT (count, size_t ); -+ VA_SHIFT (fmt, char *); -+ n = plp_unsafe_vsnprintf ( str, count, fmt, ap); -+ VA_END; -+ return( n ); -+} -+ static void dopr( int visible_control, char **buffer, int *left, const char *format, va_list args ) - { - int ch; -- long value; -+ union value value; - int longflag = 0; -+ int quadflag = 0; - char *strvalue; - int ljust; - int len; -@@ -207,22 +669,30 @@ static void dopr( char *buffer, const char *format, va_list args ) - int set_precision; - double dval; - int err = errno; -+ int base = 0; -+ int signed_val = 0; - -- output = buffer; - while( (ch = *format++) ){ - switch( ch ){ - case '%': -- ljust = len = zpad = 0; -+ longflag = quadflag = -+ ljust = len = zpad = base = signed_val = 0; - precision = -1; set_precision = 0; -- nextch: -+ nextch: - ch = *format++; - switch( ch ){ - case 0: -- dostr( "**end of format**" ); -+ dostr( buffer, left, "**end of format**" ); - return; - case '-': ljust = 1; goto nextch; - case '.': set_precision = 1; precision = 0; goto nextch; -- case '*': len = va_arg( args, int ); goto nextch; -+ case '*': -+ if( set_precision ){ -+ precision = va_arg( args, int ); -+ } else { -+ len = va_arg( args, int ); -+ } -+ goto nextch; - case '0': /* set zero padding if len not set */ - if(len==0 && set_precision == 0 ) zpad = '0'; - case '1': case '2': case '3': -@@ -234,76 +704,91 @@ static void dopr( char *buffer, const char *format, va_list args ) - len = len*10 + ch - '0'; - } - goto nextch; -- case 'l': longflag = 1; goto nextch; -+ case 'l': ++longflag; goto nextch; -+ case 'q': -+#if !defined( HAVE_QUAD_T ) -+ dostr( buffer, left, "*no quad_t support *"); -+ return; -+#endif -+ quadflag = 1; -+ goto nextch; - case 'u': case 'U': -- /*fmtnum(value,base,dosign,ljust,len, zpad, precision) */ -- if( longflag ){ -- value = va_arg( args, long ); -- } else { -- value = va_arg( args, int ); -- } -- fmtnum( value, 10,0, ljust, len, zpad, precision ); break; -+ if( base == 0 ){ base = 10; signed_val = 0; } - case 'o': case 'O': -- /*fmtnum(value,base,dosign,ljust,len, zpad, precision) */ -- if( longflag ){ -- value = va_arg( args, long ); -- } else { -- value = va_arg( args, int ); -- } -- fmtnum( value, 8,0, ljust, len, zpad, precision ); break; -+ if( base == 0 ){ base = 8; signed_val = 0; } - case 'd': case 'D': -- if( longflag ){ -- value = va_arg( args, long ); -- } else { -- value = va_arg( args, int ); -- } -- fmtnum( value, 10,1, ljust, len, zpad, precision ); break; -+ if( base == 0 ){ base = 10; signed_val = 1; } - case 'x': -- if( longflag ){ -- value = va_arg( args, long ); -- } else { -- value = va_arg( args, int ); -- } -- fmtnum( value, 16,0, ljust, len, zpad, precision ); break; -+ if( base == 0 ){ base = 16; signed_val = 0; } - case 'X': -- if( longflag ){ -- value = va_arg( args, long ); -+ if( base == 0 ){ base = -16; signed_val = 0; } -+#if defined( HAVE_QUAD_T ) -+ if( quadflag ){ -+ value.qvalue = va_arg( args, quad_t ); -+ fmtquad( buffer, left, &value,base,signed_val, ljust, len, zpad, precision ); -+ break; -+ } else -+#endif -+ if( longflag > 1 ){ -+#if defined(HAVE_LONG_LONG) -+ if( signed_val ){ -+ value.value = va_arg( args, long long ); -+ } else { -+ value.value = va_arg( args, unsigned long long ); -+ } -+#else -+ if( signed_val ){ -+ value.value = va_arg( args, long ); -+ } else { -+ value.value = va_arg( args, unsigned long ); -+ } -+#endif -+ } else if( longflag ){ -+ if( signed_val ){ -+ value.value = va_arg( args, long ); -+ } else { -+ value.value = va_arg( args, unsigned long ); -+ } - } else { -- value = va_arg( args, int ); -+ if( signed_val ){ -+ value.value = va_arg( args, int ); -+ } else { -+ value.value = va_arg( args, unsigned int ); -+ } - } -- fmtnum( value,-16,0, ljust, len, zpad, precision ); break; -+ fmtnum( buffer, left, &value,base,signed_val, ljust, len, zpad, precision ); break; - case 's': - strvalue = va_arg( args, char *); -- fmtstr( strvalue,ljust,len, zpad, precision ); -+ fmtstr( visible_control, buffer, left, strvalue,ljust,len, zpad, precision ); - break; - case 'c': - ch = va_arg( args, int ); - { char b[2]; -- int vsb = visible_control; - b[0] = ch; - b[1] = 0; -- visible_control = 0; -- fmtstr( b,ljust,len, zpad, precision ); -- visible_control = vsb; -+ fmtstr( 0, buffer, left, b,ljust,len, zpad, precision ); - } - break; -- case 'f': case 'g': -+ case 'f': case 'g': case 'e': - dval = va_arg( args, double ); -- fmtdouble( ch, dval,ljust,len, zpad, precision ); break; -+ fmtdouble( buffer, left, ch, dval,ljust,len, zpad, precision ); break; - case 'm': -- fmtstr( plp_Errormsg(err),ljust,len, zpad, precision ); break; -- case '%': dopr_outch( ch ); continue; -+ { char shortbuffer[32]; -+ fmtstr( visible_control, buffer, left, -+ plp_Errormsg(err, shortbuffer),ljust,len, zpad, precision ); -+ } -+ break; -+ case '%': dopr_outch( buffer, left, ch ); continue; - default: -- dostr( "???????" ); -+ dostr( buffer, left, "???????" ); - } - longflag = 0; - break; - default: -- dopr_outch( ch ); -+ dopr_outch( buffer, left, ch ); - break; - } - } -- *output = 0; - } - - /* -@@ -312,63 +797,69 @@ static void dopr( char *buffer, const char *format, va_list args ) - * len = minimum length - * precision = numbers of chars in string to use - */ --static void --fmtstr( char *value, int ljust, int len, int zpad, int precision ) -+ static void -+ fmtstr( int visible_control, char **buffer, int *left, -+ char *value, int ljust, int len, int zpad, int precision ) - { -- int padlen, strlen, i, c; /* amount to pad */ -+ int padlen, strlenv, i, c; /* amount to pad */ - - if( value == 0 ){ - value = ""; - } -- if( precision > 0 ){ -- strlen = precision; -- } else { -- /* cheap strlen so you do not have library call */ -- for( strlen = 0; (c=value[strlen]); ++ strlen ){ -- if( visible_control && iscntrl( c ) && !isspace( c ) ){ -- ++strlen; -- } -+ /* cheap strlen so you do not have library call */ -+ for( strlenv = i = 0; (c=CVAL(value+i)); ++i ){ -+ if( visible_control && iscntrl( c ) && c != '\t' && c != '\n' ){ -+ ++strlenv; - } -+ ++strlenv; -+ } -+ if( precision > 0 && strlenv > precision ){ -+ strlenv = precision; - } -- padlen = len - strlen; -+ padlen = len - strlenv; - if( padlen < 0 ) padlen = 0; - if( ljust ) padlen = -padlen; - while( padlen > 0 ) { -- dopr_outch( ' ' ); -+ dopr_outch( buffer, left, ' ' ); - --padlen; - } - /* output characters */ -- for( i = 0; (c = value[i]); ++i ){ -- if( visible_control && iscntrl( c ) && !isspace( c ) ){ -- dopr_outch('^'); -+ for( i = 0; i < strlenv && (c = CVAL(value+i)); ++i ){ -+ if( visible_control && iscntrl( c ) && c != '\t' && c != '\n' ){ -+ dopr_outch(buffer, left, '^'); - c = ('@' | (c & 0x1F)); - } -- dopr_outch(c); -+ dopr_outch(buffer, left, c); - } - while( padlen < 0 ) { -- dopr_outch( ' ' ); -+ dopr_outch( buffer, left, ' ' ); - ++padlen; - } - } - --static void --fmtnum( long value, int base, int dosign, int ljust, -+ static void -+ fmtnum( char **buffer, int *left, -+ union value *value, int base, int dosign, int ljust, - int len, int zpad, int precision ) - { - int signvalue = 0; -+#if defined(HAVE_LONG_LONG) -+ unsigned long long uvalue; -+#else - unsigned long uvalue; -- char convert[20]; -+#endif -+ char convert[sizeof( union value) * 8 + 16]; - int place = 0; - int padlen = 0; /* amount to pad */ - int caps = 0; - -- /* DEBUGP(("value 0x%x, base %d, dosign %d, ljust %d, len %d, zpad %d\n", -- value, base, dosign, ljust, len, zpad )); */ -- uvalue = value; -+ /* fprintf(stderr,"value 0x%x, base %d, dosign %d, ljust %d, len %d, zpad %d\n", -+ value, base, dosign, ljust, len, zpad );/ **/ -+ uvalue = value->value; - if( dosign ){ -- if( value < 0 ) { -+ if( value->value < 0 ) { - signvalue = '-'; -- uvalue = -value; -+ uvalue = -value->value; - } - } - if( base < 0 ){ -@@ -385,71 +876,148 @@ fmtnum( long value, int base, int dosign, int ljust, - padlen = len - place; - if( padlen < 0 ) padlen = 0; - if( ljust ) padlen = -padlen; -- /* DEBUGP(( "str '%s', place %d, sign %c, padlen %d\n", -- convert,place,signvalue,padlen)); */ -+ /* fprintf( stderr, "str '%s', place %d, sign %c, padlen %d\n", -+ convert,place,signvalue,padlen); / **/ - if( zpad && padlen > 0 ){ - if( signvalue ){ -- dopr_outch( signvalue ); -+ dopr_outch( buffer, left, signvalue ); - --padlen; - signvalue = 0; - } - while( padlen > 0 ){ -- dopr_outch( zpad ); -+ dopr_outch( buffer, left, zpad ); - --padlen; - } - } - while( padlen > 0 ) { -- dopr_outch( ' ' ); -+ dopr_outch( buffer, left, ' ' ); - --padlen; - } -- if( signvalue ) dopr_outch( signvalue ); -- while( place > 0 ) dopr_outch( convert[--place] ); -+ if( signvalue ) dopr_outch( buffer, left, signvalue ); -+ while( place > 0 ) dopr_outch( buffer, left, convert[--place] ); - while( padlen < 0 ){ -- dopr_outch( ' ' ); -+ dopr_outch( buffer, left, ' ' ); - ++padlen; - } - } - --static void --fmtdouble( int fmt, double value, int ljust, int len, int zpad, int precision ) -+#if defined(HAVE_QUAD_T) -+ -+ static void -+ fmtquad( char **buffer, int *left, -+ union value *value, int base, int dosign, int ljust, -+ int len, int zpad, int precision ) - { -- char convert[128]; -- char fmtstr[128]; -- int l; -+ int signvalue = 0; -+ int place = 0; -+ int padlen = 0; /* amount to pad */ -+ int caps = 0; -+ int i, c; -+ union { -+ quad_t qvalue; -+ unsigned char qconvert[sizeof(quad_t)]; -+ } vvalue; -+ char convert[2*sizeof(quad_t)+1]; -+ -+ /* fprintf(stderr,"value 0x%x, base %d, dosign %d, ljust %d, len %d, zpad %d\n", -+ value, base, dosign, ljust, len, zpad );/ **/ -+ vvalue.qvalue = value->qvalue; -+ -+ if( base < 0 ){ -+ caps = 1; -+ } - -- if( len == 0 ) len = 10; -- if( len > sizeof(convert) - 10 ){ -- len = sizeof(convert) - 10; -+ for( i = 0; i < (int)sizeof(quad_t); ++i ){ -+ c = vvalue.qconvert[i]; -+ convert[2*i] = -+ (caps? "0123456789ABCDEF":"0123456789abcdef")[ (c >> 4) & 0xF]; -+ convert[2*i+1] = -+ (caps? "0123456789ABCDEF":"0123456789abcdef")[ c & 0xF]; - } -- if( precision > sizeof(convert) - 10 ){ -- precision = sizeof(convert) - 10; -+ convert[2*i] = 0; -+ -+ place = strlen(convert); -+ padlen = len - place; -+ if( padlen < 0 ) padlen = 0; -+ if( ljust ) padlen = -padlen; -+ /* fprintf( stderr, "str '%s', place %d, sign %c, padlen %d\n", -+ convert,place,signvalue,padlen); / **/ -+ if( zpad && padlen > 0 ){ -+ if( signvalue ){ -+ dopr_outch( buffer, left, signvalue ); -+ --padlen; -+ signvalue = 0; -+ } -+ while( padlen > 0 ){ -+ dopr_outch( buffer, left, zpad ); -+ --padlen; -+ } - } -- if( precision > len ) precision = len; -- strcpy( fmtstr, "%" ); -- if( ljust ) strcat(fmtstr, "-" ); -- if( len ){ -- sprintf( fmtstr+strlen(fmtstr), "%d", len ); -+ while( padlen > 0 ) { -+ dopr_outch( buffer, left, ' ' ); -+ --padlen; - } -- if( precision > 0 ){ -- sprintf( fmtstr+strlen(fmtstr), ".%d", precision ); -+ if( signvalue ) dopr_outch( buffer, left, signvalue ); -+ while( place > 0 ) dopr_outch( buffer, left, convert[--place] ); -+ while( padlen < 0 ){ -+ dopr_outch( buffer, left, ' ' ); -+ ++padlen; - } -- l = strlen( fmtstr ); -- fmtstr[l] = fmt; -- fmtstr[l+1] = 0; -- sprintf( convert, fmtstr, value ); -- dostr( convert ); - } - --static void dostr( char *str ) -+#endif -+ -+ static void mystrcat(char *dest, char *src ) - { -- while(*str) dopr_outch(*str++); -+ if( dest && src ){ -+ dest += safestrlen(dest); -+ strcpy(dest,src); -+ } -+} -+ -+ static void -+ fmtdouble( char **buffer, int *left, -+ int fmt, double value, int ljust, int len, int zpad, int precision ) -+{ -+ char convert[sizeof( union value) * 8 + 512]; -+ char formatstr[128]; -+ -+ /* fprintf(stderr,"len %d, precision %d\n", len, precision ); */ -+ if( len > 255 ){ -+ len = 255; -+ } -+ if( precision > 255 ){ -+ precision = 255; -+ } -+ if( precision >= 0 && len > 0 && precision > len ) precision = len; -+ strcpy( formatstr, "%" ); /* 1 */ -+ if( ljust ) mystrcat(formatstr, "-" ); /* 1 */ -+ if( zpad ) mystrcat(formatstr, "0" ); /* 1 */ -+ if( len >= 0 ){ -+ sprintf( formatstr+strlen(formatstr), "%d", len ); /* 3 */ -+ } -+ if( precision >= 0 ){ -+ sprintf( formatstr+strlen(formatstr), ".%d", precision ); /* 3 */ -+ } -+ /* format string will be at most 10 chars long ... */ -+ sprintf( formatstr+strlen(formatstr), "%c", fmt ); -+ /* this is easier than trying to do the portable dtostr */ -+ /* fprintf(stderr,"format string '%s'\n", formatstr); */ -+ sprintf( convert, formatstr, value ); -+ dostr( buffer, left, convert ); -+} -+ -+ static void dostr( char **buffer, int *left, char *str ) -+{ -+ if(str)while(*str) dopr_outch( buffer, left, *str++ ); - } - --static void dopr_outch( int c ) -+ static void dopr_outch( char **buffer, int *left, int c ) - { -- if( end == 0 || output < end ){ -- *output++ = c; -+ if( *left > 0 ){ -+ *(*buffer)++ = c; - } -+ *left -= 1; - } - - -@@ -461,29 +1029,26 @@ static void dopr_outch( int c ) - * Patrick Powell Tue Apr 11 08:05:05 PDT 1995 - ****************************************************************************/ - /****************************************************************************/ --#if !defined(HAVE_STRERROR) -- --# if defined(HAVE_SYS_NERR) --# if !defined(HAVE_SYS_NERR_DEF) -- extern int sys_nerr; --# endif --# define num_errors (sys_nerr) --# else --# define num_errors (-1) /* always use "errno=%d" */ --# endif - -+#if !defined(HAVE_STRERROR) -+# undef num_errors - # if defined(HAVE_SYS_ERRLIST) --# if !defined(HAVE_SYS_ERRLIST_DEF) -+# if !defined(HAVE_DECL_SYS_ERRLIST) - extern const char *const sys_errlist[]; - # endif --# else --# undef num_errors --# define num_errors (-1) /* always use "errno=%d" */ -+# if defined(HAVE_SYS_NERR) -+# if !defined(HAVE_DECL_SYS_NERR) -+ extern int sys_nerr; -+# endif -+# define num_errors (sys_nerr) -+# endif -+# endif -+# if !defined(num_errors) -+# define num_errors (-1) /* always use "errno=%d" */ - # endif -- - #endif - --static char * plp_Errormsg ( int err ) -+ static char * plp_Errormsg ( int err, char *buffer /* int maxlen = 32 */) - { - char *cp; - -@@ -496,10 +1061,8 @@ static char * plp_Errormsg ( int err ) - } else - # endif - { -- static char msgbuf[32]; /* holds "errno=%d". */ -- /* SAFE use of sprintf */ -- (void) sprintf (msgbuf, "errno=%d", err); -- cp = msgbuf; -+ (void) sprintf (buffer, "errno=%d", err); -+ cp = buffer; - } - #endif - return (cp); -@@ -507,23 +1070,47 @@ static char * plp_Errormsg ( int err ) - - #if defined(TEST) - #include --int main( void ) -+ int main( void ) - { - char buffer[128]; - char *t; - char *test1 = "01234"; -+ int n; - errno = 1; -- plp_snprintf( buffer, sizeof(buffer), (t="errno '%m'")); printf( "%s = '%s'\n", t, buffer ); -- plp_snprintf( buffer, sizeof(buffer), (t = "%s"), test1 ); printf( "%s = '%s'\n", t, buffer ); -- plp_snprintf( buffer, sizeof(buffer), (t = "%12s"), test1 ); printf( "%s = '%s'\n", t, buffer ); -- plp_snprintf( buffer, sizeof(buffer), (t = "%-12s"), test1 ); printf( "%s = '%s'\n", t, buffer ); -- plp_snprintf( buffer, sizeof(buffer), (t = "%12.2s"), test1 ); printf( "%s = '%s'\n", t, buffer ); -- plp_snprintf( buffer, sizeof(buffer), (t = "%-12.2s"), test1 ); printf( "%s = '%s'\n", t, buffer ); -- plp_snprintf( buffer, sizeof(buffer), (t = "%g"), 1.25 ); printf( "%s = '%s'\n", t, buffer ); -- plp_snprintf( buffer, sizeof(buffer), (t = "%g"), 1.2345 ); printf( "%s = '%s'\n", t, buffer ); -- plp_snprintf( buffer, sizeof(buffer), (t = "%12g"), 1.25 ); printf( "%s = '%s'\n", t, buffer ); -- plp_snprintf( buffer, sizeof(buffer), (t = "%12.2g"), 1.25 ); printf( "%s = '%s'\n", t, buffer ); -- plp_snprintf( buffer, sizeof(buffer), (t = "%0*d"), 6, 1 ); printf( "%s = '%s'\n", t, buffer ); -+ buffer[0] = 0; -+ n = snprintf( buffer, 0, (t="test")); printf( "[%d] %s = '%s'\n", n, t, buffer ); -+ n = snprintf( buffer, sizeof(buffer), (t="errno '%m'")); printf( "[%d] %s = '%s'\n", n, t, buffer ); -+ n = snprintf( buffer, sizeof(buffer), (t = "%s"), test1 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); -+ n = snprintf( buffer, sizeof(buffer), (t = "%12s"), test1 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); -+ n = snprintf( buffer, sizeof(buffer), (t = "%-12s"), test1 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); -+ n = snprintf( buffer, sizeof(buffer), (t = "%12.2s"), test1 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); -+ n = snprintf( buffer, sizeof(buffer), (t = "%-12.2s"), test1 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); -+ n = snprintf( buffer, sizeof(buffer), (t = "%g"), 1.25 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); -+ n = snprintf( buffer, sizeof(buffer), (t = "%g"), 1.2345 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); -+ n = snprintf( buffer, sizeof(buffer), (t = "%12g"), 1.25 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); -+ n = snprintf( buffer, sizeof(buffer), (t = "%12.1g"), 1.25 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); -+ n = snprintf( buffer, sizeof(buffer), (t = "%12.2g"), 1.25 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); -+ n = snprintf( buffer, sizeof(buffer), (t = "%12.3g"), 1.25 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); -+ n = snprintf( buffer, sizeof(buffer), (t = "%0*d"), 6, 1 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); -+#if defined(HAVE_LONG_LONG) -+ n = snprintf( buffer, sizeof(buffer), (t = "%llx"), 1, 2, 3, 4 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); -+ n = snprintf( buffer, sizeof(buffer), (t = "%llx"), (long long)1, (long long)2 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); -+ n = snprintf( buffer, sizeof(buffer), (t = "%qx"), 1, 2, 3, 4 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); -+ n = snprintf( buffer, sizeof(buffer), (t = "%qx"), (quad_t)1, (quad_t)2 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); -+#endif -+ n = snprintf( buffer, sizeof(buffer), (t = "0%x, 0%x"), (char *)(0x01234567), (char *)0, 0, 0, 0); printf( "[%d] %s = '%s'\n", n, t, buffer ); -+ n = snprintf( buffer, sizeof(buffer), (t = "0%x, 0%x"), (char *)(0x01234567), (char *)0x89ABCDEF, 0, 0, 0); printf( "[%d] %s = '%s'\n", n, t, buffer ); -+ n = snprintf( buffer, sizeof(buffer), (t = "0%x, 0%x"), t, 0, 0, 0, 0); printf( "[%d] %s = '%s'\n", n, t, buffer ); -+ n = snprintf( buffer, sizeof(buffer), (t = "%f"), 1.25 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); -+ n = snprintf( buffer, sizeof(buffer), (t = "%f"), 1.2345 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); -+ n = snprintf( buffer, sizeof(buffer), (t = "%12f"), 1.25 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); -+ n = snprintf( buffer, sizeof(buffer), (t = "%12.2f"), 1.25 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); -+ n = snprintf( buffer, sizeof(buffer), (t = "%f"), 1.0 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); -+ n = snprintf( buffer, sizeof(buffer), (t = "%.0f"), 1.0 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); -+ n = snprintf( buffer, sizeof(buffer), (t = "%0.0f"), 1.0 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); -+ n = snprintf( buffer, sizeof(buffer), (t = "%1.0f"), 1.0 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); -+ n = snprintf( buffer, sizeof(buffer), (t = "%1.5f"), 1.0 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); -+ n = snprintf( buffer, sizeof(buffer), (t = "%5.5f"), 1.0 ); printf( "[%d] %s = '%s'\n", n, t, buffer ); - return(0); - } - #endif --- -2.4.2 - diff --git a/sane-backends-1.0.24-static-code-check.patch b/sane-backends-1.0.24-static-code-check.patch deleted file mode 100644 index 7b6b4a3..0000000 --- a/sane-backends-1.0.24-static-code-check.patch +++ /dev/null @@ -1,742 +0,0 @@ -From 886208261b5b91b4a64efd8a203873ab85a07a2e Mon Sep 17 00:00:00 2001 -From: Nils Philippsen -Date: Thu, 7 Nov 2013 12:48:23 +0100 -Subject: [PATCH] patch: static-code-check - -Fix problems found during static code check (Coverity). - -Squashed commit of the following: - -commit e24cea3bceb5dad2042dcd95f582d6c8acf4c9ee -Author: Nils Philippsen -Date: Thu Nov 7 14:29:28 2013 +0100 - - epson: don't leak memory if realloc() fails - - (cherry picked from commit d835d9d565118d52c2339c2e79890f57d0616077) - -commit b0c14b86210c7615ea4d90723722a7430b175ae2 -Author: Nils Philippsen -Date: Wed Nov 6 11:05:58 2013 +0100 - - genesys: check return values - - (cherry picked from commit dc76e7cce464f04e46aab2bb0c269b4742161c59) - -commit b6e13be1c187790adfa50e81506533fbe21dca6f -Author: Nils Philippsen -Date: Tue Nov 5 14:48:09 2013 +0100 - - genesys: remove code which is never reached - - The surrounding conditions always evaluate as FALSE because the - variables are set to different values before. - - (cherry picked from commit 5d7f7ffefb22e7e64789e97af0356b7859d61814) - -commit 6d77e6f1ebb9eb0f47117a5790486a3b83c142d2 -Author: Nils Philippsen -Date: Wed Nov 6 11:44:16 2013 +0100 - - rts8891: check return values - - (cherry picked from commit 602d6ecdfe5f3146867799fabf3ac87582c26461) - -commit 0438b3f9aaa4ee8558185ad5e7a9c6a0bf1a3590 -Author: Nils Philippsen -Date: Tue Nov 5 15:42:26 2013 +0100 - - genesys: compute MAX_SCANNERS from array length - - ... of genesys_usb_device_list[] - - (cherry picked from commit a3fe2c1ea5b4f6b1e55435f6abc44f402ff32b4d) - -commit ba746cc2a62cfb32ae6f8e22d6d36206959b7128 -Author: Nils Philippsen -Date: Tue Nov 5 15:31:11 2013 +0100 - - kodakio: don't overrun option name array - - (cherry picked from commit 2d89e37f365cb8e54ee44aa686a62320e2837b50) - -commit 87580bc5d07f983afa1db1e0e7c36287b85b5ecd -Author: Nils Philippsen -Date: Tue Nov 5 15:19:48 2013 +0100 - - pixma: document falling through to next switch case - - (cherry picked from commit 101f76c516cd42cafe9e142aefe751094a125e73) - -commit 15f7322b94a1e895d6ab6e8fb0466ef920a946ad -Author: Nils Philippsen -Date: Tue Nov 5 15:15:17 2013 +0100 - - genesys: avoid infinite loop - - The stray semicolon prevents executing the loop which could reset the - REG41_FEBUSY bit. - - (cherry picked from commit b53a58c4b534b9e6897c1b0a6301d2bf76dc3499) - -commit bde7ee0c9e0bde21fc8b01af11270ca51110a89d -Author: Nils Philippsen -Date: Tue Nov 5 15:12:20 2013 +0100 - - pixma: avoid buffer overflows - - (cherry picked from commit 575f40a0790bb5e20ffd7ccae1c9272e481bbe51) - -commit ee3953fb5b11a26a42bee3d75ee6b93da0bb112f -Author: Nils Philippsen -Date: Tue Nov 5 14:52:22 2013 +0100 - - pixma: u32tohex(): shift first, then cast to uint8_t - - (cherry picked from commit cf9129d62fe7e84479e8daf6018cd2495d53bcc9) - -commit ef85481800383cf082ad6aa4a944765ee84027c0 -Author: Nils Philippsen -Date: Tue Nov 5 14:47:27 2013 +0100 - - remove code which is never reached - - (cherry picked from commit 66cb9b55c2e60503d537d7ed927f5a5aef3658d2) - -commit 0864f4d6203ba8f1306af0d39a09dff2f9d4706a -Author: Nils Philippsen -Date: Tue Nov 5 14:17:12 2013 +0100 - - genesys: fix some memory leaks - - (cherry picked from commit 252ccdd926bb28bd6064da7b652e646664226572) - -commit a4d72c0e2ebb1f6352f21a300bbff67d439cd77f -Author: Nils Philippsen -Date: Tue Nov 5 13:56:28 2013 +0100 - - epson: ensure that command() allocates enough memory - - (cherry picked from commit 8cd2d36f1e9a5b5633d4b8334acf5c8f68381415) - -commit 67af3b80508c0a0adb0fe89ead7c4cb570d7400c -Author: Nils Philippsen -Date: Tue Nov 5 11:39:56 2013 +0100 - - genesys: avoid dereferencing null pointer - - (cherry picked from commit 56104b5329076d45caf2e04a2271f40a2699f71f) ---- - backend/epson.c | 36 +++++++++++++++++++++---------- - backend/genesys.c | 9 +++++--- - backend/genesys_devices.c | 3 +++ - backend/genesys_gl124.c | 21 ++++++++++++++++-- - backend/genesys_gl843.c | 20 +++++++++++++++-- - backend/genesys_gl846.c | 55 ++++++++++++++++++++++++++--------------------- - backend/genesys_gl847.c | 21 ++++++++++++++++-- - backend/genesys_low.h | 1 - - backend/kodakaio.c | 6 +++--- - backend/pixma_bjnp.c | 18 ++++++++++------ - backend/rts8891.c | 16 ++++++-------- - sanei/sanei_usb.c | 2 -- - tools/sane-find-scanner.c | 2 -- - 13 files changed, 141 insertions(+), 69 deletions(-) - -diff --git a/backend/epson.c b/backend/epson.c -index 2cae65a..3b063b9 100644 ---- a/backend/epson.c -+++ b/backend/epson.c -@@ -818,6 +818,12 @@ typedef struct - - } EpsonIdentRec, *EpsonIdent; - -+typedef union -+{ -+ EpsonHdrRec hdr; -+ EpsonIdentRec ident; -+} EpsonHdrUnionRec, *EpsonHdrUnion; -+ - - typedef struct - { -@@ -843,7 +849,7 @@ typedef struct - * - */ - --static EpsonHdr command (Epson_Scanner * s, u_char * cmd, size_t cmd_size, -+static EpsonHdrUnion command (Epson_Scanner * s, u_char * cmd, size_t cmd_size, - SANE_Status * status); - static SANE_Status get_identity_information (SANE_Handle handle); - static SANE_Status get_identity2_information (SANE_Handle handle); -@@ -1844,21 +1850,24 @@ static Epson_Device *first_dev = NULL; /* first EPSON scanner in list */ - static Epson_Scanner *first_handle = NULL; - - --static EpsonHdr -+static EpsonHdrUnion - command (Epson_Scanner * s, u_char * cmd, size_t cmd_size, - SANE_Status * status) - { -+ EpsonHdrUnion hdrunion, hdrunion_bak; - EpsonHdr head; - u_char *buf; - int count; - -- if (NULL == (head = walloc (EpsonHdrRec))) -+ if (NULL == (hdrunion = walloc (EpsonHdrUnionRec))) - { - DBG (1, "out of memory (line %d)\n", __LINE__); - *status = SANE_STATUS_NO_MEM; -- return (EpsonHdr) 0; -+ return (EpsonHdrUnion) 0; - } - -+ head = &(hdrunion->hdr); -+ - send (s, cmd, cmd_size, status); - - if (SANE_STATUS_GOOD != *status) -@@ -1869,7 +1878,7 @@ command (Epson_Scanner * s, u_char * cmd, size_t cmd_size, - *status = SANE_STATUS_GOOD; - send (s, cmd, cmd_size, status); - if (SANE_STATUS_GOOD != *status) -- return (EpsonHdr) 0; -+ return (EpsonHdrUnion) 0; - } - - buf = (u_char *) head; -@@ -1892,7 +1901,7 @@ command (Epson_Scanner * s, u_char * cmd, size_t cmd_size, - } - - if (SANE_STATUS_GOOD != *status) -- return (EpsonHdr) 0; -+ return (EpsonHdrUnion) 0; - - DBG (4, "code %02x\n", (int) head->code); - -@@ -1921,25 +1930,30 @@ command (Epson_Scanner * s, u_char * cmd, size_t cmd_size, - } - - if (SANE_STATUS_GOOD != *status) -- return (EpsonHdr) 0; -+ return (EpsonHdrUnion) 0; - - DBG (4, "status %02x\n", (int) head->status); - - count = head->count2 * 255 + head->count1; - DBG (4, "count %d\n", count); - -- if (NULL == (head = realloc (head, sizeof (EpsonHdrRec) + count))) -+ hdrunion_bak = hdrunion; -+ if (NULL == (hdrunion = realloc (hdrunion, -+ sizeof (EpsonHdrUnionRec) + count))) - { -+ free(hdrunion_bak); - DBG (1, "out of memory (line %d)\n", __LINE__); - *status = SANE_STATUS_NO_MEM; -- return (EpsonHdr) 0; -+ return (EpsonHdrUnion) 0; - } - -+ head = &(hdrunion->hdr); -+ - buf = head->buf; - receive (s, buf, count, status); - - if (SANE_STATUS_GOOD != *status) -- return (EpsonHdr) 0; -+ return (EpsonHdrUnion) 0; - - break; - -@@ -1953,7 +1967,7 @@ command (Epson_Scanner * s, u_char * cmd, size_t cmd_size, - break; - } - -- return head; -+ return hdrunion; - } - - -diff --git a/backend/genesys.c b/backend/genesys.c -index 6e7caad..e2c92e7 100644 ---- a/backend/genesys.c -+++ b/backend/genesys.c -@@ -5977,7 +5977,7 @@ attach (SANE_String_Const devname, Genesys_Device ** devp, SANE_Bool may_wait) - Genesys_Device *dev = 0; - SANE_Int dn, vendor, product; - SANE_Status status; -- int i; -+ unsigned int i; - - - DBG (DBG_proc, "attach: start: devp %s NULL, may_wait = %d\n", -@@ -6061,7 +6061,10 @@ attach (SANE_String_Const devname, Genesys_Device ** devp, SANE_Bool may_wait) - - dev->file_name = strdup (devname); - if (!dev->file_name) -- return SANE_STATUS_NO_MEM; -+ { -+ free(dev); -+ return SANE_STATUS_NO_MEM; -+ } - - dev->model = genesys_usb_device_list[i].model; - dev->vendorId = genesys_usb_device_list[i].vendor; -@@ -6630,7 +6633,7 @@ sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) - first_dev = dev->next; - num_devices--; - free (dev); -- dev = prev->next; -+ dev = first_dev; - } - } - /* case 2 : removed device is not first_dev */ -diff --git a/backend/genesys_devices.c b/backend/genesys_devices.c -index fb3cd43..462c4a9 100644 ---- a/backend/genesys_devices.c -+++ b/backend/genesys_devices.c -@@ -3413,3 +3413,6 @@ static Genesys_USB_Device_Entry genesys_usb_device_list[] = { - {0x04a9, 0x190a, &canon_lide_210_model}, - {0, 0, NULL} - }; -+ -+#define MAX_SCANNERS (sizeof(genesys_usb_device_list) / \ -+ sizeof(genesys_usb_device_list[0])) -diff --git a/backend/genesys_gl124.c b/backend/genesys_gl124.c -index 9e2fb8a..4a4b642 100644 ---- a/backend/genesys_gl124.c -+++ b/backend/genesys_gl124.c -@@ -2246,7 +2246,7 @@ gl124_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) - /* TODO add scan_mode to the API */ - scan_mode= dev->settings.scan_mode; - dev->settings.scan_mode=SCAN_MODE_GRAY; -- gl124_init_scan_regs (dev, -+ status = gl124_init_scan_regs (dev, - local_reg, - resolution, - resolution, -@@ -2260,6 +2260,15 @@ gl124_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) - SCAN_FLAG_DISABLE_SHADING | - SCAN_FLAG_DISABLE_GAMMA | - SCAN_FLAG_IGNORE_LINE_DISTANCE); -+ if (status != SANE_STATUS_GOOD) -+ { -+ DBG (DBG_error, -+ "gl124_slow_back_home: failed to set up registers: %s\n", -+ sane_strstatus (status)); -+ DBGCOMPLETED; -+ return status; -+ } -+ - dev->settings.scan_mode=scan_mode; - - /* clear scan and feed count */ -@@ -2348,7 +2357,7 @@ gl124_feed (Genesys_Device * dev, unsigned int steps) - memcpy (local_reg, dev->reg, GENESYS_GL124_MAX_REGS * sizeof (Genesys_Register_Set)); - - resolution=sanei_genesys_get_lowest_ydpi(dev); -- gl124_init_scan_regs (dev, -+ status = gl124_init_scan_regs (dev, - local_reg, - resolution, - resolution, -@@ -2364,6 +2373,14 @@ gl124_feed (Genesys_Device * dev, unsigned int steps) - SCAN_FLAG_FEEDING | - SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE | - SCAN_FLAG_IGNORE_LINE_DISTANCE); -+ if (status != SANE_STATUS_GOOD) -+ { -+ DBG (DBG_error, -+ "gl124_feed: failed to set up registers: %s\n", -+ sane_strstatus (status)); -+ DBGCOMPLETED; -+ return status; -+ } - - /* set exposure to zero */ - sanei_genesys_set_triple(local_reg,REG_EXPR,0); -diff --git a/backend/genesys_gl843.c b/backend/genesys_gl843.c -index 3648d09..6cddd4f 100644 ---- a/backend/genesys_gl843.c -+++ b/backend/genesys_gl843.c -@@ -2591,7 +2591,7 @@ gl843_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) - memcpy (local_reg, dev->reg, GENESYS_GL843_MAX_REGS * sizeof (Genesys_Register_Set)); - resolution=sanei_genesys_get_lowest_ydpi(dev); - -- gl843_init_scan_regs (dev, -+ status = gl843_init_scan_regs (dev, - local_reg, - resolution, - resolution, -@@ -2607,6 +2607,14 @@ gl843_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) - SCAN_FLAG_DISABLE_GAMMA | - SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE | - SCAN_FLAG_IGNORE_LINE_DISTANCE); -+ if (status != SANE_STATUS_GOOD) -+ { -+ DBG (DBG_error, -+ "gl843_slow_back_home: failed to set up registers: %s\n", -+ sane_strstatus (status)); -+ DBGCOMPLETED; -+ return status; -+ } - - /* clear scan and feed count */ - RIE (sanei_genesys_write_register (dev, REG0D, REG0D_CLRLNCNT | REG0D_CLRMCNT)); -@@ -2879,7 +2887,7 @@ gl843_feed (Genesys_Device * dev, unsigned int steps) - memcpy (local_reg, dev->reg, GENESYS_GL843_MAX_REGS * sizeof (Genesys_Register_Set)); - - resolution=sanei_genesys_get_lowest_ydpi(dev); -- gl843_init_scan_regs (dev, -+ status = gl843_init_scan_regs (dev, - local_reg, - resolution, - resolution, -@@ -2895,6 +2903,14 @@ gl843_feed (Genesys_Device * dev, unsigned int steps) - SCAN_FLAG_DISABLE_GAMMA | - SCAN_FLAG_FEEDING | - SCAN_FLAG_IGNORE_LINE_DISTANCE); -+ if (status != SANE_STATUS_GOOD) -+ { -+ DBG (DBG_error, -+ "gl843_feed: failed to set up registers: %s\n", -+ sane_strstatus (status)); -+ DBGCOMPLETED; -+ return status; -+ } - - /* clear scan and feed count */ - RIE (sanei_genesys_write_register (dev, REG0D, REG0D_CLRLNCNT)); -diff --git a/backend/genesys_gl846.c b/backend/genesys_gl846.c -index 5e1f0f4..c810604 100644 ---- a/backend/genesys_gl846.c -+++ b/backend/genesys_gl846.c -@@ -633,7 +633,7 @@ gl846_set_adi_fe (Genesys_Device * dev, uint8_t set) - - /* wait for FE to be ready */ - status = sanei_genesys_get_status (dev, &val8); -- while (val8 & REG41_FEBUSY); -+ while (val8 & REG41_FEBUSY) - { - usleep (10000); - status = sanei_genesys_get_status (dev, &val8); -@@ -1975,7 +1975,7 @@ gl846_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) - /* TODO add scan_mode to the API */ - scan_mode= dev->settings.scan_mode; - dev->settings.scan_mode=SCAN_MODE_LINEART; -- gl846_init_scan_regs (dev, -+ status = gl846_init_scan_regs (dev, - local_reg, - resolution, - resolution, -@@ -1989,6 +1989,14 @@ gl846_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) - SCAN_FLAG_DISABLE_SHADING | - SCAN_FLAG_DISABLE_GAMMA | - SCAN_FLAG_IGNORE_LINE_DISTANCE); -+ if (status != SANE_STATUS_GOOD) -+ { -+ DBG (DBG_error, -+ "gl846_slow_back_home: failed to set up registers: %s\n", -+ sane_strstatus (status)); -+ DBGCOMPLETED; -+ return status; -+ } - dev->settings.scan_mode=scan_mode; - - /* clear scan and feed count */ -@@ -2255,7 +2263,7 @@ gl846_feed (Genesys_Device * dev, unsigned int steps) - memcpy (local_reg, dev->reg, GENESYS_GL846_MAX_REGS * sizeof (Genesys_Register_Set)); - - resolution=sanei_genesys_get_lowest_ydpi(dev); -- gl846_init_scan_regs (dev, -+ status = gl846_init_scan_regs (dev, - local_reg, - resolution, - resolution, -@@ -2270,6 +2278,14 @@ gl846_feed (Genesys_Device * dev, unsigned int steps) - SCAN_FLAG_DISABLE_GAMMA | - SCAN_FLAG_FEEDING | - SCAN_FLAG_IGNORE_LINE_DISTANCE); -+ if (status != SANE_STATUS_GOOD) -+ { -+ DBG (DBG_error, -+ "gl846_feed: failed to set up registers: %s\n", -+ sane_strstatus (status)); -+ DBGCOMPLETED; -+ return status; -+ } - - /* set exposure to zero */ - sanei_genesys_set_triple(local_reg,REG_EXPR,0); -@@ -2583,13 +2599,14 @@ gl846_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) - ptr+=4; - } - -- RIE (sanei_genesys_read_register (dev, 0xd0+i, &val)); -+ RIEF (sanei_genesys_read_register (dev, 0xd0+i, &val), buffer); - addr = val * 8192 + 0x10000000; - status = sanei_genesys_write_ahb (dev->dn, dev->usb_mode, addr, pixels, buffer); - if (status != SANE_STATUS_GOOD) - { - DBG (DBG_error, "gl846_send_shading_data; write to AHB failed (%s)\n", - sane_strstatus (status)); -+ free(buffer); - return status; - } - } -@@ -3013,7 +3030,15 @@ gl846_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) - DBG (DBG_proc, "gl846_search_strip %s %s\n", black ? "black" : "white", - forward ? "forward" : "reverse"); - -- gl846_set_fe (dev, AFE_SET); -+ status = gl846_set_fe (dev, AFE_SET); -+ if (status != SANE_STATUS_GOOD) -+ { -+ DBG (DBG_error, -+ "gl846_search_strip: gl846_set_fe() failed: %s\n", -+ sane_strstatus(status)); -+ return status; -+ } -+ - status = gl846_stop_action (dev); - if (status != SANE_STATUS_GOOD) - { -@@ -3572,24 +3597,10 @@ gl846_coarse_gain_calibration (Genesys_Device * dev, int dpi) - max[j] = 0; - for (i = pixels/4; i < (pixels*3/4); i++) - { -- if(bpp==16) -- { -- if (dev->model->is_cis) -- val = -- line[i * 2 + j * 2 * pixels + 1] * 256 + -- line[i * 2 + j * 2 * pixels]; -- else -- val = -- line[i * 2 * channels + 2 * j + 1] * 256 + -- line[i * 2 * channels + 2 * j]; -- } -- else -- { - if (dev->model->is_cis) - val = line[i + j * pixels]; - else - val = line[i * channels + j]; -- } - - max[j] += val; - } -@@ -3619,12 +3630,6 @@ gl846_coarse_gain_calibration (Genesys_Device * dev, int dpi) - dev->frontend.gain[2] = dev->frontend.gain[1] = dev->frontend.gain[0]; - } - -- if (channels == 1) -- { -- dev->frontend.gain[0] = dev->frontend.gain[1]; -- dev->frontend.gain[2] = dev->frontend.gain[1]; -- } -- - free (line); - - RIE (gl846_stop_action (dev)); -diff --git a/backend/genesys_gl847.c b/backend/genesys_gl847.c -index 7c6a3c3..47171b9 100644 ---- a/backend/genesys_gl847.c -+++ b/backend/genesys_gl847.c -@@ -1995,7 +1995,7 @@ gl847_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) - /* TODO add scan_mode to the API */ - scan_mode= dev->settings.scan_mode; - dev->settings.scan_mode=SCAN_MODE_LINEART; -- gl847_init_scan_regs (dev, -+ status = gl847_init_scan_regs (dev, - local_reg, - resolution, - resolution, -@@ -2009,6 +2009,15 @@ gl847_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) - SCAN_FLAG_DISABLE_SHADING | - SCAN_FLAG_DISABLE_GAMMA | - SCAN_FLAG_IGNORE_LINE_DISTANCE); -+ if (status != SANE_STATUS_GOOD) -+ { -+ DBG (DBG_error, -+ "gl847_slow_back_home: failed to set up registers: %s\n", -+ sane_strstatus (status)); -+ DBGCOMPLETED; -+ return status; -+ } -+ - dev->settings.scan_mode=scan_mode; - - /* clear scan and feed count */ -@@ -2276,7 +2285,7 @@ gl847_feed (Genesys_Device * dev, unsigned int steps) - memcpy (local_reg, dev->reg, GENESYS_GL847_MAX_REGS * sizeof (Genesys_Register_Set)); - - resolution=sanei_genesys_get_lowest_ydpi(dev); -- gl847_init_scan_regs (dev, -+ status = gl847_init_scan_regs (dev, - local_reg, - resolution, - resolution, -@@ -2291,6 +2300,14 @@ gl847_feed (Genesys_Device * dev, unsigned int steps) - SCAN_FLAG_DISABLE_GAMMA | - SCAN_FLAG_FEEDING | - SCAN_FLAG_IGNORE_LINE_DISTANCE); -+ if (status != SANE_STATUS_GOOD) -+ { -+ DBG (DBG_error, -+ "gl847_feed: failed to set up registers: %s\n", -+ sane_strstatus (status)); -+ DBGCOMPLETED; -+ return status; -+ } - - /* set exposure to zero */ - sanei_genesys_set_triple(local_reg,REG_EXPR,0); -diff --git a/backend/genesys_low.h b/backend/genesys_low.h -index 1d5ef22..31e0541 100644 ---- a/backend/genesys_low.h -+++ b/backend/genesys_low.h -@@ -310,7 +310,6 @@ typedef enum Genesys_Color_Order - Genesys_Color_Order; - - --#define MAX_SCANNERS 50 - #define MAX_RESOLUTIONS 13 - #define MAX_DPI 4 - -diff --git a/backend/kodakaio.c b/backend/kodakaio.c -index 8c4583a..901f7a8 100644 ---- a/backend/kodakaio.c -+++ b/backend/kodakaio.c -@@ -3131,14 +3131,14 @@ sane_control_option(SANE_Handle handle, SANE_Int option, SANE_Action action, - void *value, SANE_Int *info) - { - KodakAio_Scanner *s = (KodakAio_Scanner *) handle; -- DBG(2, "%s: action = %x, option = %d %s\n", __func__, action, option, s->opt[option].name); -- - if (option < 0 || option >= NUM_OPTIONS) - { -- DBG(1, "%s: option num = %d (%s) out of range\n", __func__, option, s->opt[option].name); -+ DBG(1, "%s: option num = %d out of range (0..%d)\n", __func__, option, NUM_OPTIONS - 1); - return SANE_STATUS_INVAL; - } - -+ DBG(2, "%s: action = %x, option = %d %s\n", __func__, action, option, s->opt[option].name); -+ - if (info != NULL) - *info = 0; - -diff --git a/backend/pixma_bjnp.c b/backend/pixma_bjnp.c -index a1730ad..1020b8d 100644 ---- a/backend/pixma_bjnp.c -+++ b/backend/pixma_bjnp.c -@@ -130,11 +130,11 @@ static void - u32tohex (uint32_t x, char *str) - { - uint8_t uint8[4]; -- uint8[0]= (uint8_t) x >> 24; -- uint8[1] = (uint8_t)x >> 16; -- uint8[2] = (uint8_t)x >> 8; -- uint8[3] = (uint8_t)x ; -- u8tohex(str, uint8, 4); -+ uint8[0] = (uint8_t)(x >> 24); -+ uint8[1] = (uint8_t)(x >> 16); -+ uint8[2] = (uint8_t)(x >> 8); -+ uint8[3] = (uint8_t)x ; -+ u8tohex(str, uint8, 4); - } - - static void -@@ -284,7 +284,8 @@ parse_IEEE1284_to_model (char *scanner_id, char *model) - char s[BJNP_IEEE1284_MAX]; - char *tok; - -- strcpy (s, scanner_id); -+ strncpy (s, scanner_id, BJNP_IEEE1284_MAX); -+ s[BJNP_IEEE1284_MAX - 1] = '\0'; - model[0] = '\0'; - - tok = strtok (s, ";"); -@@ -441,7 +442,8 @@ split_uri (const char *devname, char *method, char *host, char *port, - char next; - int i; - -- strcpy (copy, devname); -+ strncpy (copy, devname, 1024); -+ copy[1023] = '\0'; - start = copy; - - /* -@@ -2313,6 +2315,8 @@ sanei_bjnp_read_int (SANE_Int dn, SANE_Byte * buffer, size_t * size) - } - device[dn].polling_status = BJNP_POLL_STARTED; - -+ /* fall through to BJNP_POLL_STARTED */ -+ - case BJNP_POLL_STARTED: - /* we use only seonds accuracy between poll attempts */ - timeout = device[dn].bjnp_timeout /1000; -diff --git a/backend/rts8891.c b/backend/rts8891.c -index d86347b..bdb4011 100644 ---- a/backend/rts8891.c -+++ b/backend/rts8891.c -@@ -2212,7 +2212,13 @@ sane_close (SANE_Handle handle) - /* switch off lamp and close usb */ - if (dev->conf.allowsharing == SANE_TRUE) - { -- sanei_usb_claim_interface (dev->devnum, 0); -+ SANE_Status status = sanei_usb_claim_interface (dev->devnum, 0); -+ if (status != SANE_STATUS_GOOD) -+ { -+ DBG (DBG_warn, "sane_close: cannot claim usb interface: %s\n", -+ sane_strstatus(status)); -+ DBG (DBG_warn, "sane_close: continuing anyway\n"); -+ } - } - set_lamp_state (session, 0); - sanei_usb_close (dev->devnum); -@@ -3197,14 +3203,6 @@ find_origin (struct Rts8891_Device *dev, SANE_Bool * changed) - return status; - } - -- if (status != SANE_STATUS_GOOD) -- { -- free(image); -- free(data); -- DBG (DBG_error, "find_origin: failed to wait for data\n"); -- return status; -- } -- - if (DBG_LEVEL > DBG_io2) - { - write_gray_data (data, "find_origin.pnm", width, height); -diff --git a/sanei/sanei_usb.c b/sanei/sanei_usb.c -index 7401658..491ceeb 100644 ---- a/sanei/sanei_usb.c -+++ b/sanei/sanei_usb.c -@@ -460,8 +460,6 @@ sanei_libusb_strerror (int errcode) - default: - return "Unknown libusb-1.0 error code"; - } -- -- return "Unknown libusb-1.0 error code"; - } - #endif /* HAVE_LIBUSB_1_0 */ - -diff --git a/tools/sane-find-scanner.c b/tools/sane-find-scanner.c -index dbfd0da..ae0e116 100644 ---- a/tools/sane-find-scanner.c -+++ b/tools/sane-find-scanner.c -@@ -757,8 +757,6 @@ sfs_libusb_strerror (int errcode) - default: - return "Unknown libusb-1.0 error code"; - } -- -- return "Unknown libusb-1.0 error code"; - } - - static char * --- -1.8.4.2 - diff --git a/sane-backends-1.0.24-udev.patch b/sane-backends-1.0.24-udev.patch deleted file mode 100644 index 7d6f03c..0000000 --- a/sane-backends-1.0.24-udev.patch +++ /dev/null @@ -1,72 +0,0 @@ -From f757d61aff2aa7a331f406c59c0a31f2d5e25553 Mon Sep 17 00:00:00 2001 -From: Nils Philippsen -Date: Tue, 8 Oct 2013 16:29:13 +0200 -Subject: [PATCH] patch: udev - -Squashed commit of the following: - -commit fb6d1f4c0d17f1df33429bf03a64cd4fbb819ea5 -Author: Nils Philippsen -Date: Tue Oct 8 16:24:49 2013 +0200 - - adapt generated udev rules for Fedora - -commit 8bffaccc1eeb19ecbaddb4ac9da73954af4c5d4f -Author: Nils Philippsen -Date: Mon Sep 10 12:20:43 2012 +0200 - - use group and mode macros consistently ---- - tools/sane-desc.c | 14 +++++++------- - 1 file changed, 7 insertions(+), 7 deletions(-) - -diff --git a/tools/sane-desc.c b/tools/sane-desc.c -index 3cc4407..df6d348 100644 ---- a/tools/sane-desc.c -+++ b/tools/sane-desc.c -@@ -57,9 +57,9 @@ - #define COLOR_NEW "\"#F00000\"" - #define COLOR_UNKNOWN "\"#000000\"" - --#define DEVMODE "0664" -+#define DEVMODE "0644" - #define DEVOWNER "root" --#define DEVGROUP "scanner" -+#define DEVGROUP "root" - - #ifndef PATH_MAX - # define PATH_MAX 1024 -@@ -3564,7 +3564,8 @@ print_udev (void) - } - - printf("\n# The following rule will disable USB autosuspend for the device\n"); -- printf("ENV{libsane_matched}==\"yes\", RUN+=\"/bin/sh -c 'if test -e /sys/$env{DEVPATH}/power/control; then echo on > /sys/$env{DEVPATH}/power/control; elif test -e /sys/$env{DEVPATH}/power/level; then echo on > /sys/$env{DEVPATH}/power/level; fi'\"\n"); -+ printf("ENV{libsane_matched}==\"yes\", TEST==\"power/control\", ATTR{power/control}=\"on\"\n"); -+ printf("ENV{libsane_matched}==\"yes\", TEST!=\"power/control\", TEST==\"power/level\", ATTR{power/level}=\"on\"\n"); - - printf ("\nLABEL=\"libsane_usb_rules_end\"\n\n"); - -@@ -3640,10 +3641,8 @@ print_udev (void) - } - printf ("LABEL=\"libsane_scsi_rules_end\"\n"); - -- if (mode == output_mode_udevacl) -- printf("\nENV{libsane_matched}==\"yes\", RUN+=\"/bin/setfacl -m g:%s:rw $env{DEVNAME}\"\n", DEVGROUP); -- else -- printf ("\nENV{libsane_matched}==\"yes\", MODE=\"664\", GROUP=\"scanner\"\n"); -+ if (mode != output_mode_udevacl) -+ printf ("\nENV{libsane_matched}==\"yes\", MODE=\"%s\", GROUP=\"%s\"\n", DEVMODE, DEVGROUP); - - printf ("\nLABEL=\"libsane_rules_end\"\n"); - } -@@ -3694,6 +3693,7 @@ print_udevhwdb (void) - - printf("# The following rule will disable USB autosuspend for the device\n"); - printf("ENV{DEVTYPE}==\"usb_device\", ENV{libsane_matched}==\"yes\", TEST==\"power/control\", ATTR{power/control}=\"on\"\n\n"); -+ printf("ENV{DEVTYPE}==\"usb_device\", ENV{libsane_matched}==\"yes\", TEST!=\"power/control\", TEST==\"power/level\", ATTR{power/level}=\"on\"\n"); - - printf ("SUBSYSTEMS!=\"scsi\", GOTO=\"libsane_rules_end\"\n"); - printf ("KERNEL!=\"sg[0-9]*\", GOTO=\"libsane_rules_end\"\n\n"); --- -1.8.3.1 - diff --git a/sane-backends-1.0.24-usb3-xhci.patch b/sane-backends-1.0.24-usb3-xhci.patch deleted file mode 100644 index c06d676..0000000 --- a/sane-backends-1.0.24-usb3-xhci.patch +++ /dev/null @@ -1,170 +0,0 @@ -From ccba990b2c2a39b35290370adad2acf8a4d8dc7e Mon Sep 17 00:00:00 2001 -From: Nils Philippsen -Date: Mon, 8 Jun 2015 17:51:25 +0200 -Subject: [PATCH] patch: usb3-xhci - -Squashed commit of the following: - -commit 73cb422f860a84aca7a19114936ead1794d77890 -Author: m. allan noah -Date: Tue Dec 16 10:23:55 2014 -0500 - - sanei_usb: Linux USB3/xhci workarounds - - add calls to sanei_usb_set_altinterface in sanei_usb_close and - sanei_usb_clear_halt- hopefully work around USB3/xhci problems - in Linux. Also, remove some unused code, and fix debug messages. - - (cherry picked from commit 014b45d920f1fb630e1a31bb01f1da02ea2a6a87) ---- - sanei/sanei_usb.c | 56 ++++++++++++++++++++++++++++++++----------------------- - 1 file changed, 33 insertions(+), 23 deletions(-) - -diff --git a/sanei/sanei_usb.c b/sanei/sanei_usb.c -index 491ceeb..3777ae8 100644 ---- a/sanei/sanei_usb.c -+++ b/sanei/sanei_usb.c -@@ -154,6 +154,7 @@ typedef struct - SANE_Int control_in_ep; - SANE_Int control_out_ep; - SANE_Int interface_nr; -+ SANE_Int alt_setting; - SANE_Int missing; - #ifdef HAVE_LIBUSB - usb_dev_handle *libusb_handle; -@@ -633,6 +634,7 @@ static void usbcall_scan_devices(void) - device.product = pDevDesc->idProduct; - device.method = sanei_usb_method_usbcalls; - device.interface_nr = interface; -+ device.alt_setting = 0; - DBG (4, "%s: found usbcalls device (0x%04x/0x%04x) as device number %s\n", __func__, - pDevDesc->idVendor, pDevDesc->idProduct,device.devname); - store_device(device); -@@ -819,7 +821,7 @@ static void libusb_scan_devices(void) - "scanner (%d/%d)\n", __func__, dev->descriptor.idVendor, - dev->descriptor.idProduct, interface, - dev->descriptor.bDeviceClass, -- dev->config[0].interface[interface].altsetting != 0 -+ dev->config[0].interface[interface].num_altsetting != 0 - ? dev->config[0].interface[interface].altsetting[0]. - bInterfaceClass : -1); - } -@@ -843,6 +845,7 @@ static void libusb_scan_devices(void) - device.product = dev->descriptor.idProduct; - device.method = sanei_usb_method_libusb; - device.interface_nr = interface; -+ device.alt_setting = 0; - DBG (4, - "%s: found libusb device (0x%04x/0x%04x) interface " - "%d at %s\n", __func__, -@@ -989,7 +992,7 @@ static void libusb_scan_devices(void) - "%s: device 0x%04x/0x%04x, interface %d " - "doesn't look like a scanner (%d/%d)\n", __func__, - vid, pid, interface, desc.bDeviceClass, -- (config0->interface[interface].altsetting != 0) -+ (config0->interface[interface].num_altsetting != 0) - ? config0->interface[interface].altsetting[0].bInterfaceClass : -1); - } - -@@ -1016,6 +1019,7 @@ static void libusb_scan_devices(void) - device.product = pid; - device.method = sanei_usb_method_libusb; - device.interface_nr = interface; -+ device.alt_setting = 0; - DBG (4, - "%s: found libusb-1.0 device (0x%04x/0x%04x) interface " - "%d at %s\n", __func__, -@@ -2126,22 +2130,24 @@ sanei_usb_close (SANE_Int dn) - else - #ifdef HAVE_LIBUSB - { --#if 0 -- /* Should only be done in case of a stall */ -- usb_clear_halt (devices[dn].libusb_handle, devices[dn].bulk_in_ep); -- usb_clear_halt (devices[dn].libusb_handle, devices[dn].bulk_out_ep); -- usb_clear_halt (devices[dn].libusb_handle, devices[dn].iso_in_ep); -- /* be careful, we don't know if we are in DATA0 stage now */ -- usb_resetep (devices[dn].libusb_handle, devices[dn].bulk_in_ep); -- usb_resetep (devices[dn].libusb_handle, devices[dn].bulk_out_ep); -- usb_resetep (devices[dn].libusb_handle, devices[dn].iso_in_ep); --#endif /* 0 */ -+ /* This call seems to be required by Linux xhci driver -+ * even though it should be a no-op. Without it, the -+ * host or driver does not reset it's data toggle bit. -+ * We intentionally ignore the return val */ -+ sanei_usb_set_altinterface (dn, devices[dn].alt_setting); -+ - usb_release_interface (devices[dn].libusb_handle, - devices[dn].interface_nr); - usb_close (devices[dn].libusb_handle); - } - #elif defined(HAVE_LIBUSB_1_0) - { -+ /* This call seems to be required by Linux xhci driver -+ * even though it should be a no-op. Without it, the -+ * host or driver does not reset it's data toggle bit. -+ * We intentionally ignore the return val */ -+ sanei_usb_set_altinterface (dn, devices[dn].alt_setting); -+ - libusb_release_interface (devices[dn].lu_handle, - devices[dn].interface_nr); - libusb_close (devices[dn].lu_handle); -@@ -2166,7 +2172,6 @@ sanei_usb_set_timeout (SANE_Int timeout) - SANE_Status - sanei_usb_clear_halt (SANE_Int dn) - { --#ifdef HAVE_LIBUSB - int ret; - - if (dn >= device_number || dn < 0) -@@ -2175,6 +2180,14 @@ sanei_usb_clear_halt (SANE_Int dn) - return SANE_STATUS_INVAL; - } - -+#ifdef HAVE_LIBUSB -+ -+ /* This call seems to be required by Linux xhci driver -+ * even though it should be a no-op. Without it, the -+ * host or driver does not send the clear to the device. -+ * We intentionally ignore the return val */ -+ sanei_usb_set_altinterface (dn, devices[dn].alt_setting); -+ - ret = usb_clear_halt (devices[dn].libusb_handle, devices[dn].bulk_in_ep); - if (ret){ - DBG (1, "sanei_usb_clear_halt: BULK_IN ret=%d\n", ret); -@@ -2187,18 +2200,13 @@ sanei_usb_clear_halt (SANE_Int dn) - return SANE_STATUS_INVAL; - } - -- /* be careful, we don't know if we are in DATA0 stage now -- ret = usb_resetep (devices[dn].libusb_handle, devices[dn].bulk_in_ep); -- ret = usb_resetep (devices[dn].libusb_handle, devices[dn].bulk_out_ep); -- */ - #elif defined(HAVE_LIBUSB_1_0) -- int ret; - -- if (dn >= device_number || dn < 0) -- { -- DBG (1, "sanei_usb_clear_halt: dn >= device number || dn < 0\n"); -- return SANE_STATUS_INVAL; -- } -+ /* This call seems to be required by Linux xhci driver -+ * even though it should be a no-op. Without it, the -+ * host or driver does not send the clear to the device. -+ * We intentionally ignore the return val */ -+ sanei_usb_set_altinterface (dn, devices[dn].alt_setting); - - ret = libusb_clear_halt (devices[dn].lu_handle, devices[dn].bulk_in_ep); - if (ret){ -@@ -3036,6 +3044,8 @@ sanei_usb_set_altinterface (SANE_Int dn, SANE_Int alternate) - - DBG (5, "sanei_usb_set_altinterface: alternate = %d\n", alternate); - -+ devices[dn].alt_setting = alternate; -+ - if (devices[dn].method == sanei_usb_method_scanner_driver) - { - #if defined(__linux__) --- -2.4.2 - diff --git a/sane-backends-1.0.25-udev.patch b/sane-backends-1.0.25-udev.patch new file mode 100644 index 0000000..6a64812 --- /dev/null +++ b/sane-backends-1.0.25-udev.patch @@ -0,0 +1,72 @@ +From 252f347d59fff3ab1877f77a36613b318651725e Mon Sep 17 00:00:00 2001 +From: Nils Philippsen +Date: Tue, 8 Oct 2013 16:29:13 +0200 +Subject: [PATCH] patch: udev + +Squashed commit of the following: + +commit fb6d1f4c0d17f1df33429bf03a64cd4fbb819ea5 +Author: Nils Philippsen +Date: Tue Oct 8 16:24:49 2013 +0200 + + adapt generated udev rules for Fedora + +commit 8bffaccc1eeb19ecbaddb4ac9da73954af4c5d4f +Author: Nils Philippsen +Date: Mon Sep 10 12:20:43 2012 +0200 + + use group and mode macros consistently +--- + tools/sane-desc.c | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +diff --git a/tools/sane-desc.c b/tools/sane-desc.c +index badc8ce..f992bf5 100644 +--- a/tools/sane-desc.c ++++ b/tools/sane-desc.c +@@ -57,9 +57,9 @@ + #define COLOR_NEW "\"#F00000\"" + #define COLOR_UNKNOWN "\"#000000\"" + +-#define DEVMODE "0664" ++#define DEVMODE "0644" + #define DEVOWNER "root" +-#define DEVGROUP "scanner" ++#define DEVGROUP "root" + + #ifndef PATH_MAX + # define PATH_MAX 1024 +@@ -3564,7 +3564,8 @@ print_udev (void) + } + + printf("\n# The following rule will disable USB autosuspend for the device\n"); +- printf("ENV{libsane_matched}==\"yes\", RUN+=\"/bin/sh -c 'if test -e /sys/$env{DEVPATH}/power/control; then echo on > /sys/$env{DEVPATH}/power/control; elif test -e /sys/$env{DEVPATH}/power/level; then echo on > /sys/$env{DEVPATH}/power/level; fi'\"\n"); ++ printf("ENV{libsane_matched}==\"yes\", TEST==\"power/control\", ATTR{power/control}=\"on\"\n"); ++ printf("ENV{libsane_matched}==\"yes\", TEST!=\"power/control\", TEST==\"power/level\", ATTR{power/level}=\"on\"\n"); + + printf ("\nLABEL=\"libsane_usb_rules_end\"\n\n"); + +@@ -3641,10 +3642,8 @@ print_udev (void) + } + printf ("LABEL=\"libsane_scsi_rules_end\"\n"); + +- if (mode == output_mode_udevacl) +- printf("\nENV{libsane_matched}==\"yes\", RUN+=\"/bin/setfacl -m g:%s:rw $env{DEVNAME}\"\n", DEVGROUP); +- else +- printf ("\nENV{libsane_matched}==\"yes\", MODE=\"664\", GROUP=\"scanner\"\n"); ++ if (mode != output_mode_udevacl) ++ printf ("\nENV{libsane_matched}==\"yes\", MODE=\"%s\", GROUP=\"%s\"\n", DEVMODE, DEVGROUP); + + printf ("\nLABEL=\"libsane_rules_end\"\n"); + } +@@ -3695,6 +3694,7 @@ print_udevhwdb (void) + + printf("# The following rule will disable USB autosuspend for the device\n"); + printf("ENV{DEVTYPE}==\"usb_device\", ENV{libsane_matched}==\"yes\", TEST==\"power/control\", ATTR{power/control}=\"on\"\n\n"); ++ printf("ENV{DEVTYPE}==\"usb_device\", ENV{libsane_matched}==\"yes\", TEST!=\"power/control\", TEST==\"power/level\", ATTR{power/level}=\"on\"\n"); + + printf ("SUBSYSTEMS==\"scsi\", GOTO=\"libsane_scsi_rules_begin\"\n"); + printf ("GOTO=\"libsane_rules_end\"\n\n"); +-- +2.5.0 + diff --git a/sane-backends.spec b/sane-backends.spec index de3fc21..e3a0eae 100644 --- a/sane-backends.spec +++ b/sane-backends.spec @@ -36,8 +36,8 @@ Summary: Scanner access software Name: sane-backends -Version: 1.0.24 -Release: 15%{?dist} +Version: 1.0.25 +Release: 1%{?dist} # lib/ is LGPLv2+, backends are GPLv2+ with exceptions # Tools are GPLv2+, docs are public domain # see LICENSE for details @@ -47,41 +47,13 @@ Group: System Environment/Libraries Source0: https://alioth.debian.org/frs/download.php/latestfile/176/sane-backends-%{version}.tar.gz Source1: sane.png -# Fedora-specific, not generally applicable: -Patch0: sane-backends-1.0.24-udev.patch -# Upstream commit b491261f0c0f6df47d1e4859cde88448f98718dd -Patch1: sane-backends-1.0.21-epson-expression800.patch +# Fedora-specific, probably not generally applicable: +Patch0: sane-backends-1.0.25-udev.patch # Fedora-specific (for now): don't use the same SONAME for backend libs and # main lib -Patch2: sane-backends-1.0.23-soname.patch +Patch1: sane-backends-1.0.23-soname.patch # Fedora-specific (for now): make installed sane-config multi-lib aware again -Patch3: sane-backends-1.0.23-sane-config-multilib.patch -# Upstream commit 3b96baef65ea6c315937f5cd2253c6b6c62636d8 -Patch4: sane-backends-1.0.24-hwdb.patch -# Upstream commit d35d6326cb00fcbb19b41599bdff7faf5d79225e -Patch5: sane-backends-1.0.24-pixma_bjnp-crash.patch -# Upstream commit 252ccdd926bb28bd6064da7b652e646664226572 -# Upstream commit 66cb9b55c2e60503d537d7ed927f5a5aef3658d2 -# Upstream commit cf9129d62fe7e84479e8daf6018cd2495d53bcc9 -# Upstream commit 575f40a0790bb5e20ffd7ccae1c9272e481bbe51 -# Upstream commit b53a58c4b534b9e6897c1b0a6301d2bf76dc3499 -# Upstream commit 101f76c516cd42cafe9e142aefe751094a125e73 -# Upstream commit 2d89e37f365cb8e54ee44aa686a62320e2837b50 -# Upstream commit a3fe2c1ea5b4f6b1e55435f6abc44f402ff32b4d -# Upstream commit 602d6ecdfe5f3146867799fabf3ac87582c26461 -# Upstream commit 5d7f7ffefb22e7e64789e97af0356b7859d61814 -# Upstream commit dc76e7cce464f04e46aab2bb0c269b4742161c59 -# Upstream commit d835d9d565118d52c2339c2e79890f57d0616077 -Patch6: sane-backends-1.0.24-static-code-check.patch -# Upstream commit 758731489d0d58bab6e4b70db9556038c9f4bb67 -Patch7: sane-backends-1.0.24-scsi-permissions.patch -# Upstream commit 8082a42ec4f3b3cf2cffc30a45dda5fc41d55576 -Patch8: sane-backends-1.0.24-format-security.patch -# Update lib/snprintf.c to latest from LPRng to resolve -# license issue (#1102520) -Patch9: sane-backends-1.0.24-snprintf-cleanroom.patch -# Upstream commit 73cb422f860a84aca7a19114936ead1794d77890 -Patch10: sane-backends-1.0.24-usb3-xhci.patch +Patch2: sane-backends-1.0.23-sane-config-multilib.patch URL: http://www.sane-project.org @@ -191,16 +163,8 @@ This package contains backend drivers to access digital cameras through SANE. %setup -q %patch0 -p1 -b .udev -%patch1 -p1 -b .epson-expression800 -%patch2 -p1 -b .soname -%patch3 -p1 -b .sane-config-multilib -%patch4 -p1 -b .hwdb -%patch5 -p1 -b .pixma_bjnp-crash -%patch6 -p1 -b .static-code-check -%patch7 -p1 -b .scsi-permissions -%patch8 -p1 -b .format-security -%patch9 -p1 -b .snprintf-cleanroom -%patch10 -p1 -b .usb3-xhci +%patch1 -p1 -b .soname +%patch2 -p1 -b .sane-config-multilib %build CFLAGS="%optflags -fno-strict-aliasing" @@ -289,6 +253,7 @@ udevadm hwdb --update >/dev/null 2>&1 || : %{_bindir}/sane-find-scanner %{_bindir}/scanimage +%{_bindir}/umax_pp %{_sbindir}/* %exclude %{_mandir}/man1/sane-config.1* @@ -322,6 +287,14 @@ udevadm hwdb --update >/dev/null 2>&1 || : %{_libdir}/sane/*gphoto2.so* %changelog +* Thu Oct 08 2015 Nils Philippsen - 1.0.25-1 +- version 1.0.25 +- remove obsolete patches: epson-expression800, hwdb, pixma_bjnp-crash, + static-code-check, scsi-permissions, format-security, snprintf-license, + usb3-xhci +- update udev patch +- ship umax_pp tool + * Fri Jun 19 2015 Fedora Release Engineering - 1.0.24-15 - Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild diff --git a/sources b/sources index 8a51e75..e10c087 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -1ca68e536cd7c1852322822f5f6ac3a4 sane-backends-1.0.24.tar.gz +f9ed5405b3c12f07c6ca51ee60225fe7 sane-backends-1.0.25.tar.gz