diff options
author | Jonathan Cowper-Andrewes <Jonathan.Ca@Sun.COM> | 2009-03-30 22:19:54 +0100 |
---|---|---|
committer | Jonathan Cowper-Andrewes <Jonathan.Ca@Sun.COM> | 2009-03-30 22:19:54 +0100 |
commit | a5669307eaef64af8519feb70d42f0aa0e7ec21a (patch) | |
tree | ac510b901e30abae5b6f348320f6cab85ca361ac /usr/src/lib/print | |
parent | becf5de312dcd786fe98ed1f17cfb64004fb2551 (diff) | |
download | illumos-gate-a5669307eaef64af8519feb70d42f0aa0e7ec21a.tar.gz |
6799615 return from stat() should be checked when looking for zero byte files
Diffstat (limited to 'usr/src/lib/print')
-rw-r--r-- | usr/src/lib/print/libpapi-ipp/common/ipp-support.c | 7 | ||||
-rw-r--r-- | usr/src/lib/print/libpapi-ipp/common/job.c | 10 | ||||
-rw-r--r-- | usr/src/lib/print/libpapi-lpd/common/lpd-job.c | 7 |
3 files changed, 21 insertions, 3 deletions
diff --git a/usr/src/lib/print/libpapi-ipp/common/ipp-support.c b/usr/src/lib/print/libpapi-ipp/common/ipp-support.c index ab3d1a337c..bbdf867b12 100644 --- a/usr/src/lib/print/libpapi-ipp/common/ipp-support.c +++ b/usr/src/lib/print/libpapi-ipp/common/ipp-support.c @@ -536,7 +536,12 @@ ipp_send_request_with_file(service_t *svc, papi_attribute_t **request, detailed_error(svc, "%s: %s", file, strerror(errno)); return (PAPI_DOCUMENT_ACCESS_ERROR); } else if (strcmp("standard input", file) != 0) { - stat(file, &statbuf); + if (stat(file, &statbuf) < 0) { + detailed_error(svc, + gettext("Cannot access file: %s: %s"), + file, strerror(errno)); + return (PAPI_DOCUMENT_ACCESS_ERROR); + } if (statbuf.st_size == 0) { detailed_error(svc, "Zero byte (empty) file: %s", file); diff --git a/usr/src/lib/print/libpapi-ipp/common/job.c b/usr/src/lib/print/libpapi-ipp/common/job.c index db93aedf75..e87df638cb 100644 --- a/usr/src/lib/print/libpapi-ipp/common/job.c +++ b/usr/src/lib/print/libpapi-ipp/common/job.c @@ -37,6 +37,7 @@ #include <fcntl.h> #include <sys/types.h> #include <sys/stat.h> +#include <libintl.h> #ifndef OPID_CUPS_MOVE_JOB #define OPID_CUPS_MOVE_JOB 0x400D @@ -249,7 +250,14 @@ internal_job_submit(papi_service_t handle, char *printer, } if (strcmp("standard input", files[i]) != 0) { - stat(files[i], &statbuf); + if (stat(files[i], &statbuf) < 0) { + detailed_error(svc, gettext( + "Cannot access file: %s:" + " %s"), files[i], + strerror(errno)); + return ( + PAPI_DOCUMENT_ACCESS_ERROR); + } if (statbuf.st_size == 0) { detailed_error(svc, "Zero byte (empty) file: " diff --git a/usr/src/lib/print/libpapi-lpd/common/lpd-job.c b/usr/src/lib/print/libpapi-lpd/common/lpd-job.c index 72f7bee4e9..86223f5e54 100644 --- a/usr/src/lib/print/libpapi-lpd/common/lpd-job.c +++ b/usr/src/lib/print/libpapi-lpd/common/lpd-job.c @@ -518,7 +518,12 @@ lpd_job_add_files(service_t *svc, papi_attribute_t **attributes, return (PAPI_NOT_AUTHORIZED); } if (strcmp("standard input", files[i]) != 0) { - stat(files[i], &statbuf); + if (stat(files[i], &statbuf) < 0) { + detailed_error(svc, + gettext("Cannot access file: %s: %s"), + files[i], strerror(errno)); + return (PAPI_DOCUMENT_ACCESS_ERROR); + } if (statbuf.st_size == 0) { detailed_error(svc, gettext("Zero byte (empty) file: %s"), |