[pnm2ppa] Don't return a local variable out of scope (bug #704568).
Tim Waugh
twaugh at fedoraproject.org
Fri May 20 15:08:20 UTC 2011
commit 0faf404e22874ad3bd47d92b5bbe2b2484163119
Author: Tim Waugh <twaugh at redhat.com>
Date: Fri May 20 16:06:11 2011 +0100
Don't return a local variable out of scope (bug #704568).
pnm2ppa-coverity-return-local.patch | 52 +++++++++++++++++++++++++++++++++++
pnm2ppa.spec | 8 +++++-
2 files changed, 59 insertions(+), 1 deletions(-)
---
diff --git a/pnm2ppa-coverity-return-local.patch b/pnm2ppa-coverity-return-local.patch
new file mode 100644
index 0000000..ce7e1d3
--- /dev/null
+++ b/pnm2ppa-coverity-return-local.patch
@@ -0,0 +1,52 @@
+diff -up pnm2ppa-1.04/calibrate_ppa.c.coverity-return-local pnm2ppa-1.04/calibrate_ppa.c
+--- pnm2ppa-1.04/calibrate_ppa.c.coverity-return-local 2000-11-11 22:22:38.000000000 +0000
++++ pnm2ppa-1.04/calibrate_ppa.c 2011-05-20 16:04:23.233425268 +0100
+@@ -75,7 +75,7 @@ main (int argc, char *argv[])
+ BOOLEAN gamma = false ;
+ FILE *outFile = NULL ;
+ int testPattern = 0;
+- char *out_filepath = NULL;
++ char out_filepath[MAXPATHLEN];
+ char c;
+ static struct option long_opts[] = {
+ {"gamma",0,0,'g'},
+@@ -157,9 +157,7 @@ main (int argc, char *argv[])
+ {
+ if ( strlen(optarg) < MAXPATHLEN )
+ {
+- char filepath[MAXPATHLEN];
+- strncpy(filepath, optarg, MAXPATHLEN);
+- out_filepath = filepath ;
++ strncpy(out_filepath, optarg, MAXPATHLEN);
+ use_stdout = false ;
+ }
+ }
+diff -up pnm2ppa-1.04/pnm2ppa.c.coverity-return-local pnm2ppa-1.04/pnm2ppa.c
+--- pnm2ppa-1.04/pnm2ppa.c.coverity-return-local 2000-11-11 19:53:03.000000000 +0000
++++ pnm2ppa-1.04/pnm2ppa.c 2011-05-20 16:04:23.234425246 +0100
+@@ -145,20 +145,15 @@ print_pnm (FILE * fptr)
+ char *
+ readPath(char *input )
+ {
+- char File_path[MAXPATHLEN];
+ char *path = NULL;
+ /* security audit ajv 20001007; be very careful with input strings!*/
+ if (strlen(input) < MAXPATHLEN )
+ {
+- if ( strncpy (File_path, input, MAXPATHLEN ))
+- {
+- /*
+- a user-specifed file *File_path may later be opened;
+- should any extra validation of this be performed now ?
+- */
+- path = File_path;
+- return path;
+- }
++ path = strdup(input);
++ /*
++ a user-specifed file *path may later be opened;
++ should any extra validation of this be performed now ?
++ */
+ }
+ else
+ {
diff --git a/pnm2ppa.spec b/pnm2ppa.spec
index d734955..169016e 100644
--- a/pnm2ppa.spec
+++ b/pnm2ppa.spec
@@ -2,7 +2,7 @@ Name: pnm2ppa
Summary: Drivers for printing to HP PPA printers
Epoch: 1
Version: 1.04
-Release: 21%{?dist}
+Release: 22%{?dist}
URL: http://sourceforge.net/projects/pnm2ppa
Source: http://download.sourceforge.net/pnm2ppa/pnm2ppa-%{version}.tar.gz
# Following sourcelink is dead currently.
@@ -11,6 +11,8 @@ Source1: http://www.httptech.com/ppa/files/ppa-0.8.6.tar.gz
Patch2: pbm2ppa-20000205.diff
# Use RPM_OPT_FLAGS.
Patch3: pnm2ppa-redhat.patch
+# Don't return a local variable out of scope (bug #704568).
+Patch4: pnm2ppa-coverity-return-local.patch
License: GPLv2
Group: Applications/Publishing
@@ -29,6 +31,7 @@ Install pnm2ppa if you need to print to a PPA printer.
%setup -q -T -D -a 1
%patch2 -p0 -b .20000205
%patch3 -p1 -b .rh
+%patch4 -p1 -b .coverity-return-local
for file in docs/en/LICENSE pbm2ppa-0.8.6/LICENSE; do
sed "s|\r||g" $file > $file.new && \
@@ -83,6 +86,9 @@ done
%config(noreplace) %{_sysconfdir}/pbm2ppa.conf
%changelog
+* Fri May 20 2011 Tim Waugh <twaugh at redhat.com> - 1:1.04-22
+- Don't return a local variable out of scope (bug #704568).
+
* Wed Feb 09 2011 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 1:1.04-21
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
More information about the scm-commits
mailing list