Rohit Kumar [Wed, 4 Mar 2026 03:47:37 +0000 (09:17 +0530)]
Enhance memory handling in read_jcl_lines
Improve memory management in read_jcl_lines function by using a temporary pointer for realloc and ensuring previously allocated lines are freed on failure.
Introduce foomatic-hash and reject unauthorized values in foomatic-rip (#648)
The change provides a way for users to have control over what values are
allowed for the foomatic-rip-related PPD keywords FoomaticRIPCommandLine,
FoomaticRIPCommandLinePDF, and FoomaticRIPOptionSetting. Since the
values can be later used when constructing a shell command, the filter
foomatic-rip was a target of several exploits (caused by issues at
different places in CUPS or in different projects of the printing stack) to
do arbitrary code execution when the filter is used.
By default the filter is run by user lp, so the issue is mitigated, but
this PR gives admin complete control over what can be run in
foomatic-rip and reject anything injected into system via different
ways.
First, the new tool - foomatic-hash - can be called on a PPD file or
directory with drivers/PPDs, with scan output and file with hexadecimal
representation of hashed values. Once the scan output is reviewed by
admin, admin can decide to put the resulting hashes into
/etc/foomatic/hashes.d and allow them for the filter.
Michael Weghorn [Fri, 5 Jul 2024 11:29:39 +0000 (13:29 +0200)]
pclmtoraster: Properly set CFLAGS (#588)
As this is a C program, set
`pclmtoraster_CFLAGS`, not `pclmtoraster_CXXFLAGS`.
This fixes building pclmtoraster when libcupsfilter
headers are installed in a non-standard directory.
Previously, when configuring and installing libcupsfilters
with e.g. `--prefix=$HOME/temp/cpdb` and then configuring
cups-filters with `PKG_CONFIG_PATH=$HOME/temp/cpdb/lib/pkgconfig/`,
`make pclmtoraster` would fail like this:
CC filter/pclmtoraster.o
filter/pclmtoraster.c:14:10: fatal error: cupsfilters/filter.h: No such file or directory
14 | #include <cupsfilters/filter.h>
| ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
For this to actually work, recent libcupsfilters
commit [1] is also needed:
Eli Schwartz [Fri, 8 Mar 2024 12:02:33 +0000 (07:02 -0500)]
configure: Fix broken bashism resulting in logic failure (#567)
After carefully using configure checks designed to work on pre-unix wars
bourne shells -- that is, the `test "$var" = ""` construct once upon a
time wasn't specified to treat "" as a distinct argument, and various
buggy implementations mishandled various forms where the first argument
started with a dash, so the "x" padding provided a guaranteed comparison
-- the configure.ac check then fails to run on any shells at all other
than GNU bash.
Bash provides the standard `test XXX = YYY` or `[ XXX = YYY ]`
utilities. It also provides the ability to spell the equals sign as a
double equals. This does nothing whatsoever -- it adds no new
functionality to bash, it forbids nothing, it is *literally* an exact
alias.
It should never be used under any circumstances. All developers must
immediately forget that it exists. Using it is non-portable and does not
work in /bin/sh scripts such as configure scripts, and it results in
dangerous muscle memory when used in bash scripts because it makes
people unthinkingly use the double equals even in /bin/sh scripts. To
add insult to injury, it makes scripts take up more disk space (by a
whole byte! and sometimes even a few bytes...)
Delete this accidental bashism, and restore the ability to get correct
./configure behavior on systems where /bin/sh is something other than a
symlink to GNU bash.
Enable application/vnd.cups-postscript in conversion tables (#534)
Unfortunately there are filters which produce this MIME type (such as
hpps from hplip), and if someone uses such driver on client and server
has IPP Everywhere/driverless driver, job fails.
The patch (together with change in libcupsfilters, which will come later)
fixes the issue.
Till Kamppeter [Wed, 17 May 2023 09:12:37 +0000 (11:12 +0200)]
Merge pull request from GHSA-gpxc-v2m8-fr3x
* beh backend: Use execv() instead of system() - CVE-2023-24805
With execv() command line arguments are passed as separate strings and
not the full command line in a single string. This prevents arbitrary
command execution by escaping the quoting of the arguments in a job
with forged job title.
* beh backend: Extra checks against odd/forged input - CVE-2023-24805
- Do not allow '/' in the scheme of the URI (= backend executable
name), to assure that only backends inside /usr/lib/cups/backend/
are used.
- Pre-define scheme buffer to empty string, to be defined for case of
uri being NULL.
- URI must have ':', to split off scheme, otherwise error.
- Check return value of snprintf() to create call path for backend, to
error out on truncation of a too long scheme or on complete failure
due to a completely odd scheme.
* beh backend: Further improvements - CVE-2023-24805
- Use strncat() instead of strncpy() for getting scheme from URI, the latter
does not require setting terminating zero byte in case of truncation.
- Also exclude "." or ".." as scheme, as directories are not valid CUPS
backends.
- Do not use fprintf() in sigterm_handler(), to not interfere with a
fprintf() which could be running in the main process when
sigterm_handler() is triggered.
- Use "static volatile int" for global variable job_canceled.
Adam Majer [Mon, 10 Apr 2023 14:22:46 +0000 (16:22 +0200)]
Drop C++ references and obsolete C standards (#513)
With no C++ compiler needed, there is no need to set the
CXXFLAGS or log it during configure. Furthermore, forcing
outdated C11 standard is not a good idea considering compilers
have moved on. We should not limit our feature set, including
compiler warnings, to old standards.
Steve Langasek [Fri, 17 Mar 2023 20:02:43 +0000 (13:02 -0700)]
foomatic-rip: Fix a SIGPIPE error when calling gs (#517)
https://autopkgtest.ubuntu.com/packages/f/foo2zjs/lunar/ppc64el shows
foo2zjs's testsuite failing with cups-filters 2.0beta3 on ppc64el because
the gs command here to check page count is failing with a SIGPIPE when
trying to write back to the parent. To fix this, we close gs's input fd as
soon as we know we're done writing to it. Since gs may not have started
processing its input until this happens, also give the final poll() a longer
timeout (5s instead of 1s); without this we see race conditions because
foomatic-rip gives up before gs has had a chance to finish processing.
Till Kamppeter [Wed, 18 Jan 2023 20:48:10 +0000 (17:48 -0300)]
COPYING, NOTICE: Simplification for autotools-generated files
autotools-generated files can be included under the license of the
upstream code, and FSF copyright added to upstream copyright
list. Simplified debian/copyright appropriately.
Till Kamppeter [Tue, 17 Jan 2023 16:53:23 +0000 (13:53 -0300)]
Build system: Do not explicitly check for libpoppler-cpp
The cups-filters does not contain any code using libpoppler-cpp,
therefore we let ./configure not check for it. This makes building
distribution packages easier.
Till Kamppeter [Fri, 6 Jan 2023 19:13:29 +0000 (16:13 -0300)]
README.md: Removed Printer Application links
The package cups-filters only contains classic CUPS filters and
backends, not relevant for Printer Applications, as they would use the
underlying filter functions of libcupsfilters.
Till Kamppeter [Thu, 17 Nov 2022 12:58:03 +0000 (13:58 +0100)]
Removed everything which got split out
In the New Architecture for printing we switch to an all-IPP workflow
with PPD files being abolished and classic CUPS printer drivers
replaced by Printer Applications (software emulation of driverless IPP
printers).
To conserve the functionality of the CUPS filters which got developed
over the last 20+ years into a PPD-less, IPP-driven world without
having to maintain and include the legacy PPD support in OS
distributions and other system environments, the original cups-filters
package got split into 5 separate packages: libcupsfilters, libppd,
cups-filters, braille-printer-app, and cups-browsed, with
libcupsfilters and braille-printer-app not containing PPD file support
code any more and cups-browsed being planned to drop explicit use of
PPD files.
This commit drops everything from the cups-filters repository which
got split out into the other 4, new repositories.
What remains are the CUPS filter executables, from which most are
wrappers around filter functions implemented in the libcupsfilters and
libppd libraries, backends, the "driverless" utility for setting up
driverless printers with classic printer setup tools, and auxiliary
files (PPD files, *.drv files, MIME rules, ...).
This package is needed for using CUPS 2.x with filters from
libcupsfilters (2.x) and libppd.
It is not needed/does not make sense to be used with CUPS 3.x or the
CUPS Snap (or any other containerized CUPS implementation). If you
need printer drivers for such CUPS versions, use Printer Applications.
Till Kamppeter [Mon, 14 Nov 2022 22:33:16 +0000 (23:33 +0100)]
Added DEVELOPING.md and CONTRIBUTING.md
These files are mainly overtaken from CUPS. They provide information
for contributors: Coding style, contact, where to report bugs/post
feature requests, ...
- Renamed NEWS to CHANGES.md
- Moved changes on 1.x to CHANGES-1.x.md
- As changes for 2.0b1 listed all changes compared to the last 1.x release
(1.28.16), in preparation for the separation already divided up by the
components.
- Converted README to README.md, some updates of the text.
Till Kamppeter [Fri, 11 Nov 2022 19:19:57 +0000 (20:19 +0100)]
Data files: Changed license info to Apache 2.0
Changed the license info in the file headers to the license used by
CUPS, on PostScript files, *.drv PPD generator files, M4 files, MIME
rules, and PPD files.
Till Kamppeter [Sun, 23 Oct 2022 19:21:41 +0000 (21:21 +0200)]
cups-browsed, driverless: Code clean-up for code of the utilities
Cleaned up the code in the utils/ drirectory following the coding
style rules in the DEVELOPING.md file of the CUPS source code.
This improves the readability of the code a lot, especially as missing
spaces got inserted in comma-separated lists ("xxx,yyy,zzz" -> "xxx,
yyy, zzz") and around operators ("x=a*(b+c)%4" -> "x = a * (b + c) %
4"), what got nearly completely missed out by several contributors.
Comments are re-formatted to use "// ..." instead of "/* ... */", like
in PAPPL, so C and C++ files get the same comment style.
Also we get rid of the mix of many different coding styles which came
together from the many code contributions received during more than a
decade, even before the start of the cups-filters project.
In addition, all the file's header comments reflect the new license,
Apache 2.0, the same license as used for CUPS.
Note that we did not clean up driverless.c, as here we still accept a
major code contribution from the GSoC.
Till Kamppeter [Sat, 22 Oct 2022 14:32:45 +0000 (16:32 +0200)]
CUPS backends: Code clean-up for code in backend/
Cleaned up the code of the legacy CUPS backends following the coding
style rules in the DEVELOPING.md file of the CUPS source code.
Comments are re-formatted to use "// ..." instead of "/* ... */", like
in PAPPL, so C and C++ files get the same comment style.
Also we get rid of the mix of many different coding styles which came
together from the many code contributions received during more than a
decade, even before the start of the cups-filters project.
In addition, all the file's header comments reflect the new license
now, Apache 2.0, the same license as used for CUPS.
Till Kamppeter [Fri, 21 Oct 2022 21:56:00 +0000 (23:56 +0200)]
CUPS filters: Code clean-up for code in filter/
Cleaned up the code of the legacy CUPS filters/filter function
wrappers following the coding style rules in the DEVELOPING.md file of
the CUPS source code.
Comments are re-formatted to use "// ..." instead of "/* ... */", like
in PAPPL, so C and C++ files get the same comment style.
Also we get rid of the mix of many different coding styles which came
together from the many code contributions received during more than a
decade, even before the start of the cups-filters project.
In addition, all the file's header comments reflect the new license
now, Apache 2.0, the same license as used for CUPS.
Till Kamppeter [Wed, 19 Oct 2022 21:38:59 +0000 (23:38 +0200)]
libppd: Code clean-up for code of foomatic-rip
Cleaned up the code following the coding style rules in the
DEVELOPING.md file of the CUPS source code.
Comments are re-formatted to use "// ..." instead of "/* ... */", like
in PAPPL, so C and C++ files get the same comment style.
The indent width is set to 2 spaces instead of 4, to match the other
files.
This way we get rid of the mix of many different coding styles which
came together from the many code contributions received during more
than a decade, even before the start of the cups-filters project.