From 58f9cea4615c2a2f56461dbde9949ad201e746dd Mon Sep 17 00:00:00 2001 From: Vitezslav Crhonek Date: Tue, 27 Aug 2019 15:06:07 +0200 Subject: [PATCH] Fix exit status, Fix issues found by static analysis --- sblim-wbemcli-1.6.3-covscan-fixes.patch | 97 +++++++++++++++++++++++ sblim-wbemcli-1.6.3-fix-exit-status.patch | 25 ++++++ sblim-wbemcli.spec | 10 ++- 3 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 sblim-wbemcli-1.6.3-covscan-fixes.patch create mode 100644 sblim-wbemcli-1.6.3-fix-exit-status.patch diff --git a/sblim-wbemcli-1.6.3-covscan-fixes.patch b/sblim-wbemcli-1.6.3-covscan-fixes.patch new file mode 100644 index 0000000..23909c3 --- /dev/null +++ b/sblim-wbemcli-1.6.3-covscan-fixes.patch @@ -0,0 +1,97 @@ +diff -up sblim-wbemcli-1.6.3/CimCurl.cpp.orig sblim-wbemcli-1.6.3/CimCurl.cpp +--- sblim-wbemcli-1.6.3/CimCurl.cpp.orig 2019-08-27 14:18:53.329846123 +0200 ++++ sblim-wbemcli-1.6.3/CimCurl.cpp 2019-08-27 14:18:53.332846130 +0200 +@@ -369,6 +369,7 @@ void CimomCurl::setClientCertificates(co + } else if (cacert) { + FILE *fp; + if ((fp = fopen(cacert, "r"))) { ++ fclose(fp); + if ((rv=curl_easy_setopt(mHandle,CURLOPT_SSL_VERIFYPEER,1))) { + cerr << getErrorMessage(rv) << endl; + throw HttpException("Could not enable peer verification."); +@@ -377,7 +378,6 @@ void CimomCurl::setClientCertificates(co + cerr << getErrorMessage(rv) << endl; + throw HttpException("Could not load CA certificate."); + } +- fclose(fp); + } else { + throw HttpException( + string("Could not open CA certificate file: ") + string(cacert) +diff -up sblim-wbemcli-1.6.3/CimXml.cpp.orig sblim-wbemcli-1.6.3/CimXml.cpp +--- sblim-wbemcli-1.6.3/CimXml.cpp.orig 2014-10-13 18:05:30.000000000 +0200 ++++ sblim-wbemcli-1.6.3/CimXml.cpp 2019-08-27 14:32:20.068589450 +0200 +@@ -159,7 +159,7 @@ int XmlBuffer::skipElement(const char *t + cerr<<"--- XmlBuffer::skipElement(\""<"); + char *e=strstr(cur,eTag); + if (e) { +@@ -451,7 +451,7 @@ AVPs::AVPs(char *s, PropertyArray &prop) + + AVPs::AVPs(char *s, ParameterArray ¶m) + { +- char *n, *t, *u, *v, *w; ++ char *n, *t, *u, *v; + int i,k,j,l; + bool name = false; + bool addAValue = false; +@@ -856,8 +856,6 @@ IMethodresponseXml::IMethodresponseXml(X + if (irv->getReturnData() == NULL) { + /* OpenWBEM support */ + throw NoReturnValue(); +- delete irv; +- irv=NULL; + } + if (xb.endTag("IMETHODRESPONSE")) return; + else throw ParseException("Expecting tag(2)"); +@@ -877,8 +875,6 @@ IMethodresponseXml::IMethodresponseXml(X + } + */ else if (xb.endTag("IMETHODRESPONSE")) { + throw NoReturnValue(); +- irv=NULL; +- return; + } + /* else throw ParseException("Expecting tag(1)"); + } +@@ -934,8 +930,6 @@ MethodresponseXml::MethodresponseXml(Xml + } + */ else if (xb.endTag("METHODRESPONSE")) { + throw NoReturnValue(); +- rvl=NULL; +- return; + } + /* else throw ParseException("Expecting tag(1)"); + } +@@ -2950,7 +2944,7 @@ char *strndup(char *f, int n) { + + URL::URL(const char *U) + { +- int pint,indir=0; ++ int indir=0; + char *p,*q,*phelp,*np,*last,*un,*b,*h,*z; + char *origu, *u; + u = origu = strdup(U); +@@ -3061,7 +3055,7 @@ URL::URL(const char *U) + zone_id = -1; + } + +- pint=strtol(port.c_str(),&np,10); ++ (void) strtol(port.c_str(),&np,10); + if (*np) throw URLException("Invalid port number"); + + if (!phelp || strlen(phelp+1) == 0) { +@@ -3168,9 +3162,11 @@ int URL::getNetDeviceNum(string devName) + + while (2 == fscanf(fp, scnfmt.c_str(), &dev_num, dev_name)) { + if (strcmp(devName.c_str(), dev_name) == 0) { /* match */ ++ fclose(fp); + return dev_num; + } + } ++ fclose(fp); + return -1; // zone id not found in interfaces table + #endif + } diff --git a/sblim-wbemcli-1.6.3-fix-exit-status.patch b/sblim-wbemcli-1.6.3-fix-exit-status.patch new file mode 100644 index 0000000..f82bfb3 --- /dev/null +++ b/sblim-wbemcli-1.6.3-fix-exit-status.patch @@ -0,0 +1,25 @@ +diff -up sblim-wbemcli-1.6.3/main.cpp.orig sblim-wbemcli-1.6.3/main.cpp +--- sblim-wbemcli-1.6.3/main.cpp.orig 2019-08-21 11:27:58.881274422 +0200 ++++ sblim-wbemcli-1.6.3/main.cpp 2019-08-21 11:27:58.886274433 +0200 +@@ -655,5 +655,5 @@ fini: + // These needs to be called once + curl_global_cleanup(); + #endif +- return 0; ++ return retval; + } +diff -up sblim-wbemcli-1.6.3/man/wbemcli.1.pre.in.orig sblim-wbemcli-1.6.3/man/wbemcli.1.pre.in +--- sblim-wbemcli-1.6.3/man/wbemcli.1.pre.in.orig 2019-08-21 11:27:58.883274426 +0200 ++++ sblim-wbemcli-1.6.3/man/wbemcli.1.pre.in 2019-08-21 11:27:58.886274433 +0200 +@@ -565,6 +565,11 @@ remote SSL protocol version. + .TP + .I @CACERT@ + The default CA certificate file. Can be overriden with \-cacert. ++.SH EXIT CODES ++.IP 0 ++Normal termination. ++.IP 16 ++Abnormal termination, see diagnostics printed to the standard error. + .SH AUTHOR + Adrian Schuur + .SH BUGS diff --git a/sblim-wbemcli.spec b/sblim-wbemcli.spec index c1215e1..4a67912 100644 --- a/sblim-wbemcli.spec +++ b/sblim-wbemcli.spec @@ -1,6 +1,6 @@ Name: sblim-wbemcli Version: 1.6.3 -Release: 15%{?dist} +Release: 16%{?dist} Summary: SBLIM WBEM Command Line Interface License: EPL-1.0 @@ -9,6 +9,8 @@ Source0: http://downloads.sourceforge.net/sblim/%{name}-%{version}.tar.bz Patch0: sblim-wbemcli-1.5.1-gcc43.patch Patch1: sblim-wbemcli-1.6.2-https-segfaults.patch Patch2: sblim-wbemcli-1.6.1-ssl-proto-option.patch +Patch3: sblim-wbemcli-1.6.3-fix-exit-status.patch +Patch4: sblim-wbemcli-1.6.3-covscan-fixes.patch BuildRequires: curl-devel >= 7.9.3 BuildRequires: binutils-devel >= 2.17.50.0.3-4 @@ -27,6 +29,8 @@ autoreconf --install --force %patch0 -p1 -b .gcc43 %patch1 -p1 -b .https-segfaults %patch2 -p1 -b .ssl-proto-option +%patch3 -p1 -b .fix-exit-status +%patch4 -p1 -b .covscan-fixes %build %configure CACERT=/etc/pki/Pegasus/client.pem @@ -43,6 +47,10 @@ mkdir -p $RPM_BUILD_ROOT/%{_datadir}/%{name} %{_datadir}/%{name} %changelog +* Tue Aug 27 2019 Vitezslav Crhonek - 1.6.3-16 +- Fix exit status (i. e. apply https://sourceforge.net/p/sblim/bugs/2761/) +- Fix issues found by static analysis + * Fri Jul 26 2019 Fedora Release Engineering - 1.6.3-15 - Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild