From 569d49e7693797c6a796144ff7afee5851662c54 Mon Sep 17 00:00:00 2001 From: Nils Philippsen Date: Tue, 9 Jun 2015 03:13:01 +0200 Subject: [PATCH] reformat and rename snprintf-cleanroom patch --- ...e-backends-1.0.24-snprintf-cleanroom.patch | 423 +++++++++--------- sane-backends.spec | 7 +- 2 files changed, 221 insertions(+), 209 deletions(-) rename sane-backends-1.0.24-update-to-current-lprng-plp_snprintf.patch => sane-backends-1.0.24-snprintf-cleanroom.patch (96%) diff --git a/sane-backends-1.0.24-update-to-current-lprng-plp_snprintf.patch b/sane-backends-1.0.24-snprintf-cleanroom.patch similarity index 96% rename from sane-backends-1.0.24-update-to-current-lprng-plp_snprintf.patch rename to sane-backends-1.0.24-snprintf-cleanroom.patch index 9e3764d..92cf72f 100644 --- a/sane-backends-1.0.24-update-to-current-lprng-plp_snprintf.patch +++ b/sane-backends-1.0.24-snprintf-cleanroom.patch @@ -1,6 +1,31 @@ -diff -up sane-backends-1.0.24/lib/snprintf.c.OLD sane-backends-1.0.24/lib/snprintf.c ---- sane-backends-1.0.24/lib/snprintf.c.OLD 2013-02-22 21:00:56.000000000 -0500 -+++ sane-backends-1.0.24/lib/snprintf.c 2014-05-29 11:22:46.150023325 -0400 +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 @@ -19,92 +44,30 @@ diff -up sane-backends-1.0.24/lib/snprintf.c.OLD sane-backends-1.0.24/lib/snprin + * 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. -- --Definitions: -- -- "Package" refers to the collection of files distributed by the -- Copyright Holder, and derivatives of that collection of files -- created through textual modification. -- -- "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. -- -- "Copyright Holder" is whoever is named in the copyright or -- copyrights for the package. -- -- "You" is you, if you are thinking about copying or distributing -- this Package. -- -- "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.) - -- "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. -- --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. -- --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. -- --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: -- -- 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. -- -- b) use the modified Package only within your corporation or organization. -- -- 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. -- -- 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: -+/* -+ Overview: - -- 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. -+ 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 -+ + 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 @@ -112,14 +75,22 @@ diff -up sane-backends-1.0.24/lib/snprintf.c.OLD sane-backends-1.0.24/lib/snprin + 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. @@ -127,46 +98,80 @@ diff -up sane-backends-1.0.24/lib/snprintf.c.OLD sane-backends-1.0.24/lib/snprin + 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 -+ ++ - 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, @@ -197,7 +202,10 @@ diff -up sane-backends-1.0.24/lib/snprintf.c.OLD sane-backends-1.0.24/lib/snprin + 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, + [ @@ -223,8 +231,13 @@ diff -up sane-backends-1.0.24/lib/snprintf.c.OLD sane-backends-1.0.24/lib/snprin + 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[]; @@ -250,9 +263,19 @@ diff -up sane-backends-1.0.24/lib/snprintf.c.OLD sane-backends-1.0.24/lib/snprin + 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, + [ @@ -265,7 +288,10 @@ diff -up sane-backends-1.0.24/lib/snprintf.c.OLD sane-backends-1.0.24/lib/snprin + 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, + [ @@ -278,7 +304,10 @@ diff -up sane-backends-1.0.24/lib/snprintf.c.OLD sane-backends-1.0.24/lib/snprin + 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, + [ @@ -291,9 +320,19 @@ diff -up sane-backends-1.0.24/lib/snprintf.c.OLD sane-backends-1.0.24/lib/snprin + 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 + @@ -535,25 +574,12 @@ diff -up sane-backends-1.0.24/lib/snprintf.c.OLD sane-backends-1.0.24/lib/snprin + 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. - -- b) accompany the distribution with the machine-readable source of -- the Package with your modifications. ++ + The typedef names quad_t and u_quad_t are infelicitous. - -- 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. ++ +*/ - -- 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. ++ ++ +#include +#include +#include @@ -568,30 +594,24 @@ diff -up sane-backends-1.0.24/lib/snprintf.c.OLD sane-backends-1.0.24/lib/snprin +#include +#endif --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. -+/* + /* +- * 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 - --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. ++ +/**** ENDINCLUDE ****/ - -- The End --#include "lp.h" ++ +/************************************************* + * 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"; @@ -622,18 +642,12 @@ diff -up sane-backends-1.0.24/lib/snprintf.c.OLD sane-backends-1.0.24/lib/snprin +# else + XX ** NO VARARGS ** XX +# endif - #endif ++#endif --#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 * 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; @@ -645,20 +659,12 @@ diff -up sane-backends-1.0.24/lib/snprintf.c.OLD sane-backends-1.0.24/lib/snprin +#endif + double dvalue; +}; - --static char *const _id = "$Id$"; -+#undef CVAL ++ ++#undef CVAL +#define CVAL(s) (*((unsigned char *)s)) +#define safestrlen(s) ((s)?strlen(s):0) - --/* -- * dopr(): poor man's version of doprintf -- */ - --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, ++ ++ + static char * plp_Errormsg ( int err, char *buffer ); + static void dopr( int visible_control, char **buffer, int *left, + const char *format, va_list args ); @@ -697,12 +703,6 @@ diff -up sane-backends-1.0.24/lib/snprintf.c.OLD sane-backends-1.0.24/lib/snprin - **************************************************************/ - -int vsnprintf(char *str, size_t count, const char *fmt, va_list args) --{ -- str[0] = 0; -- end = str+count-1; -- dopr( str, fmt, args ); -- if( count>0 ){ -- end[0] = 0; + static void dostr( char **buffer, int *left, char *str ); + static void dopr_outch( char **buffer, int *left, int c ); +/* VARARGS3 */ @@ -738,7 +738,12 @@ diff -up sane-backends-1.0.24/lib/snprintf.c.OLD sane-backends-1.0.24/lib/snprin +#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; @@ -822,7 +827,7 @@ diff -up sane-backends-1.0.24/lib/snprintf.c.OLD sane-backends-1.0.24/lib/snprin char *strvalue; int ljust; int len; -@@ -207,22 +669,30 @@ static void dopr( char *buffer, const ch +@@ -207,22 +669,30 @@ static void dopr( char *buffer, const char *format, va_list args ) int set_precision; double dval; int err = errno; @@ -837,7 +842,8 @@ diff -up sane-backends-1.0.24/lib/snprintf.c.OLD sane-backends-1.0.24/lib/snprin + longflag = quadflag = + ljust = len = zpad = base = signed_val = 0; precision = -1; set_precision = 0; - nextch: +- nextch: ++ nextch: ch = *format++; switch( ch ){ case 0: @@ -857,7 +863,7 @@ diff -up sane-backends-1.0.24/lib/snprintf.c.OLD sane-backends-1.0.24/lib/snprin 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 ch +@@ -234,76 +704,91 @@ static void dopr( char *buffer, const char *format, va_list args ) len = len*10 + ch - '0'; } goto nextch; @@ -992,7 +998,7 @@ diff -up sane-backends-1.0.24/lib/snprintf.c.OLD sane-backends-1.0.24/lib/snprin } /* -@@ -312,63 +797,69 @@ static void dopr( char *buffer, const ch +@@ -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 */ @@ -1022,11 +1028,11 @@ diff -up sane-backends-1.0.24/lib/snprintf.c.OLD sane-backends-1.0.24/lib/snprin + ++strlenv; } + ++strlenv; - } -- padlen = len - strlen; ++ } + if( precision > 0 && strlenv > precision ){ + strlenv = precision; -+ } + } +- padlen = len - strlen; + padlen = len - strlenv; if( padlen < 0 ) padlen = 0; if( ljust ) padlen = -padlen; @@ -1084,11 +1090,11 @@ diff -up sane-backends-1.0.24/lib/snprintf.c.OLD sane-backends-1.0.24/lib/snprin + if( value->value < 0 ) { signvalue = '-'; - uvalue = -value; -+ uvalue = -value->value; ++ uvalue = -value->value; } } if( base < 0 ){ -@@ -385,71 +876,148 @@ fmtnum( long value, int base, int dosig +@@ -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; @@ -1151,28 +1157,23 @@ diff -up sane-backends-1.0.24/lib/snprintf.c.OLD sane-backends-1.0.24/lib/snprin + /* 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; -+ if( base < 0 ){ -+ caps = 1; ++ 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; -+ -+ 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 > len ) precision = len; -- strcpy( fmtstr, "%" ); -- if( ljust ) strcat(fmtstr, "-" ); -- if( len ){ -- sprintf( fmtstr+strlen(fmtstr), "%d", len ); + convert[2*i] = 0; + + place = strlen(convert); @@ -1191,23 +1192,37 @@ diff -up sane-backends-1.0.24/lib/snprintf.c.OLD sane-backends-1.0.24/lib/snprin + 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); @@ -1234,29 +1249,20 @@ diff -up sane-backends-1.0.24/lib/snprintf.c.OLD sane-backends-1.0.24/lib/snprin + if( zpad ) mystrcat(formatstr, "0" ); /* 1 */ + if( len >= 0 ){ + sprintf( formatstr+strlen(formatstr), "%d", len ); /* 3 */ - } -- if( precision > 0 ){ -- sprintf( fmtstr+strlen(fmtstr), ".%d", precision ); ++ } + if( precision >= 0 ){ + sprintf( formatstr+strlen(formatstr), ".%d", precision ); /* 3 */ - } -- l = strlen( fmtstr ); -- fmtstr[l] = fmt; -- fmtstr[l+1] = 0; -- sprintf( convert, fmtstr, value ); -- dostr( convert ); ++ } + /* 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 *str ) ++} ++ + static void dostr( char **buffer, int *left, char *str ) - { -- while(*str) dopr_outch(*str++); ++{ + if(str)while(*str) dopr_outch( buffer, left, *str++ ); } @@ -1388,3 +1394,6 @@ diff -up sane-backends-1.0.24/lib/snprintf.c.OLD sane-backends-1.0.24/lib/snprin return(0); } #endif +-- +2.4.2 + diff --git a/sane-backends.spec b/sane-backends.spec index 1c730f2..c1fee3e 100644 --- a/sane-backends.spec +++ b/sane-backends.spec @@ -79,7 +79,7 @@ Patch7: sane-backends-1.0.24-scsi-permissions.patch 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-update-to-current-lprng-plp_snprintf.patch +Patch9: sane-backends-1.0.24-snprintf-cleanroom.patch URL: http://www.sane-project.org @@ -197,7 +197,7 @@ This package contains backend drivers to access digital cameras through SANE. %patch6 -p1 -b .static-code-check %patch7 -p1 -b .scsi-permissions %patch8 -p1 -b .format-security -%patch9 -p1 -b .snprintf +%patch9 -p1 -b .snprintf-cleanroom %build CFLAGS="%optflags -fno-strict-aliasing" @@ -319,6 +319,9 @@ udevadm hwdb --update >/dev/null 2>&1 || : %{_libdir}/sane/*gphoto2.so* %changelog +* Tue Jun 09 2015 Nils Philippsen +- reformat and rename snprintf-cleanroom patch + * Mon Jun 08 2015 Nils Philippsen - apply format-security patch, drop format-security2 patch