From d7fb19dca20b7ad30da95d43cbdb9aa2d3714a0d Mon Sep 17 00:00:00 2001 From: AZero13 Date: Mon, 3 Nov 2025 19:55:13 -0500 Subject: [PATCH] Do not allow negative file descriptors to be closed Especially --- backend/lpd.c | 4 ++-- filter/rastertoepson.c | 2 +- filter/rastertohp.c | 2 +- filter/rastertolabel.c | 2 +- filter/rastertopwg.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/backend/lpd.c b/backend/lpd.c index bc13c6f6bf..6a5f32ad66 100644 --- a/backend/lpd.c +++ b/backend/lpd.c @@ -523,7 +523,7 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ if (tmpfilename[0]) unlink(tmpfilename); - if (fd) + if (fd > 0) close(fd); if (snmp_fd >= 0) @@ -948,7 +948,7 @@ lpd_queue(const char *hostname, /* I - Host to connect to */ * Next, open the print file and figure out its size... */ - if (print_fd) + if (print_fd > 0) { /* * Use the size from the print file... diff --git a/filter/rastertoepson.c b/filter/rastertoepson.c index 644e81e5e2..9de3986935 100644 --- a/filter/rastertoepson.c +++ b/filter/rastertoepson.c @@ -1141,7 +1141,7 @@ main(int argc, /* I - Number of command-line arguments */ */ cupsRasterClose(ras); - if (fd != 0) + if (fd > 0) close(fd); /* diff --git a/filter/rastertohp.c b/filter/rastertohp.c index d2743b2dd2..bb942c3595 100644 --- a/filter/rastertohp.c +++ b/filter/rastertohp.c @@ -813,7 +813,7 @@ main(int argc, /* I - Number of command-line arguments */ */ cupsRasterClose(ras); - if (fd != 0) + if (fd > 0) close(fd); /* diff --git a/filter/rastertolabel.c b/filter/rastertolabel.c index 8f75e9a176..e196b8685b 100644 --- a/filter/rastertolabel.c +++ b/filter/rastertolabel.c @@ -1263,7 +1263,7 @@ main(int argc, /* I - Number of command-line arguments */ */ cupsRasterClose(ras); - if (fd != 0) + if (fd > 0) close(fd); /* diff --git a/filter/rastertopwg.c b/filter/rastertopwg.c index 9c50f71a74..6ef0975d25 100644 --- a/filter/rastertopwg.c +++ b/filter/rastertopwg.c @@ -490,7 +490,7 @@ main(int argc, /* I - Number of command-line args */ } cupsRasterClose(inras); - if (fd) + if (fd > 0) close(fd); cupsRasterClose(outras); -- 2.47.3