fix code defects found by Coverity
This commit is contained in:
parent
fa09de49f2
commit
fdfae8d301
98
units-1.88-coverity.patch
Normal file
98
units-1.88-coverity.patch
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
From 149121fe597e9d3ee818d6d1d0facf9175d6674d Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kamil Dudka <kdudka@redhat.com>
|
||||||
|
Date: Tue, 15 Nov 2011 19:24:00 +0100
|
||||||
|
Subject: [PATCH 1/2] units - fix defects found by Coverity
|
||||||
|
|
||||||
|
---
|
||||||
|
units.c | 18 +++++++++++-------
|
||||||
|
1 files changed, 11 insertions(+), 7 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/units.c b/units.c
|
||||||
|
index cdda76a..c4230c9 100644
|
||||||
|
--- a/units.c
|
||||||
|
+++ b/units.c
|
||||||
|
@@ -383,7 +383,7 @@ readunits(char *file, FILE *errfile,
|
||||||
|
struct prefixlist *pfxptr;
|
||||||
|
struct unitlist *uptr;
|
||||||
|
FILE *unitfile;
|
||||||
|
- char *line, *lineptr, *unitdef, *unitname, *permfile;
|
||||||
|
+ char *line = 0, *lineptr, *unitdef, *unitname, *permfile;
|
||||||
|
int len, linenum, linebufsize, goterr;
|
||||||
|
unsigned hashval, pval;
|
||||||
|
int locunitcount, locprefixcount, locfunccount;
|
||||||
|
@@ -399,12 +399,13 @@ readunits(char *file, FILE *errfile,
|
||||||
|
|
||||||
|
growbuffer(&line,&linebufsize);
|
||||||
|
|
||||||
|
- permfile = dupstr(file); /* This is a permanent copy to
|
||||||
|
- reference in the database.
|
||||||
|
- It is never freed. */
|
||||||
|
unitfile = fopen(file, "rt");
|
||||||
|
if (!unitfile)
|
||||||
|
return E_FILE;
|
||||||
|
+
|
||||||
|
+ permfile = dupstr(file); /* This is a permanent copy to
|
||||||
|
+ reference in the database.
|
||||||
|
+ It is never freed. */
|
||||||
|
while (!feof(unitfile)) {
|
||||||
|
if (!fgetslong(&line, &linebufsize, unitfile, &linenum))
|
||||||
|
break;
|
||||||
|
@@ -471,8 +472,10 @@ readunits(char *file, FILE *errfile,
|
||||||
|
}
|
||||||
|
readerr = readunits(includefile, errfile, unitcount, prefixcount,
|
||||||
|
funccount, depth+1);
|
||||||
|
- if (readerr == E_MEMORY)
|
||||||
|
+ if (readerr == E_MEMORY) {
|
||||||
|
+ fclose(unitfile);
|
||||||
|
return readerr;
|
||||||
|
+ }
|
||||||
|
if (readerr == E_FILE) {
|
||||||
|
if (errfile)
|
||||||
|
fprintf(errfile, "%s: unable to open included file '%s' at line %d of file '%s\n", progname, includefile, linenum, file);
|
||||||
|
@@ -1381,7 +1384,8 @@ subunitroot(int n,char *in[], char *out[])
|
||||||
|
char **ptr,**current;
|
||||||
|
int count;
|
||||||
|
|
||||||
|
- for(current = in;*current && *current==NULLUNIT;current++);
|
||||||
|
+ for(current = in;*current==NULLUNIT;current++)
|
||||||
|
+ if (!*current) return E_NOTROOT;
|
||||||
|
count = 0;
|
||||||
|
for(ptr=in;*ptr;ptr++){
|
||||||
|
if (*ptr==NULLUNIT) continue;
|
||||||
|
@@ -2618,7 +2622,7 @@ Typing 'search text' will show units whose names contain 'text'.\n\n",
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
- struct unittype have, want;
|
||||||
|
+ static struct unittype have, want;
|
||||||
|
char *havestr=0, *wantstr=0;
|
||||||
|
struct func *funcval;
|
||||||
|
int havestrsize=0; /* Only used if READLINE is undefined */
|
||||||
|
--
|
||||||
|
1.7.1
|
||||||
|
|
||||||
|
|
||||||
|
From 30ede89a0147189cd815afc58b1d82545b881bcd Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kamil Dudka <kdudka@redhat.com>
|
||||||
|
Date: Wed, 16 Nov 2011 13:37:09 +0100
|
||||||
|
Subject: [PATCH 2/2] units - use an annotation to suppress a false positive of Coverity
|
||||||
|
|
||||||
|
---
|
||||||
|
units.c | 1 +
|
||||||
|
1 files changed, 1 insertions(+), 0 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/units.c b/units.c
|
||||||
|
index c4230c9..28555a4 100644
|
||||||
|
--- a/units.c
|
||||||
|
+++ b/units.c
|
||||||
|
@@ -403,6 +403,7 @@ readunits(char *file, FILE *errfile,
|
||||||
|
if (!unitfile)
|
||||||
|
return E_FILE;
|
||||||
|
|
||||||
|
+ /* coverity[alloc_fn] */
|
||||||
|
permfile = dupstr(file); /* This is a permanent copy to
|
||||||
|
reference in the database.
|
||||||
|
It is never freed. */
|
||||||
|
--
|
||||||
|
1.7.1
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
Summary: A utility for converting amounts from one unit to another
|
Summary: A utility for converting amounts from one unit to another
|
||||||
Name: units
|
Name: units
|
||||||
Version: 1.88
|
Version: 1.88
|
||||||
Release: 3%{?dist}
|
Release: 4%{?dist}
|
||||||
Source: ftp://ftp.gnu.org/gnu/units/%{name}-%{version}.tar.gz
|
Source: ftp://ftp.gnu.org/gnu/units/%{name}-%{version}.tar.gz
|
||||||
URL: http://www.gnu.org/software/units/units.html
|
URL: http://www.gnu.org/software/units/units.html
|
||||||
License: GPLv3+
|
License: GPLv3+
|
||||||
@ -13,6 +13,7 @@ BuildRequires: bison
|
|||||||
BuildRequires: ncurses-devel
|
BuildRequires: ncurses-devel
|
||||||
BuildRequires: readline-devel
|
BuildRequires: readline-devel
|
||||||
Patch1: units-1.88-man-typo.patch
|
Patch1: units-1.88-man-typo.patch
|
||||||
|
Patch2: units-1.88-coverity.patch
|
||||||
|
|
||||||
%description
|
%description
|
||||||
Units converts an amount from one unit to another, or tells you what
|
Units converts an amount from one unit to another, or tells you what
|
||||||
@ -23,6 +24,7 @@ well as conversions such as Fahrenheit to Celsius.
|
|||||||
%prep
|
%prep
|
||||||
%setup -q
|
%setup -q
|
||||||
%patch1 -p1
|
%patch1 -p1
|
||||||
|
%patch2 -p1
|
||||||
|
|
||||||
%build
|
%build
|
||||||
%configure
|
%configure
|
||||||
@ -57,6 +59,9 @@ fi
|
|||||||
%{_mandir}/man1/*
|
%{_mandir}/man1/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Nov 16 2011 Kamil Dudka <kdudka@redhat.com> - 1.88-4
|
||||||
|
- fix code defects found by Coverity
|
||||||
|
|
||||||
* Mon Feb 07 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.88-3
|
* Mon Feb 07 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.88-3
|
||||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user