summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTill Kamppeter <till.kamppeter@gmail.com>2010-12-15 21:21:32 +0100
committerTill Kamppeter <till.kamppeter@gmail.com>2010-12-15 21:21:32 +0100
commitba49ab606cb10ae2b9b9900fd361bf264988261c (patch)
tree9e2caecdc2e7b524fdbc5ff90d7e4da128be2b2e
parent3e6f9d2acd431cf866429e8238f70d1d7a44b386 (diff)
foomatic-filters 4.0.6-0ubuntu1ubuntu/4.0.6-0ubuntu1
-rw-r--r--ChangeLog60
-rw-r--r--README2
-rw-r--r--USAGE2
-rw-r--r--VERSION2
-rw-r--r--VERSION.full2
-rwxr-xr-xconfigure20
-rw-r--r--configure.ac2
-rw-r--r--debian/changelog17
-rw-r--r--debian/patches/series2
-rw-r--r--debian/patches/strncpy-tochar-use-isempty.patch69
-rw-r--r--debian/patches/unhtmlify-segfault.patch56
-rw-r--r--fileconverter.c4
-rw-r--r--foomaticrip.c26
-rw-r--r--options.c121
-rw-r--r--util.c15
15 files changed, 209 insertions, 191 deletions
diff --git a/ChangeLog b/ChangeLog
index 53f992b..4180489 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,49 @@
+2010-12-15 Till Kamppeter <till.kamppeter@gmail.com>
+
+ * Tagged branch for release 4.0.6.
+
+ * VERSION, README, USAGE, configure.ac: Updated for release 4.0.6.
+
+ * options.c: Allow length limitation for the substitution of the special
+ entities "&job;", "&user;", "&host;", "&title;", and "&options;":
+ The maximum length can be supplied via the PPD keywords
+ "*FoomaticRIP<Item>EntityMaxLength: <mexlength>" (for example
+ "*FoomaticRIPUserEntityMaxLength: 8") or by adding a number to the
+ individual entities (for example "&user8;"). If the string to
+ insert for the entity is longer than the limit, it gets cut off to
+ the limit. Feature requested by Uli Wehner from Ricoh
+ (http://forums.linux-foundation.org/read.php?30,13134).
+
+2010-12-10 Till Kamppeter <till.kamppeter@gmail.com>
+
+ * foomaticrip.c: Make file type detection also work if the PostScript
+ or PDF input is preceeded by PJL with an additional '%' character.
+ Thanks to Alexpro for reporting this as Ubuntu bug #688551 and
+ supplying the patch.
+
+2010-11-11 Till Kamppeter <till.kamppeter@gmail.com>
+
+ * util.c: The temp_dir() function did not take into account that
+ getenv() can return NULL. In such a case the fallback to /tmp
+ did not work. Thanks to Abel Abraham Camarillo Ojeda (spam at
+ verlet dot org) for the patch (bug #552).
+
+ * fileconverter.c: Make the check for the text filter actually
+ work. Before, the text filter choice from the configuration file
+ was simply taken for good and not checked whether it is supported.
+ Thanks to Abel Abraham Camarillo Ojeda (spam at verlet dot org)
+ for the patch (bug #551).
+
+2010-08-27 Till Kamppeter <till.kamppeter@gmail.com>
+
+ * options.c: Made sure that the unhtmlify() function does not write
+ the zero byte to mark the string end beyond the buffer. Also use a
+ much larger buffer for parsing "*FoomaticRIPOptionPrototype:" in
+ the PPD file (bug #515).
+
+ * util.c: In strncpy_tochar() use the isempty() function to check
+ whether the input string is empty (bug #514).
+
2010-08-10 Till Kamppeter <till.kamppeter@gmail.com>
* Tagged branch for release 4.0.5.
@@ -10,34 +56,36 @@
page size in the prototype string for the custom page size
working. Before, only substitution of %0 and %1 worked reliably.
Thanks to Lutz Sammer (johns98 at web dot de) for reporting this
- problem.
+ problem (see also bug 514, comment #1).
* options.c: Make custom page size settings also work if the custom
size is set via embedded PostScript code and the comment to mark
the selected option setting is only "%% FoomaticRIPOptionSetting:
PageSize=Custom", without the size and unit parameters. Thanks to
- Lutz Sammer for reporting this problem.
+ Lutz Sammer for reporting this problem (see also bug 514, comment #1).
2010-07-02 Till Kamppeter <till.kamppeter@gmail.com>
* spooler.c: Config file for the default printer in spooler-less
(direct) printing mode was not read correctly. Thanks to Lutz
- Sammer (johns98 at web dot de) for reporting this problem.
+ Sammer (johns98 at web dot de) for reporting this problem (see
+ also bug 514, comment #1).
* spooler.c: Fixed error message output if a printer's PPD is missing
in spooler-less mode. There was a segfault due to the printer name
not specified in the _log() function call. Thanks to Lutz Sammer
- for reporting this problem.
+ for reporting this problem (see also bug 514, comment #1).
* util.c: The isempty() function did not consider NULL as an empty
string. This caused segfaults when a string is considered non-empty
but in fact it is NULL. Thanks to Lutz Sammer for reporting this
- problem.
+ problem (see also bug 514, comment #1).
* util.c: strncpy_tochar() did not check whether the input string
is empty and returned a pointer one character beyond the input
string, leading to segfaults in the code calling this function.
- Thanks to Lutz Sammer for reporting this problem.
+ Thanks to Lutz Sammer for reporting this problem (see also bug 514,
+ comment #1).
2010-06-08 Till Kamppeter <till.kamppeter@gmail.com>
diff --git a/README b/README
index 7c5da05..cd2a514 100644
--- a/README
+++ b/README
@@ -1,5 +1,5 @@
-Foomatic 4.0.5
+Foomatic 4.0.6
==============
diff --git a/USAGE b/USAGE
index 7d173a1..b760f3f 100644
--- a/USAGE
+++ b/USAGE
@@ -1,5 +1,5 @@
-Foomatic 4.0.5
+Foomatic 4.0.6
==============
foomatic-filters
diff --git a/VERSION b/VERSION
index 7636e75..d13e837 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-4.0.5
+4.0.6
diff --git a/VERSION.full b/VERSION.full
index 0171aa7..e0049e4 100644
--- a/VERSION.full
+++ b/VERSION.full
@@ -1 +1 @@
-4.0.5.223
+4.0.6.230
diff --git a/configure b/configure
index 24e7d2a..d4fe980 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.61 for foomatic-rip "4.0.5".
+# Generated by GNU Autoconf 2.61 for foomatic-rip "4.0.6".
#
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
@@ -572,8 +572,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='foomatic-rip'
PACKAGE_TARNAME='foomatic-rip'
-PACKAGE_VERSION='"4.0.5"'
-PACKAGE_STRING='foomatic-rip "4.0.5"'
+PACKAGE_VERSION='"4.0.6"'
+PACKAGE_STRING='foomatic-rip "4.0.6"'
PACKAGE_BUGREPORT=''
ac_unique_file="options.c"
@@ -1232,7 +1232,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures foomatic-rip "4.0.5" to adapt to many kinds of systems.
+\`configure' configures foomatic-rip "4.0.6" to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1298,7 +1298,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of foomatic-rip "4.0.5":";;
+ short | recursive ) echo "Configuration of foomatic-rip "4.0.6":";;
esac
cat <<\_ACEOF
@@ -1394,7 +1394,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-foomatic-rip configure "4.0.5"
+foomatic-rip configure "4.0.6"
generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1408,7 +1408,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by foomatic-rip $as_me "4.0.5", which was
+It was created by foomatic-rip $as_me "4.0.6", which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
@@ -2098,7 +2098,7 @@ fi
# Define the identity of the package.
PACKAGE='foomatic-rip'
- VERSION='"4.0.5"'
+ VERSION='"4.0.6"'
# Some tools Automake needs.
@@ -7850,7 +7850,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by foomatic-rip $as_me "4.0.5", which was
+This file was extended by foomatic-rip $as_me "4.0.6", which was
generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -7903,7 +7903,7 @@ Report bugs to <bug-autoconf@gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
-foomatic-rip config.status "4.0.5"
+foomatic-rip config.status "4.0.6"
configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
diff --git a/configure.ac b/configure.ac
index 3efca32..7e5ab5e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61)
-AC_INIT(foomatic-rip, "4.0.5")
+AC_INIT(foomatic-rip, "4.0.6")
AM_INIT_AUTOMAKE([no-define])
AC_CONFIG_SRCDIR([options.c])
diff --git a/debian/changelog b/debian/changelog
index b100e16..7b8068a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,20 @@
+foomatic-filters (4.0.6-0ubuntu1) natty; urgency=low
+
+ * New upstream release
+ - Allow length limitations for the job parameter strings inserted for
+ the special entities "&job;", "&user;", "&host;", "&title;", and
+ "&options;" in code snippets for the renderer command line.
+ - Make foomatic-rip determine correctly whether the input is PostScript
+ or PDF also if the input is preceded by PJL.
+ - Non-CUPS use: Do not blindly use the text filter requested by the
+ configuration file, check whether it is supported.
+ - Fixed several segfaults.
+ * debian/patches/strncpy-tochar-use-isempty.patch,
+ debian/patches/unhtmlify-segfault.patch: Removed patches with fixes
+ backported from upstream.
+
+ -- Till Kamppeter <till.kamppeter@gmail.com> Wed, 15 Dec 2010 20:49:03 +0100
+
foomatic-filters (4.0.5-6) unstable; urgency=low
[ Till Kamppeter ]
diff --git a/debian/patches/series b/debian/patches/series
deleted file mode 100644
index 07477d4..0000000
--- a/debian/patches/series
+++ /dev/null
@@ -1,2 +0,0 @@
-strncpy-tochar-use-isempty.patch
-unhtmlify-segfault.patch
diff --git a/debian/patches/strncpy-tochar-use-isempty.patch b/debian/patches/strncpy-tochar-use-isempty.patch
deleted file mode 100644
index 7fb83ac..0000000
--- a/debian/patches/strncpy-tochar-use-isempty.patch
+++ /dev/null
@@ -1,69 +0,0 @@
-=== modified file 'ChangeLog'
---- foomatic-filters/ChangeLog 2010-08-10 10:06:19 +0000
-+++ foomatic-filters/ChangeLog 2010-08-27 18:01:04 +0000
-@@ -1,3 +1,8 @@
-+2010-08-27 Till Kamppeter <till.kamppeter@gmail.com>
-+
-+ * util.c: In strncpy_tochar() use the isempty() function to check
-+ whether the input string is empty (bug #514).
-+
- 2010-08-10 Till Kamppeter <till.kamppeter@gmail.com>
-
- * Tagged branch for release 4.0.5.
-@@ -10,34 +15,36 @@
- page size in the prototype string for the custom page size
- working. Before, only substitution of %0 and %1 worked reliably.
- Thanks to Lutz Sammer (johns98 at web dot de) for reporting this
-- problem.
-+ problem (see also bug 514, comment #1).
-
- * options.c: Make custom page size settings also work if the custom
- size is set via embedded PostScript code and the comment to mark
- the selected option setting is only "%% FoomaticRIPOptionSetting:
- PageSize=Custom", without the size and unit parameters. Thanks to
-- Lutz Sammer for reporting this problem.
-+ Lutz Sammer for reporting this problem (see also bug 514, comment #1).
-
- 2010-07-02 Till Kamppeter <till.kamppeter@gmail.com>
-
- * spooler.c: Config file for the default printer in spooler-less
- (direct) printing mode was not read correctly. Thanks to Lutz
-- Sammer (johns98 at web dot de) for reporting this problem.
-+ Sammer (johns98 at web dot de) for reporting this problem (see
-+ also bug 514, comment #1).
-
- * spooler.c: Fixed error message output if a printer's PPD is missing
- in spooler-less mode. There was a segfault due to the printer name
- not specified in the _log() function call. Thanks to Lutz Sammer
-- for reporting this problem.
-+ for reporting this problem (see also bug 514, comment #1).
-
- * util.c: The isempty() function did not consider NULL as an empty
- string. This caused segfaults when a string is considered non-empty
- but in fact it is NULL. Thanks to Lutz Sammer for reporting this
-- problem.
-+ problem (see also bug 514, comment #1).
-
- * util.c: strncpy_tochar() did not check whether the input string
- is empty and returned a pointer one character beyond the input
- string, leading to segfaults in the code calling this function.
-- Thanks to Lutz Sammer for reporting this problem.
-+ Thanks to Lutz Sammer for reporting this problem (see also bug 514,
-+ comment #1).
-
- 2010-06-08 Till Kamppeter <till.kamppeter@gmail.com>
-
-
-=== modified file 'util.c'
---- foomatic-filters/util.c 2010-07-02 15:57:09 +0000
-+++ foomatic-filters/util.c 2010-08-27 18:01:04 +0000
-@@ -272,7 +272,7 @@
- {
- const char *psrc = src;
- char *pdest = dest;
-- if (!*psrc) {
-+ if (isempty(psrc)) {
- return NULL;
- }
- while (*psrc && --max > 0 && !strchr(stopchars, *psrc)) {
-
diff --git a/debian/patches/unhtmlify-segfault.patch b/debian/patches/unhtmlify-segfault.patch
deleted file mode 100644
index c30875d..0000000
--- a/debian/patches/unhtmlify-segfault.patch
+++ /dev/null
@@ -1,56 +0,0 @@
-=== modified file 'ChangeLog'
---- foomatic-filters/ChangeLog 2010-08-27 18:01:04 +0000
-+++ foomatic-filters/ChangeLog 2010-08-27 23:41:04 +0000
-@@ -1,5 +1,10 @@
- 2010-08-27 Till Kamppeter <till.kamppeter@gmail.com>
-
-+ * options.c: Made sure that the unhtmlify() function does not write
-+ the zero byte to mark the string end beyond the buffer. Also use a
-+ much larger buffer for parsing "*FoomaticRIPOptionPrototype:" in
-+ the PPD file (bug #515).
-+
- * util.c: In strncpy_tochar() use the isempty() function to check
- whether the input string is empty (bug #514).
-
-
-=== modified file 'options.c'
---- foomatic-filters/options.c 2010-07-07 21:49:47 +0000
-+++ foomatic-filters/options.c 2010-08-27 23:41:04 +0000
-@@ -1088,8 +1088,9 @@
- const char *repl;
- struct tm *t = localtime(&job->time);
- char tmpstr[10];
-+ size_t s;
-
-- while (*psrc && pdest - dest < size) {
-+ while (*psrc && pdest - dest < size - 1) {
-
- if (*psrc == '&') {
- psrc++;
-@@ -1154,8 +1155,12 @@
- }
-
- if (repl) {
-- strncpy(pdest, repl, size - (pdest - dest));
-- pdest += strlen(repl);
-+ s = size - (pdest - dest) - 1;
-+ strncpy(pdest, repl, s);
-+ if (s < strlen(repl))
-+ pdest += s;
-+ else
-+ pdest += strlen(repl);
- psrc = strchr(psrc, ';') +1;
- }
- else {
-@@ -1601,8 +1606,8 @@
- /* "*FoomaticRIPOptionPrototype <option>: <code>"
- Used for numerical and string options only */
- opt = assure_option(name);
-- opt->proto = malloc(128);
-- unhtmlify(opt->proto, 128, value->data);
-+ opt->proto = malloc(65536);
-+ unhtmlify(opt->proto, 65536, value->data);
- }
- else if (!strcmp(key, "FoomaticRIPOptionRange")) {
- /* *FoomaticRIPOptionRange <option>: <min> <max>
-
diff --git a/fileconverter.c b/fileconverter.c
index 6751dbf..baee2a9 100644
--- a/fileconverter.c
+++ b/fileconverter.c
@@ -49,8 +49,10 @@ void set_fileconverter(const char *fc)
{
int i;
for (i = 0; fileconverters[i][0]; i++) {
- if (!strcmp(fc, fileconverters[i][0]))
+ if (!strcmp(fc, fileconverters[i][0])) {
strlcpy(fileconverter, fileconverters[i][1], PATH_MAX);
+ break;
+ }
}
if (!fileconverters[i][0])
strlcpy(fileconverter, fc, PATH_MAX);
diff --git a/foomaticrip.c b/foomaticrip.c
index aad3953..089e4ff 100644
--- a/foomaticrip.c
+++ b/foomaticrip.c
@@ -946,16 +946,22 @@ enum FileType {
int guess_file_type(const char *begin, size_t len, int *startpos)
{
- const char * p;
-
- p = memchr(begin, '%', len);
- if (!p)
- return UNKNOWN_FILE;
- *startpos = p - begin;
- if (!memcmp(p, "%!", 2))
- return PS_FILE;
- else if (!memcmp(p, "%PDF-1.", 7))
- return PDF_FILE;
+ const char * p, * end;
+ p = begin;
+ end = begin + len;
+
+ while (p < end)
+ {
+ p = memchr(p, '%', end - p);
+ if (!p)
+ return UNKNOWN_FILE;
+ *startpos = p - begin;
+ if ((end - p) > 2 && !memcmp(p, "%!", 2))
+ return PS_FILE;
+ else if ((end - p) > 7 && !memcmp(p, "%PDF-1.", 7))
+ return PDF_FILE;
+ ++ p;
+ }
*startpos = 0;
return UNKNOWN_FILE;
}
diff --git a/options.c b/options.c
index f69d0cb..9a4b116 100644
--- a/options.c
+++ b/options.c
@@ -42,6 +42,11 @@ dstr_t *postpipe = NULL; /* command into which the output of this
filter should be piped */
int ps_accounting = 1;
char cupsfilter [256];
+int jobentitymaxlen = 0;
+int userentitymaxlen = 0;
+int hostentitymaxlen = 0;
+int titleentitymaxlen = 0;
+int optionsentitymaxlen = 0;
/* JCL prefix to put before the JCL options
(Can be modified by a "*JCLBegin:" keyword in the ppd file): */
@@ -1084,79 +1089,123 @@ static void unhtmlify(char *dest, size_t size, const char *src)
{
jobparams_t *job = get_current_job();
char *pdest = dest;
- const char *psrc = src;
+ const char *psrc = src, *p = NULL;
const char *repl;
struct tm *t = localtime(&job->time);
char tmpstr[10];
+ size_t s, l, n;
- while (*psrc && pdest - dest < size) {
+ while (*psrc && pdest - dest < size - 1) {
if (*psrc == '&') {
psrc++;
repl = NULL;
+ p = NULL;
+ l = 0;
/* Replace HTML/XML entities by the original characters */
- if (!prefixcmp(psrc, "apos;"))
+ if (!prefixcmp(psrc, "apos")) {
repl = "\'";
- else if (!prefixcmp(psrc, "quot;"))
+ p = psrc + 4;
+ } else if (!prefixcmp(psrc, "quot")) {
repl = "\"";
- else if (!prefixcmp(psrc, "gt;"))
+ p = psrc + 4;
+ } else if (!prefixcmp(psrc, "gt")) {
repl = ">";
- else if (!prefixcmp(psrc, "lt;"))
+ p = psrc + 2;
+ } else if (!prefixcmp(psrc, "lt")) {
repl = "<";
- else if (!prefixcmp(psrc, "amp;"))
+ p = psrc + 2;
+ } else if (!prefixcmp(psrc, "amp")) {
repl = "&";
+ p = psrc + 3;
/* Replace special entities by job->data */
- else if (!prefixcmp(psrc, "job;"))
+ } else if (!prefixcmp(psrc, "job")) {
repl = job->id;
- else if (!prefixcmp(psrc, "user;"))
+ p = psrc + 3;
+ if (jobentitymaxlen != 0)
+ l = jobentitymaxlen;
+ } else if (!prefixcmp(psrc, "user")) {
repl = job->user;
- else if (!prefixcmp(psrc, "host;"))
+ p = psrc + 4;
+ if (userentitymaxlen != 0)
+ l = userentitymaxlen;
+ } else if (!prefixcmp(psrc, "host")) {
repl = job->host;
- else if (!prefixcmp(psrc, "title;"))
+ p = psrc + 4;
+ if (hostentitymaxlen != 0)
+ l = hostentitymaxlen;
+ } else if (!prefixcmp(psrc, "title")) {
repl = job->title;
- else if (!prefixcmp(psrc, "copies;"))
+ p = psrc + 5;
+ if (titleentitymaxlen != 0)
+ l = titleentitymaxlen;
+ } else if (!prefixcmp(psrc, "copies")) {
repl = job->copies;
- else if (!prefixcmp(psrc, "rbinumcopies;")) {
+ p = psrc + 6;
+ } else if (!prefixcmp(psrc, "rbinumcopies")) {
if (job->rbinumcopies > 0) {
snprintf(tmpstr, 10, "%d", job->rbinumcopies);
repl = tmpstr;
}
else
repl = job->copies;
+ p = psrc + 12;
}
- else if (!prefixcmp(psrc, "options;"))
+ else if (!prefixcmp(psrc, "options")) {
repl = job->optstr->data;
- else if (!prefixcmp(psrc, "year;")) {
+ p = psrc + 7;
+ if (optionsentitymaxlen != 0)
+ l = optionsentitymaxlen;
+ } else if (!prefixcmp(psrc, "year")) {
sprintf(tmpstr, "%04d", t->tm_year + 1900);
repl = tmpstr;
+ p = psrc + 4;
}
- else if (!prefixcmp(psrc, "month;")) {
+ else if (!prefixcmp(psrc, "month")) {
sprintf(tmpstr, "%02d", t->tm_mon + 1);
repl = tmpstr;
+ p = psrc + 5;
}
- else if (!prefixcmp(psrc, "date;")) {
+ else if (!prefixcmp(psrc, "date")) {
sprintf(tmpstr, "%02d", t->tm_mday);
repl = tmpstr;
+ p = psrc + 4;
}
- else if (!prefixcmp(psrc, "hour;")) {
+ else if (!prefixcmp(psrc, "hour")) {
sprintf(tmpstr, "%02d", t->tm_hour);
repl = tmpstr;
+ p = psrc + 4;
}
- else if (!prefixcmp(psrc, "min;")) {
+ else if (!prefixcmp(psrc, "min")) {
sprintf(tmpstr, "%02d", t->tm_min);
repl = tmpstr;
+ p = psrc + 3;
}
- else if (!prefixcmp(psrc, "sec;")) {
+ else if (!prefixcmp(psrc, "sec")) {
sprintf(tmpstr, "%02d", t->tm_sec);
repl = tmpstr;
+ p = psrc + 3;
}
-
+ if (p) {
+ n = strtol(p, (char **)(&p), 0);
+ if (n != 0)
+ l = n;
+ if (*p != ';')
+ repl = NULL;
+ } else
+ repl = NULL;
if (repl) {
- strncpy(pdest, repl, size - (pdest - dest));
- pdest += strlen(repl);
- psrc = strchr(psrc, ';') +1;
+ if ((l == 0) || (l > strlen(repl)))
+ l = strlen(repl);
+ s = size - (pdest - dest) - 1;
+ strncpy(pdest, repl, s);
+ if (s < l)
+ pdest += s;
+ else
+ pdest += l;
+ psrc = p + 1;
}
else {
*pdest = '&';
@@ -1601,8 +1650,8 @@ void read_ppd_file(const char *filename)
/* "*FoomaticRIPOptionPrototype <option>: <code>"
Used for numerical and string options only */
opt = assure_option(name);
- opt->proto = malloc(128);
- unhtmlify(opt->proto, 128, value->data);
+ opt->proto = malloc(65536);
+ unhtmlify(opt->proto, 65536, value->data);
}
else if (!strcmp(key, "FoomaticRIPOptionRange")) {
/* *FoomaticRIPOptionRange <option>: <min> <max>
@@ -1699,6 +1748,26 @@ void read_ppd_file(const char *filename)
"longer supported by Foomatic >4.0. Exiting.\n");
exit(1); /* TODO exit more gracefully */
}
+ else if (!strcmp(key, "FoomaticRIPJobEntityMaxLength")) {
+ /* "*FoomaticRIPJobEntityMaxLength: <length>" */
+ sscanf(value->data, "%d", &jobentitymaxlen);
+ }
+ else if (!strcmp(key, "FoomaticRIPUserEntityMaxLength")) {
+ /* "*FoomaticRIPUserEntityMaxLength: <length>" */
+ sscanf(value->data, "%d", &userentitymaxlen);
+ }
+ else if (!strcmp(key, "FoomaticRIPHostEntityMaxLength")) {
+ /* "*FoomaticRIPHostEntityMaxLength: <length>" */
+ sscanf(value->data, "%d", &hostentitymaxlen);
+ }
+ else if (!strcmp(key, "FoomaticRIPTitleEntityMaxLength")) {
+ /* "*FoomaticRIPTitleEntityMaxLength: <length>" */
+ sscanf(value->data, "%d", &titleentitymaxlen);
+ }
+ else if (!strcmp(key, "FoomaticRIPOptionsEntityMaxLength")) {
+ /* "*FoomaticRIPOptionsEntityMaxLength: <length>" */
+ sscanf(value->data, "%d", &optionsentitymaxlen);
+ }
}
fclose(fh);
diff --git a/util.c b/util.c
index 9055648..382fbcb 100644
--- a/util.c
+++ b/util.c
@@ -39,14 +39,15 @@ const char * temp_dir()
if (!tmpdir)
{
- const char *dirs[] = { getenv("TMPDIR"), P_tmpdir, "/tmp", NULL };
- const char **dir;
+ const char *dirs[] = { getenv("TMPDIR"), P_tmpdir, "/tmp" };
+ int i;
- for (dir = dirs; *dir; dir++)
- if (access(*dir, W_OK) == 0) {
- tmpdir = *dir;
+ for (i = 0; i < (sizeof(dirs) / sizeof(dirs[0])); i++) {
+ if (access(dirs[i], W_OK) == 0) {
+ tmpdir = dirs[i];
break;
}
+ }
if (tmpdir)
{
_log("Storing temporary files in %s\n", tmpdir);
@@ -162,6 +163,7 @@ strcasestr (const char *haystack, const char *needle)
}
#endif
+#ifndef __OpenBSD__
size_t strlcpy(char *dest, const char *src, size_t size)
{
char *pdest = dest;
@@ -201,6 +203,7 @@ size_t strlcat(char *dest, const char *src, size_t size)
return len + (psrc - src);
}
+#endif /* ! __OpenBSD__ */
void strrepl(char *str, const char *chars, char repl)
{
@@ -272,7 +275,7 @@ const char * strncpy_tochar(char *dest, const char *src, size_t max, const char
{
const char *psrc = src;
char *pdest = dest;
- if (!*psrc) {
+ if (isempty(psrc)) {
return NULL;
}
while (*psrc && --max > 0 && !strchr(stopchars, *psrc)) {