From 0e3cc273717b047d8430852d9dc24fda1f2adb7c Mon Sep 17 00:00:00 2001 From: Till Kamppeter Date: Sun, 21 Aug 2022 00:30:36 +0200 Subject: [PATCH] libppd: Added more NULL checks when "libppd" extension not present This time added NULL checks in the ppdFilterPSToPS(), ppdFilterImageToPS(), and ppdFilterPDFToPS() filter functions. --- ppd/imagetops-pstops.c | 23 ++++++++++++++--------- ppd/pdftops.c | 5 +++-- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/ppd/imagetops-pstops.c b/ppd/imagetops-pstops.c index 6232ce5de..1a9aa2963 100644 --- a/ppd/imagetops-pstops.c +++ b/ppd/imagetops-pstops.c @@ -264,11 +264,11 @@ ppdFilterPSToPS(int inputfd, /* I - File descriptor input stream */ signal(SIGPIPE, SIG_IGN); -/* + /* * Process job options... */ - if (set_pstops_options(&doc, filter_data_ext->ppd, + if (set_pstops_options(&doc, (filter_data_ext ? filter_data_ext->ppd : NULL), data->job_id, data->job_user, data->job_title, data->copies, data->num_options, data->options, @@ -404,13 +404,14 @@ ppdFilterPSToPS(int inputfd, /* I - File descriptor input stream */ * Write any "exit server" options that have been selected... */ - ppdEmit(filter_data_ext->ppd, outputfp, PPD_ORDER_EXIT); + if (filter_data_ext) + ppdEmit(filter_data_ext->ppd, outputfp, PPD_ORDER_EXIT); /* * Write any JCL commands that are needed to print PostScript code... */ - if (doc.emit_jcl) + if (filter_data_ext && doc.emit_jcl) ppdEmitJCL(filter_data_ext->ppd, outputfp, doc.job_id, doc.user, doc.title); /* @@ -455,7 +456,8 @@ ppdFilterPSToPS(int inputfd, /* I - File descriptor input stream */ * Yes, filter the document... */ - copy_dsc(&doc, filter_data_ext->ppd, line, len, sizeof(line)); + if (filter_data_ext) + copy_dsc(&doc, filter_data_ext->ppd, line, len, sizeof(line)); } else { @@ -464,7 +466,8 @@ ppdFilterPSToPS(int inputfd, /* I - File descriptor input stream */ * a single page... */ - copy_non_dsc(&doc, filter_data_ext->ppd, line, len, sizeof(line)); + if (filter_data_ext) + copy_non_dsc(&doc, filter_data_ext->ppd, line, len, sizeof(line)); } /* @@ -480,7 +483,8 @@ ppdFilterPSToPS(int inputfd, /* I - File descriptor input stream */ if (doc.emit_jcl) { - if (filter_data_ext->ppd && filter_data_ext->ppd->jcl_end) + if (filter_data_ext && filter_data_ext->ppd && + filter_data_ext->ppd->jcl_end) ppdEmitJCLEnd(filter_data_ext->ppd, doc.outputfp); else doc_putc(&doc, 0x04); @@ -592,7 +596,7 @@ ppdFilterImageToPS(int inputfd, /* I - File descriptor input stream * int colorspace; /* Output colorspace */ int out_offset, /* Offset into output buffer */ out_length; /* Length of output buffer */ - ppd_file_t *ppd; /* PPD file */ + ppd_file_t *ppd = NULL; /* PPD file */ ppd_choice_t *choice; /* PPD option choice */ int num_options; /* Number of print options */ cups_option_t *options; /* Print options */ @@ -758,7 +762,8 @@ ppdFilterImageToPS(int inputfd, /* I - File descriptor input stream * * Process job options... */ - ppd = filter_data_ext->ppd; + if (filter_data_ext) + ppd = filter_data_ext->ppd; ppdFilterSetCommonOptions(ppd, num_options, options, 0, &doc.Orientation, &doc.Duplex, &doc.LanguageLevel, &doc.Color, diff --git a/ppd/pdftops.c b/ppd/pdftops.c index afdf81c53..323f8ddd5 100644 --- a/ppd/pdftops.c +++ b/ppd/pdftops.c @@ -280,7 +280,7 @@ ppdFilterPDFToPS(int inputfd, /* I - File descriptor input stream */ cf_filter_data_t pstops_filter_data; int ret; const char *val; /* Option value */ - ppd_file_t *ppd; /* PPD file */ + ppd_file_t *ppd = NULL; /* PPD file */ char resolution[128] = ""; /* Output resolution */ int xres = 0, yres = 0, /* resolution values */ mres, res, @@ -393,7 +393,8 @@ ppdFilterPDFToPS(int inputfd, /* I - File descriptor input stream */ num_options = cfJoinJobOptionsAndAttrs(data, num_options, &options); - ppd = filter_data_ext->ppd; + if (filter_data_ext) + ppd = filter_data_ext->ppd; /* * Process job options... -- 2.47.3